Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "install from source" instructions #1042

Closed
MatthiasKohl opened this issue Feb 6, 2024 · 3 comments · Fixed by #1047
Closed

Fix "install from source" instructions #1042

MatthiasKohl opened this issue Feb 6, 2024 · 3 comments · Fixed by #1047

Comments

@MatthiasKohl
Copy link

MatthiasKohl commented Feb 6, 2024

System Info

Applies to all CUDA platforms

Reproduction

Run the following instructions as given by the error output in the latest NVIDA NGC PyTorch container:

git clone https://github.com/TimDettmers/bitsandbytes.git
cd bitsandbytes
CUDA_VERSION=123
python setup.py install

--> these instructions won't install CUDA-enabled bitsandbytes. BTW, python setup.py has been obsolete for a long time.

Run the following instructions as given by https://huggingface.co/docs/bitsandbytes/main/en/installation#from-source:

git clone https://github.com/TimDettmers/bitsandbytes.git && cd bitsandbytes/
cmake -B build -DBUILD_CUDA=ON -S .
pip install .

--> still won't give a CUDA insall, BUILD_CUDA is not a CMake option used by this project, and the build folder is useless to pip install

Expected behavior

The install instructions here: https://huggingface.co/docs/bitsandbytes/main/en/installation#from-source
Are incorrect AFAICT:

Somewhat related issue: #1040

  1. -DBUILD_CUDA=ON doesn't seem to exist given CMakeLists , it should be -DCOMPUTE_BACKEND=[cpu|cuda|mps]
  2. making the build directory -B build is confusing since the setup.py isn't looking in that folder by default. In fact, setup.py looks in the main repo folder by default, which is odd since this means one has to build in-place, something that's fairly rare for python extensions. If this should stay that way, at least change the default instruction to -B .
  3. modern NVCC (I'm not sure whether this applies to all versions supported by bitsandbytes, but it should apply to most) support the "native" architecture. This is what almost every developer wants, and wastes much fewer compilation cycles than having all architectures by default. So I'd suggest adding a check in CMake for -DCOMPUTE_CAPABILITY=native to pass the flag -arch=native to NVCC, then use that as a default
  4. The install instructions still lack the call to either make or cmake --build

So the final install isntructions I'd suggest at the moment is:

cmake -B . -DCOMPUTE_BACKEND=cuda -S .
cmake --build .

and ultimately, it would be nice to get to this (cannot work with the current CMakeLists):

cmake -B . -DCOMPUTE_BACKEND=cuda -DCOMPUTE_CAPABILITY=native -S .
cmake --build .
@younesbelkada
Copy link
Collaborator

Great catch @MatthiasKohl I can confirm this works perfect, would you be happy to fix the installation.md file on the docs? https://github.com/TimDettmers/bitsandbytes/blob/main/docs/source/installation.mdx otherwise I can do it as well

@younesbelkada
Copy link
Collaborator

#1047 from @rickardp is fixing the commands on the docs

@MatthiasKohl
Copy link
Author

@younesbelkada Thank you so much for fixing this so quickly ! I'd love to contribute, but I'm on CET, so I wasn't available anymore yesterday late in the evening. I'll give it a shot next time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants