This repository provides scripts to build GPU-enabled wheels for the faiss library.
Distributes faiss-gpu-cuXX packages to PyPI using the contents of this repository.
Key Features
No local CUDA installation required - Dynamically links to CUDA Runtime and cuBLAS libraries from PyPI
Builds CUDA 11.8+ and CUDA 12.1+ compatible wheels
Supports Volta to Ada Lovelace architecture GPUs (Compute Capability 7.0–8.9)
Bundles OpenBLAS in Linux
Reduces wheel file size through dynamic linking instead of static compilation
Important Requirements
The published faiss-gpu-cuXX packages require proper system setup that cannot be managed by pip. It is your responsibility to prepare a suitable environment:
NVIDIA Driver: Your host must have a CUDA-compatible NVIDIA driver installed
The minimum driver version depends on the CUDA version that gets installed
GPU Architecture: Your GPU must be compatible (Compute Capability 7.0–8.9)
Supported: Volta, Turing, Ampere, Ada Lovelace
Library Compatibility: If you install multiple CUDA-dependent libraries (e.g., PyTorch) in the same environment, they must link to the same CUDA version
GPU Architecture Support for PyPI Packages
Support Policy for faiss-gpu-cu11 and faiss-gpu-cu12
Note: This is an unofficial, personal development project with limited computational resources. Due to these constraints, comprehensive testing across all NVIDIA GPU architectures is not feasible. The pre-built and packages on PyPI aim to support the same GPU architecture range (Compute Capability 7.0–8.9) as the official Faiss repository.
faiss-gpu-cu11
faiss-gpu-cu12
Sponsoring New GPU Architecture Support
Adding support for a new GPU architecture (e.g., Hopper, Blackwell) requires dedicated hardware for building and testing. NVIDIA GPUs have limited compatibility across compute capabilities — binaries built for one architecture do not necessarily work correctly on another. Distributing untested wheels is not an option.
This is an unfunded personal project. If you or your organization need support for an architecture outside the current range, please consider sponsoring this project to help cover the hardware and infrastructure costs. For ongoing discussion and status updates, see Support for New GPU Architectures.
For Unsupported GPU Architectures
If you have a GPU architecture that is not supported by these pre-built wheels:
Build from Source: Use this repository's code to build wheels for your specific architecture (see Building from Source section)
Installation
The faiss-gpu-cu11 and faiss-gpu-cu12 wheels are available on PyPI. Choose the appropriate version for your CUDA environment.
For CUDA 12
# Install with fixed CUDA 12.1 (requires NVIDIA Driver ≥R530)
pip install 'faiss-gpu-cu12[fix-cuda]'
# Install with CUDA 12.X (X≥1) - allows flexibility but driver requirement varies
pip install faiss-gpu-cu12
Details:
faiss-gpu-cu12 is built with CUDA Toolkit 12.1 and maintains minor version compatibility
With [fix-cuda]: Installs exactly CUDA 12.1, requiring NVIDIA Driver ≥R530
Without [fix-cuda]: Allows any CUDA 12.X (X≥1), driver requirement depends on the actual CUDA version installed
For example: CUDA 12.4 requires Driver ≥R550
Use without [fix-cuda] when integrating with other CUDA-dependent packages (e.g., PyTorch with CUDA 12.4)
System Requirements:
OS: Linux x86_64 (glibc ≥2.17)
GPU: Compute Capability 7.0–8.9
For CUDA 11
# Install with CUDA 11.8 (requires NVIDIA Driver ≥R520)
pip install faiss-gpu-cu11[fix-cuda]
# Same as above (CUDA 11.8 is the final version)
pip install faiss-gpu-cu11
Details:
faiss-gpu-cu11 is built with CUDA Toolkit 11.8
Both commands install CUDA 11.8 since no newer CUDA 11.X versions exist
Warning: When installing without [fix-cuda], pip may resolve to a newer CUDA version that requires a newer driver than you have installed. Always verify driver compatibility before installation.
Advanced: Using System CUDA Libraries
If you need to use system-installed CUDA instead of PyPI CUDA packages, you can bypass the automatic CUDA loading:
Exclude PyPI CUDA dependencies using your package manager (e.g., uv, pdm)
Set environment variable: _FAISS_WHEEL_DISABLE_CUDA_PRELOAD=1
Ensure CUDA libraries are accessible via LD_LIBRARY_PATH