From a4564232a480159d97376579d08c8b36743b60d1 Mon Sep 17 00:00:00 2001 From: mraiser Date: Thu, 25 Jan 2024 09:49:35 -0500 Subject: [PATCH 1/3] Update gen_linux.sh to find libcudart in separate directory --- llm/generate/gen_linux.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/llm/generate/gen_linux.sh b/llm/generate/gen_linux.sh index fee4c85f..b5190cfa 100755 --- a/llm/generate/gen_linux.sh +++ b/llm/generate/gen_linux.sh @@ -128,6 +128,11 @@ if [ -z "${CUDA_LIB_DIR}" ] && [ -d /opt/cuda/targets/x86_64-linux/lib ]; then CUDA_LIB_DIR=/opt/cuda/targets/x86_64-linux/lib fi +# Allow override in case libcudart is in the wrong place +if [ -z "${CUDART_LIB_DIR}" ]; then + CUDART_LIB_DIR="${CUDA_LIB_DIR}" +fi + if [ -d "${CUDA_LIB_DIR}" ]; then echo "CUDA libraries detected - building dynamic CUDA library" init_vars @@ -151,6 +156,8 @@ if [ -d "${CUDA_LIB_DIR}" ]; then cp "${CUDA_LIB_DIR}/${DEP}" "${BUILD_DIR}/lib/" elif [ -e "${CUDA_LIB_DIR}/${lib}.${CUDA_MAJOR}" ]; then cp "${CUDA_LIB_DIR}/${lib}.${CUDA_MAJOR}" "${BUILD_DIR}/lib/" + elif [ -e "${CUDART_LIB_DIR}/${lib}" ]; then + cp -d ${CUDART_LIB_DIR}/${lib}* "${BUILD_DIR}/lib/" else cp -d "${CUDA_LIB_DIR}/${lib}*" "${BUILD_DIR}/lib/" fi From 6eb3cddcb66da807ecde869d0a5c11bc78849697 Mon Sep 17 00:00:00 2001 From: Marc Raiser Date: Thu, 25 Jan 2024 10:17:22 -0500 Subject: [PATCH 2/3] To build on NixOS: nix-shell --run 'go generate ./... && go build .' --- default.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..5f91a14b --- /dev/null +++ b/default.nix @@ -0,0 +1,24 @@ +with (import {}); +let + LLP = with pkgs; [ + gcc11 + cudatoolkit + linuxPackages.nvidia_x11 + go + cmake + ]; + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath LLP; +in +stdenv.mkDerivation { + name = "ollama-env"; + buildInputs = LLP; + src = null; + # IMPORTANT: Edit ./llm/generate/gen_linux.sh + shellHook = '' + SOURCE_DATE_EPOCH=$(date +%s) + export LD_LIBRARY_PATH=${LD_LIBRARY_PATH} + export CUDA_LIB_DIR=${cudatoolkit.out}/lib + export CUDART_LIB_DIR=${cudatoolkit.lib}/lib + export NVCC_PREPEND_FLAGS='-ccbin ${gcc11}/bin/' + ''; +} From c3f9538636fc2449767de712930f2ab25b615cd0 Mon Sep 17 00:00:00 2001 From: Marc Raiser Date: Mon, 29 Jan 2024 00:05:07 -0500 Subject: [PATCH 3/3] remove default.nix --- default.nix | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 default.nix diff --git a/default.nix b/default.nix deleted file mode 100644 index 5f91a14b..00000000 --- a/default.nix +++ /dev/null @@ -1,24 +0,0 @@ -with (import {}); -let - LLP = with pkgs; [ - gcc11 - cudatoolkit - linuxPackages.nvidia_x11 - go - cmake - ]; - LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath LLP; -in -stdenv.mkDerivation { - name = "ollama-env"; - buildInputs = LLP; - src = null; - # IMPORTANT: Edit ./llm/generate/gen_linux.sh - shellHook = '' - SOURCE_DATE_EPOCH=$(date +%s) - export LD_LIBRARY_PATH=${LD_LIBRARY_PATH} - export CUDA_LIB_DIR=${cudatoolkit.out}/lib - export CUDART_LIB_DIR=${cudatoolkit.lib}/lib - export NVCC_PREPEND_FLAGS='-ccbin ${gcc11}/bin/' - ''; -}