Bitsandbytes documentation

Compiling from Source

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.45.4).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Compiling from Source

Linux

To compile from source, you need the following:

  • The ability to compile C++ (gcc, make, headers, etc)
  • CMake (version 3.22.1 or newer)
  • Python 3.10 or newer
  • The CUDA toolkit (nvcc)

On Ubuntu, install the first two with apt-get install -y build-essential cmake.

To install the CUDA toolkit, follow the instructions from your distro.

To install the package from source, then run

pip install -r requirements-dev.txt
cmake -DCOMPUTE_BACKEND=cuda -S .
make
pip install .

If you have multiple versions of CUDA installed, or have installed it in a non-standard location, please refer to cmake CUDA documentation for how to configure the CUDA compiler used.

Windows

The following is required to install from source on Windows

To install the CUDA toolkit, follow the instructions for Windows.

To install the package from source, then run

pip install -r requirements-dev.txt
cmake -DCOMPUTE_BACKEND=cuda -S .
cmake --build . --config Release
pip install .

Compilation for Kepler Architecture

From version 0.39.1, bitsandbytes no longer includes Kepler binaries in pip installations, requiring manual compilation. Follow the general steps and use cuda11x_nomatmul_kepler for Kepler-targeted compilation.