[GH-ISSUE #1024] Packaging ollama + cuda for Arch Linux #47011

Closed
opened 2026-04-28 02:40:23 -05:00 by GiteaMirror · 11 comments
Owner

Originally created by @xyproto on GitHub (Nov 7, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/1024

Hi! Arch Linux package maintainer for the ollama and ollama-cuda packages here.

Thanks for creating Ollama, it makes LLMs more fun to deal with!

When compiling v0.1.8 for Arch Linux, using this PKGBUILD:

pkgname=ollama-cuda
pkgdesc='Create, run and share large language models (LLMs) with CUDA'
pkgver=0.1.8
pkgrel=1
arch=(x86_64)
url='https://github.com/jmorganca/ollama'
license=(MIT)
provides=(ollama)
conflicts=(ollama)
makedepends=(cmake cuda git go setconf)
_ollamacommit=e21579a0f1548e2d1f77411af3df2037c1f144fe # tag: v0.1.8
# The git submodule commit hashes are here:
# https://github.com/jmorganca/ollama/tree/v0.1.8/llm/llama.cpp
_ggmlcommit=9e232f0234073358e7031c1b8d7aa45020469a3b
_ggufcommit=9e70cc03229df19ca2d28ce23cc817198f897278
source=(git+$url#commit=$_ollamacommit
        ggml::git+https://github.com/ggerganov/llama.cpp#commit=$_ggmlcommit
        gguf::git+https://github.com/ggerganov/llama.cpp#commit=$_ggufcommit)
b2sums=('SKIP'
        'SKIP'
        'SKIP')

prepare() {
  cd ${pkgname/-cuda}

  rm -frv llm/llama.cpp/gg{ml,uf}

  # Copy git submodule files instead of symlinking because the build process is sensitive to symlinks.
  cp -r "$srcdir/ggml" llm/llama.cpp/ggml
  cp -r "$srcdir/gguf" llm/llama.cpp/gguf

  # Do not git clone when "go generate" is being run.
  sed -i 's,git submodule,true,g' llm/llama.cpp/generate_linux.go

  # Set the version number
  setconf version/version.go 'var Version string' "\"$pkgver\""
}

build() {
  export CGO_CFLAGS="$CFLAGS" CGO_CPPFLAGS="$CPPFLAGS" CGO_CXXFLAGS="$CXXFLAGS" CGO_LDFLAGS="$LDFLAGS"
  cd ${pkgname/-cuda}
  go generate ./...
  go build -buildmode=pie -trimpath -mod=readonly -modcacherw -ldflags=-linkmode=external -ldflags=-buildid=''
}

check() {
  cd ${pkgname/-cuda}
  go test ./...
}

package() {
  cd ${pkgname/-cuda}
  install -Dm755 ${pkgname/-cuda} "$pkgdir/usr/bin/${pkgname/-cuda}"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

I get:

- Found CUDAToolkit: /opt/cuda/include (found version "12.3.52")
-- cuBLAS found
CMake Error at /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:753 (message):
Compiling the CUDA compiler identification source file
"CMakeCUDACompilerId.cu" failed.

Compiler: /opt/cuda/bin/nvcc

Build flags:

Id flags: --keep;--keep-dir;tmp -v



The output was:

2

#$ _NVVM_BRANCH_=nvvm

#$ _SPACE_=

#$ _CUDART_=cudart

#$ _HERE_=/opt/cuda/bin

#$ _THERE_=/opt/cuda/bin

#$ _TARGET_SIZE_=

#$ _TARGET_DIR_=

#$ _TARGET_DIR_=targets/x86_64-linux

#$ TOP=/opt/cuda/bin/..

#$ NVVMIR_LIBRARY_DIR=/opt/cuda/bin/../nvvm/libdevice

#$ LD_LIBRARY_PATH=/opt/cuda/bin/../lib:

#$
PATH=/opt/cuda/bin/../nvvm/bin:/opt/cuda/bin:/usr/lib/go/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_pn


#$ INCLUDES="-I/opt/cuda/bin/../targets/x86_64-linux/include"

#$ LIBRARIES= "-L/opt/cuda/bin/../targets/x86_64-linux/lib/stubs"
"-L/opt/cuda/bin/../targets/x86_64-linux/lib"

#$ CUDAFE_FLAGS=

#$ PTXAS_FLAGS=

#$ rm tmp/a_dlink.reg.c

#$ gcc -D__CUDA_ARCH_LIST__=520 -E -x c++ -D__CUDACC__ -D__NVCC__
"-I/opt/cuda/bin/../targets/x86_64-linux/include" -D__CUDACC_VER_MAJOR__=12
-D__CUDACC_VER_MINOR__=3 -D__CUDACC_VER_BUILD__=52
-D__CUDA_API_VER_MAJOR__=12 -D__CUDA_API_VER_MINOR__=3
-D__NVCC_DIAG_PRAGMA_SUPPORT__=1 -include "cuda_runtime.h" -m64
"CMakeCUDACompilerId.cu" -o "tmp/CMakeCUDACompilerId.cpp4.ii"

#$ cudafe++ --c++17 --gnu_version=130201 --display_error_number
--orig_src_file_name "CMakeCUDACompilerId.cu" --orig_src_path_name
"/build/ollama-cuda/src/ollama/llm/llama.cpp/ggml/build/cuda/CMakeFiles/3.27.7/CompilerIdCUDA/CMakeCUDACompilerId.cu"
--allow_managed --m64 --parse_templates --gen_c_file_name
"tmp/CMakeCUDACompilerId.cudafe1.cpp" --stub_file_name
"CMakeCUDACompilerId.cudafe1.stub.c" --gen_module_id_file
--module_id_file_name "tmp/CMakeCUDACompilerId.module_id"
"tmp/CMakeCUDACompilerId.cpp4.ii"

/usr/include/bits/floatn.h(86): error: invalid combination of type
specifiers

typedef __float128 _Float128;
^



/usr/include/bits/floatn-common.h(214): error: invalid combination of type
specifiers

typedef float _Float32;
^



/usr/include/bits/floatn-common.h(251): error: invalid combination of type
specifiers

typedef double _Float64;
^



/usr/include/bits/floatn-common.h(268): error: invalid combination of type
specifiers

typedef double _Float32x;
^



/usr/include/bits/floatn-common.h(285): error: invalid combination of type
specifiers

typedef long double _Float64x;
^



5 errors detected in the compilation of "CMakeCUDACompilerId.cu".

# --error 0x2 --





Call Stack (most recent call first):
/usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
/usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test)
/usr/share/cmake/Modules/CMakeDetermineCUDACompiler.cmake:307 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:250 (enable_language)


-- Configuring incomplete, errors occurred!
llm/llama.cpp/generate_linux.go:21: running "cmake": exit status 1

Building the regular ollama package, where cuda/nvcc are not installed before building, works fine.

Attaching logs.

ollama-cuda-0.1.8-1-x86_64-build.log
ollama-cuda-0.1.8-1-x86_64-prepare.log

Advice for how to package ollama + cuda for Arch Linux is welcome.

Originally created by @xyproto on GitHub (Nov 7, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/1024 Hi! Arch Linux package maintainer for the `ollama` and `ollama-cuda` packages here. Thanks for creating Ollama, it makes LLMs more fun to deal with! When compiling `v0.1.8` for Arch Linux, using this PKGBUILD: ```bash pkgname=ollama-cuda pkgdesc='Create, run and share large language models (LLMs) with CUDA' pkgver=0.1.8 pkgrel=1 arch=(x86_64) url='https://github.com/jmorganca/ollama' license=(MIT) provides=(ollama) conflicts=(ollama) makedepends=(cmake cuda git go setconf) _ollamacommit=e21579a0f1548e2d1f77411af3df2037c1f144fe # tag: v0.1.8 # The git submodule commit hashes are here: # https://github.com/jmorganca/ollama/tree/v0.1.8/llm/llama.cpp _ggmlcommit=9e232f0234073358e7031c1b8d7aa45020469a3b _ggufcommit=9e70cc03229df19ca2d28ce23cc817198f897278 source=(git+$url#commit=$_ollamacommit ggml::git+https://github.com/ggerganov/llama.cpp#commit=$_ggmlcommit gguf::git+https://github.com/ggerganov/llama.cpp#commit=$_ggufcommit) b2sums=('SKIP' 'SKIP' 'SKIP') prepare() { cd ${pkgname/-cuda} rm -frv llm/llama.cpp/gg{ml,uf} # Copy git submodule files instead of symlinking because the build process is sensitive to symlinks. cp -r "$srcdir/ggml" llm/llama.cpp/ggml cp -r "$srcdir/gguf" llm/llama.cpp/gguf # Do not git clone when "go generate" is being run. sed -i 's,git submodule,true,g' llm/llama.cpp/generate_linux.go # Set the version number setconf version/version.go 'var Version string' "\"$pkgver\"" } build() { export CGO_CFLAGS="$CFLAGS" CGO_CPPFLAGS="$CPPFLAGS" CGO_CXXFLAGS="$CXXFLAGS" CGO_LDFLAGS="$LDFLAGS" cd ${pkgname/-cuda} go generate ./... go build -buildmode=pie -trimpath -mod=readonly -modcacherw -ldflags=-linkmode=external -ldflags=-buildid='' } check() { cd ${pkgname/-cuda} go test ./... } package() { cd ${pkgname/-cuda} install -Dm755 ${pkgname/-cuda} "$pkgdir/usr/bin/${pkgname/-cuda}" install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" } ``` I get: ``` - Found CUDAToolkit: /opt/cuda/include (found version "12.3.52") -- cuBLAS found CMake Error at /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:753 (message): Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed. Compiler: /opt/cuda/bin/nvcc Build flags: Id flags: --keep;--keep-dir;tmp -v The output was: 2 #$ _NVVM_BRANCH_=nvvm #$ _SPACE_= #$ _CUDART_=cudart #$ _HERE_=/opt/cuda/bin #$ _THERE_=/opt/cuda/bin #$ _TARGET_SIZE_= #$ _TARGET_DIR_= #$ _TARGET_DIR_=targets/x86_64-linux #$ TOP=/opt/cuda/bin/.. #$ NVVMIR_LIBRARY_DIR=/opt/cuda/bin/../nvvm/libdevice #$ LD_LIBRARY_PATH=/opt/cuda/bin/../lib: #$ PATH=/opt/cuda/bin/../nvvm/bin:/opt/cuda/bin:/usr/lib/go/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_pn #$ INCLUDES="-I/opt/cuda/bin/../targets/x86_64-linux/include" #$ LIBRARIES= "-L/opt/cuda/bin/../targets/x86_64-linux/lib/stubs" "-L/opt/cuda/bin/../targets/x86_64-linux/lib" #$ CUDAFE_FLAGS= #$ PTXAS_FLAGS= #$ rm tmp/a_dlink.reg.c #$ gcc -D__CUDA_ARCH_LIST__=520 -E -x c++ -D__CUDACC__ -D__NVCC__ "-I/opt/cuda/bin/../targets/x86_64-linux/include" -D__CUDACC_VER_MAJOR__=12 -D__CUDACC_VER_MINOR__=3 -D__CUDACC_VER_BUILD__=52 -D__CUDA_API_VER_MAJOR__=12 -D__CUDA_API_VER_MINOR__=3 -D__NVCC_DIAG_PRAGMA_SUPPORT__=1 -include "cuda_runtime.h" -m64 "CMakeCUDACompilerId.cu" -o "tmp/CMakeCUDACompilerId.cpp4.ii" #$ cudafe++ --c++17 --gnu_version=130201 --display_error_number --orig_src_file_name "CMakeCUDACompilerId.cu" --orig_src_path_name "/build/ollama-cuda/src/ollama/llm/llama.cpp/ggml/build/cuda/CMakeFiles/3.27.7/CompilerIdCUDA/CMakeCUDACompilerId.cu" --allow_managed --m64 --parse_templates --gen_c_file_name "tmp/CMakeCUDACompilerId.cudafe1.cpp" --stub_file_name "CMakeCUDACompilerId.cudafe1.stub.c" --gen_module_id_file --module_id_file_name "tmp/CMakeCUDACompilerId.module_id" "tmp/CMakeCUDACompilerId.cpp4.ii" /usr/include/bits/floatn.h(86): error: invalid combination of type specifiers typedef __float128 _Float128; ^ /usr/include/bits/floatn-common.h(214): error: invalid combination of type specifiers typedef float _Float32; ^ /usr/include/bits/floatn-common.h(251): error: invalid combination of type specifiers typedef double _Float64; ^ /usr/include/bits/floatn-common.h(268): error: invalid combination of type specifiers typedef double _Float32x; ^ /usr/include/bits/floatn-common.h(285): error: invalid combination of type specifiers typedef long double _Float64x; ^ 5 errors detected in the compilation of "CMakeCUDACompilerId.cu". # --error 0x2 -- Call Stack (most recent call first): /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD) /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test) /usr/share/cmake/Modules/CMakeDetermineCUDACompiler.cmake:307 (CMAKE_DETERMINE_COMPILER_ID) CMakeLists.txt:250 (enable_language) -- Configuring incomplete, errors occurred! llm/llama.cpp/generate_linux.go:21: running "cmake": exit status 1 ``` Building the regular `ollama` package, where `cuda`/`nvcc` are not installed before building, works fine. Attaching logs. [ollama-cuda-0.1.8-1-x86_64-build.log](https://github.com/jmorganca/ollama/files/13274355/ollama-cuda-0.1.8-1-x86_64-build.log) [ollama-cuda-0.1.8-1-x86_64-prepare.log](https://github.com/jmorganca/ollama/files/13274356/ollama-cuda-0.1.8-1-x86_64-prepare.log) Advice for how to package ollama + cuda for Arch Linux is welcome.
Author
Owner

@geekodour commented on GitHub (Nov 7, 2023):

This error is more llama.cpp specific as far as i understand. I was trying to install the same in nixos yesterday and faced similar issues, https://github.com/NixOS/nixpkgs/pull/257760#issuecomment-1794967371

<!-- gh-comment-id:1797992841 --> @geekodour commented on GitHub (Nov 7, 2023): This error is more llama.cpp specific as far as i understand. I was trying to install the same in nixos yesterday and faced similar issues, https://github.com/NixOS/nixpkgs/pull/257760#issuecomment-1794967371
Author
Owner

@xyproto commented on GitHub (Nov 7, 2023):

I haven't tested this yet, but there is a new llama.cpp commit from 2 days ago that might fix this issue:

2833a6f63c

<!-- gh-comment-id:1798153020 --> @xyproto commented on GitHub (Nov 7, 2023): I haven't tested this yet, but there is a new llama.cpp commit from 2 days ago that might fix this issue: https://github.com/ggerganov/llama.cpp/commit/2833a6f63c1b87c7f4ac574bcf7a15a2f3bf3ede
Author
Owner

@orkutmuratyilmaz commented on GitHub (Nov 9, 2023):

@xyproto thanks for maintaining this package:)

<!-- gh-comment-id:1803283585 --> @orkutmuratyilmaz commented on GitHub (Nov 9, 2023): @xyproto thanks for maintaining this package:)
Author
Owner

@xyproto commented on GitHub (Nov 13, 2023):

#1028 did not work out.

Could the errors be related to the cmake defines -DLLAMA_FMA=off or -DLLAMA_F16C=off somehow?

<!-- gh-comment-id:1808940600 --> @xyproto commented on GitHub (Nov 13, 2023): #1028 did not work out. Could the errors be related to the cmake defines `-DLLAMA_FMA=off` or `-DLLAMA_F16C=off` somehow?
Author
Owner

@xyproto commented on GitHub (Nov 19, 2023):

With the latest version of the Arch Linux packages + the latest version of Ollama, this now works again. 👍

<!-- gh-comment-id:1817858750 --> @xyproto commented on GitHub (Nov 19, 2023): With the latest version of the Arch Linux packages + the latest version of Ollama, this now works again. :+1:
Author
Owner

@orkutmuratyilmaz commented on GitHub (Nov 19, 2023):

@xyproto thanks for this update. I'd like to use the latest package on my local environment. Can you also update the stable branch too?

Many thanks for Sunday contribution:)

<!-- gh-comment-id:1817912721 --> @orkutmuratyilmaz commented on GitHub (Nov 19, 2023): @xyproto thanks for this update. I'd like to use the latest package on my local environment. Can you also update the [stable branch](https://packages.manjaro.org/?query=ollama) too? Many thanks for Sunday contribution:)
Author
Owner

@xyproto commented on GitHub (Nov 19, 2023):

Manjaro is a different Linux distribution, so I don't have access to those packages. They will probably update the stable version soon, though.

<!-- gh-comment-id:1817997306 --> @xyproto commented on GitHub (Nov 19, 2023): Manjaro is a different Linux distribution, so I don't have access to those packages. They will probably update the stable version soon, though.
Author
Owner

@orkutmuratyilmaz commented on GitHub (Nov 25, 2023):

@xyproto thanks for the explanation:)

<!-- gh-comment-id:1826397454 --> @orkutmuratyilmaz commented on GitHub (Nov 25, 2023): @xyproto thanks for the explanation:)
Author
Owner

