Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions pkgs/development/python-modules/llama-cpp-python/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# nativeBuildInputs
cmake,
ninja,
autoAddDriverRunpath,

# build-system
pathspec,
Expand Down Expand Up @@ -73,20 +74,23 @@ buildPythonPackage rec {
# -mcpu, breaking linux build as follows:
#
# cc1: error: unknown value ‘native+nodotprod+noi8mm+nosve’ for ‘-mcpu’
"-DGGML_NATIVE=off"
"-DGGML_BUILD_NUMBER=1"
(lib.cmakeBool "GGML_NATIVE" false)
(lib.cmakeFeature "GGML_BUILD_NUMBER" "1")
]
++ lib.optionals cudaSupport [
"-DGGML_CUDA=on"
"-DCUDAToolkit_ROOT=${lib.getDev cudaPackages.cuda_nvcc}"
"-DCMAKE_CUDA_COMPILER=${lib.getExe cudaPackages.cuda_nvcc}"
(lib.cmakeBool "GGML_CUDA" true)
(lib.cmakeFeature "CUDAToolkit_ROOT" "${lib.getDev cudaPackages.cuda_nvcc}")
(lib.cmakeFeature "CMAKE_CUDA_COMPILER" "${lib.getExe cudaPackages.cuda_nvcc}")
];

enableParallelBuilding = true;

nativeBuildInputs = [
cmake
ninja
]
++ lib.optionals cudaSupport [
autoAddDriverRunpath
];

build-system = [
Expand Down Expand Up @@ -125,7 +129,13 @@ buildPythonPackage rec {
"test_real_llama"
];

pythonImportsCheck = [ "llama_cpp" ];
pythonImportsCheck = lib.optionals (!cudaSupport) [
# `libllama.so` is loaded at import time, and failing when cudaSupport is enabled as the cuda
# driver is missing in the sandbox:
# RuntimeError: Failed to load shared library '/nix/store/...-python3.13-llama-cpp-python-0.3.16/lib/python3.13/site-packages/llama_cpp/lib/libllama.so':
# libcuda.so.1: cannot open shared object file: No such file or directory
"llama_cpp"
];

passthru = {
updateScript = gitUpdater {
Expand Down
Loading