Custom Ollama build with CUDA support for NVIDIA GPUs (GTX 9xx through RTX 50xx) on Linux systems.
-
RUNPATH stub issue (non-NixOS): The upstream nixpkgs
ollama-cudapackage has stub library paths in RUNPATH that prevent GPU detection on non-NixOS systems. This build removes those stub paths. -
Extended CUDA architectures: Adds support for newer GPU architectures (including sm_120 for RTX 5090) not yet in upstream nixpkgs.
| Branch | Description |
|---|---|
latest |
Bleeding edge - tracks upstream Ollama GitHub releases |
main |
Stable - most recently deprecated version from latest |
v0.x.x |
Archived versions (e.g., v0.14.3, v0.14.1) |
# Clone this repo
git clone https://github.com/barstoolbluz/ollama-cuda.git
cd ollama-cuda
# For stable version (main branch - default)
flox build ollama-cuda
# For bleeding edge
git checkout latest
flox build ollama-cuda
# For specific version (use `git branch -a` to list available versions)
git checkout v0.14.3
flox build ollama-cuda
# Run the built binary
./result-ollama-cuda/bin/ollama serve# Clone this repo
git clone https://github.com/barstoolbluz/ollama-cuda.git
cd ollama-cuda
# Build
nix build --extra-experimental-features 'nix-command flakes'
# Run the built binary
./result/bin/ollama serve
# Or run directly without building first
nix run --extra-experimental-features 'nix-command flakes' .
# Or install to your profile
nix profile install --extra-experimental-features 'nix-command flakes' .- CUDA support for RTX 5090 (sm_120 / compute 12.0)
- All 9 GPU architectures supported (Maxwell through Blackwell)
- Automatic RUNPATH fixing to remove stub libraries
- Works on any Linux distribution (NixOS and non-NixOS)
| Architecture | Compute | GPUs |
|---|---|---|
| sm_52 | Maxwell | GTX 9xx |
| sm_61 | Pascal | GTX 10xx |
| sm_75 | Turing | RTX 20xx |
| sm_80 | Ampere | RTX 30xx |
| sm_86 | Ampere | RTX 30xx mobile |
| sm_89 | Ada Lovelace | RTX 40xx |
| sm_90 | Hopper | H100 |
| sm_100 | Blackwell | Datacenter |
| sm_120 | Blackwell | RTX 50xx |
The Nix expressions (.flox/pkgs/ollama-cuda.nix for Flox, flake.nix for pure Nix):
- Fetch the specified Ollama version directly from GitHub
- Override upstream
ollama-cudawith extended CUDA architectures - Use
preInstallCheckphase to run AFTERautoPatchelfHook - Remove stub library paths from
libggml-cuda.soRUNPATH - Allow proper GPU detection on non-NixOS systems
# Publish to your personal catalog
flox publish ollama-cuda
# Publish to an organization
flox publish -o myorg ollama-cuda
# Then install from anywhere
flox install <username>/ollama-cuda- OS: Linux (any distribution)
- GPU: NVIDIA CUDA-capable GPU
- Driver: NVIDIA driver appropriate for your GPU (580.82.07+ for RTX 5090)
- Tools: Flox OR Nix with flakes enabled
.
├── .flox/
│ ├── env/manifest.toml # Flox environment definition
│ └── pkgs/
│ └── ollama-cuda.nix # Nix expression (for Flox)
├── flake.nix # Nix flake (for pure Nix/NixOS)
├── flake.lock # Flake lock file
└── README.md
# Check GPU is visible
nvidia-smi
# Check LD_AUDIT is set (Flox only, within flox activate)
flox activate -- env | grep LD_AUDIT
# Run with debug output
# Flox build:
OLLAMA_DEBUG=1 ./result-ollama-cuda/bin/ollama serve
# Nix flake build:
OLLAMA_DEBUG=1 ./result/bin/ollama serve# Should NOT contain "stubs"
# Flox build:
readelf -d result-ollama-cuda/lib/ollama/libggml-cuda.so | grep RUNPATH
# Nix flake build:
readelf -d result/lib/ollama/libggml-cuda.so | grep RUNPATH# Clean and rebuild (Flox)
rm -rf result-ollama-cuda
flox build ollama-cuda
# Clean and rebuild (Nix flake)
rm -rf result
nix build --extra-experimental-features 'nix-command flakes'This custom build configuration is provided as-is. Ollama itself is licensed under MIT.