@BaconIsAVeg commented on GitHub (Dec 25, 2023):

Hey sorry @xyproto to ping you here, but Arch registrations are down at the moment and there's no issue tracker on your fork. It looks like when you built the ollama-cuda package, the version number was left at 0.0.0. I'm assuming there should be something in the build process that updates that.

This causes the ollama-webui client to refuse connection, as it requires at least 1.1.16. Running the ollama bin manually (downloaded from ollama.ai) works.

<!-- gh-comment-id:1869013563 --> @BaconIsAVeg commented on GitHub (Dec 25, 2023): Hey sorry @xyproto to ping you here, but Arch registrations are down at the moment and there's no issue tracker on your fork. It looks like when you built the ollama-cuda package, the version number was left at 0.0.0. I'm assuming there should be something in the build process that updates that. This causes the ollama-webui client to refuse connection, as it requires at least 1.1.16. Running the ollama bin manually (downloaded from ollama.ai) works.
Author
Owner

@xyproto commented on GitHub (Dec 25, 2023):

@BaconIsAVeg Ah, yes. The latest tests added to ollama specifically checked if the version number was 0.0.0 before passing. Following the Arch philosophy of patching as little as possible, I removed the line in the PKGBUILD that patched in the correct version number, while figuring out if this really is on purpose or just a fluke.

<!-- gh-comment-id:1869124762 --> @xyproto commented on GitHub (Dec 25, 2023): @BaconIsAVeg Ah, yes. The latest tests added to ollama specifically checked if the version number was 0.0.0 before passing. Following the Arch philosophy of patching as little as possible, I removed the line in the PKGBUILD that patched in the correct version number, while figuring out if this really is on purpose or just a fluke.
Author
Owner

@xyproto commented on GitHub (Dec 25, 2023):

See also https://github.com/jmorganca/ollama/issues/1712

<!-- gh-comment-id:1869127151 --> @xyproto commented on GitHub (Dec 25, 2023): See also https://github.com/jmorganca/ollama/issues/1712
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#47011