Skip to content

Commit

Permalink
Fixed CMAKE CUDA Version. Updated compile doc
Browse files Browse the repository at this point in the history
  • Loading branch information
acpopescu committed Mar 28, 2023
1 parent 2495ac0 commit f9a7774
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 13 deletions.
31 changes: 18 additions & 13 deletions CMakelists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,31 @@ set(FILES_CPP csrc/common.cpp csrc/cpu_ops.cpp csrc/pythonInterface.c)

option(MAKE_CUDA_BUILD "Build using CUDA" ON)
option(NO_CUBLASLT "Don't use CUBLAST" OFF)

set(COMPUTE_CAPABILITY
50 52 60 61 70 72
)

set(CC_KEPLER 35 37)
set(CUDA_VERSION "11.7" CACHE STRING "CUDA Version DLL Name: 11.0, 11.7, 11.6")
set(CUDA_VERSION_FIXED "")
set(CUDA_VERSION_MAJOR "")
string(REPLACE "." "" CUDA_VERSION_FIXED "${CUDA_VERSION}")
string(REGEX MATCH "[^\.]+" CUDA_VERSION_MAJOR "${CUDA_VERSION}")
# Later versions of CUDA support the new architectures
set(CC_CUDA10x 75)

set(CC_CUDA110 75 80)
set(CC_CUDA11x 75 80 86)
set(CC_cublasLt110 75 80)

set(CC_cublasLt111 75 80 86)
set(CC_ADA_HOPPER 89 90)
set(CC_CUDA12x 89 90)

add_definitions(-DUSE_AVX2 -DUSE_AVX)
if( MAKE_CUDA_BUILD )
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 75 80 86)
if(${CUDA_VERSION} EQUAL "11.0")
set(CMAKE_CUDA_ARCHITECTURES ${CC_CUDA110})
elseif(${CUDA_VERSION_MAJOR} EQUAL "11")
set(CMAKE_CUDA_ARCHITECTURES ${CC_CUDA11x})
elseif(${CUDA_VERSION_MAJOR} EQUAL "12")
set(CMAKE_CUDA_ARCHITECTURES ${CC_CUDA12x})
else()
set(CMAKE_CUDA_ARCHITECTURES ${CC_CUDA10x})
set(NO_CUBLASLT ON)
endif()
endif()

if(NOT DEFINED CMAKE_CUDA_STANDARD)
Expand All @@ -54,7 +59,7 @@ if( MAKE_CUDA_BUILD )
POSITION_INDEPENDENT_CODE ON
CUDA_SEPARABLE_COMPILATION ON
PREFIX ""
OUTPUT_NAME "libbitsandbytes_cuda${CMAKE_CUDA_STANDARD}7"
OUTPUT_NAME "libbitsandbytes_cuda${CUDA_VERSION_FIXED}"
LINKER_LANGUAGE C
WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
# add_link_options(-Wl,--export-all-symbols)
Expand Down
54 changes: 54 additions & 0 deletions compile_from_source.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,59 @@
# Compiling from source

## Windows

CPU NOT TESTED

Ensure you have your environment you want to bring in bitsandbytes. (a bloom setup, textgen-ui, etc) - via conda.
I'd suggest to install MAMBA and use it, as it's way faster.

IMPORTANT - ensure your environment.yml matches your installed CUDA version in Visual Studio. Keep One VERSION.

1. environment.yml. Replace/tweak as necesarry (remove cuda, change version):
```
name: mycompileenv
channels:
- pytorch
- nvidia
- huggingface
- conda-forge
- anaconda
dependencies:
- python=3.10.9
- pytorch-cuda=11.7
- pytorch
- torchvision
- torchaudio
- transformers
- cudatoolkit=11.7
- jupyter
- notebook
- pytest
```

2. Then open POWERSHELL
```
conda install -c conda-forge mamba
mamba env create
mamba env activate mycompileenv
& "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1" -List -Arch amd64
```
At this point - select your visual studio installation - aka hit 1

3. Go into your bitsandbytes folder and run `cmake-gui .`
4. Make sure you put the build folder correctly, append "build" to Where to build the binaries
5. Hit Configure
6. Set your CUDA_VERSION to whatever you have. If you deselect MAKE_CUDA_BUILD, leave as is
7. Hit Configure again, then Generate
8. Open Visual Studio and select Release as configuration. Build Solution
9. copy everything from `build\Release\*.*` over in the `bitsandbytes` folder (the one with the python modules)
10. run tests `python -m pytest`. You may need to use `mamba` to install other modules
11. build wheel `mamba install build` and then `python -m build --wheel`
12. install wheel `pip install .\dist\*.whl`


## Linux
Basic steps.
1. `make [target]` where `[target]` is among `cuda92, cuda10x, cuda110, cuda11x, cuda12x, cpuonly`
2. `CUDA_VERSION=XXX python setup.py install`
Expand Down

0 comments on commit f9a7774

Please sign in to comment.