From f9a7774eb10a086361dd767eecbcad2aeff0b169 Mon Sep 17 00:00:00 2001 From: Adrian Popescu Date: Tue, 28 Mar 2023 00:25:49 -0400 Subject: [PATCH] Fixed CMAKE CUDA Version. Updated compile doc --- CMakelists.txt | 31 ++++++++++++++---------- compile_from_source.md | 54 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 13 deletions(-) diff --git a/CMakelists.txt b/CMakelists.txt index 84c0a1dfe..18d0ea046 100644 --- a/CMakelists.txt +++ b/CMakelists.txt @@ -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) @@ -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) diff --git a/compile_from_source.md b/compile_from_source.md index c126341f3..cae90cc75 100644 --- a/compile_from_source.md +++ b/compile_from_source.md @@ -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`