From 890704277157a13e2b284436a0cc14886f8f8264 Mon Sep 17 00:00:00 2001 From: m0nsky Date: Tue, 18 Jun 2024 15:21:57 +0200 Subject: [PATCH 1/7] Add the github build actions for Vulkan --- .github/workflows/compile.yml | 80 ++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index f7a10e98c..1921c5661 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -100,6 +100,79 @@ jobs: path: .\build\bin\Release\llava_shared.dll name: llava-bin-win-${{ matrix.build }}-x64.dll + compile-vulkan: + name: Compile (vulkan) - ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ + ubuntu-22.04, + windows-latest + ] + env: + VULKAN_VERSION: 1.3.261.1 + runs-on: ${{ matrix.os }} + steps: + - name: Clone + id: checkout + uses: actions/checkout@v4 + with: + repository: ggerganov/llama.cpp + + - name: Download dependencies - Linux + if: ${{ matrix.os == 'ubuntu-22.04' }} + run: | + wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc + sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list http://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list + sudo apt update + sudo apt install vulkan-sdk + - name: Download dependencies - Windows + id: get_vulkan + if: ${{ matrix.os == 'windows-latest' }} + run: | + curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/VulkanSDK-${env:VULKAN_VERSION}-Installer.exe" + & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install + Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}" + Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin" + - name: Build + id: cmake_build + if: ${{ matrix.os == 'windows-latest' }} + run: | + mkdir build + cd build + cmake .. ${{ env.COMMON_DEFINE }} -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_VULKAN=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/vulkan" + cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS} + #copy $env:RUNNER_TEMP/clblast/lib/clblast.dll .\bin\Release\clblast.dll + # # We should probably generate a sha256 sum in a file, and use that. + # echo "78a8c98bcb2efe1a63318d901ab204d9ba96c3b29707b4ce0c4240bdcdc698d6 ./bin/Release/clblast.dll" >> tmp + # sha256sum -c tmp || exit 255 + # rm tmp + ls -R + - name: Build + if: ${{ matrix.os == 'ubuntu-22.04' }} + run: | + mkdir build + cd build + cmake .. ${{ env.COMMON_DEFINE }} -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_VULKAN=ON -DBUILD_SHARED_LIBS=ON + cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS} + # if we ever want to pull libvulkan.so back into the packages, just uncomment this line, and the one below for the upload + # cp $(ldconfig -p | grep libvulkan.so | tail -n 1 | cut -d ' ' -f 4) ./ + ls -R + - name: Upload artifacts (Windows) + if: ${{ matrix.os == 'windows-latest' }} + uses: actions/upload-artifact@v4 + with: + path: | + .\build\bin\Release\llama.dll + name: llama-bin-win-vulkan-x64.dll + - name: Upload artifacts (linux) + if: ${{ matrix.os == 'ubuntu-22.04' }} + uses: actions/upload-artifact@v4 + with: + path: | + ./build/libllama.so + name: llama-bin-linux-vulkan-x64.so + compile-cublas: name: Compile (cublas) strategy: @@ -223,7 +296,8 @@ jobs: "compile-linux", "compile-macos", "compile-windows", - "compile-cublas" + "compile-cublas", + "compile-vulkan" ] steps: - uses: actions/download-artifact@v4 @@ -234,7 +308,7 @@ jobs: - name: Rearrange Files run: | # Make all directories at once - mkdir --parents deps/{avx,avx2,avx512,osx-arm64,osx-x64,osx-x64-rosetta2,cu11.7.1,cu12.1.0} + mkdir --parents deps/{avx,avx2,avx512,osx-arm64,osx-x64,osx-x64-rosetta2,cu11.7.1,cu12.1.0,vulkan} cp artifacts/llama-bin-linux-noavx-x64.so/libllama.so deps/libllama.so cp artifacts/llama-bin-linux-avx-x64.so/libllama.so deps/avx/libllama.so @@ -279,6 +353,8 @@ jobs: cp artifacts/llama-bin-linux-cublas-cu12.1.0-x64.so/libllama.so deps/cu12.1.0/libllama.so cp artifacts/llava-bin-linux-cublas-cu12.1.0-x64.so/libllava_shared.so deps/cu12.1.0/libllava_shared.so + cp artifacts/llama-bin-win-vulkan-x64.dll/llama.dll deps/vulkan/ + cp artifacts/llama-bin-linux-vulkan-x64.so/libllama.so deps/vulkan/ - name: Upload artifacts uses: actions/upload-artifact@v4 From c0034d3759cf3ae908270875c407bc5c14f5e065 Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Tue, 18 Jun 2024 22:55:01 +0100 Subject: [PATCH 2/7] Removed deprecated `LLAMA_CUBLAS` define, replaced with `LLAMA_CUDA` --- .github/workflows/compile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 1921c5661..02f75f0ef 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -211,7 +211,7 @@ jobs: run: | mkdir build cd build - cmake .. ${{ env.COMMON_DEFINE }} -DLLAMA_CUBLAS=ON + cmake .. ${{ env.COMMON_DEFINE }} -DLLAMA_CUDA=ON cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS} ls -R From 0c28fce6002217eb1fd6c59b626113c896f3b41d Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Tue, 18 Jun 2024 23:26:16 +0100 Subject: [PATCH 3/7] Updated jimver cuda toolkit --- .github/workflows/compile.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 02f75f0ef..defe909a0 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -179,7 +179,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, windows-latest] - cuda: ['12.1.0', '11.7.1'] + cuda: ['12.4.1', '11.7.1'] runs-on: ${{ matrix.os }} steps: - name: Clone @@ -190,7 +190,7 @@ jobs: fetch-depth: 0 ref: '${{ github.event.inputs.llama_cpp_commit }}' - - uses: Jimver/cuda-toolkit@v0.2.14 + - uses: Jimver/cuda-toolkit@v0.2.15 if: runner.os == 'Windows' id: cuda-toolkit-windows with: @@ -198,7 +198,7 @@ jobs: method: 'network' sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]' - - uses: Jimver/cuda-toolkit@v0.2.14 + - uses: Jimver/cuda-toolkit@v0.2.15 if: runner.os == 'Linux' id: cuda-toolkit-linux with: From 9668c92e0eeaf81dc13d5ac02b8d627527f39172 Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Wed, 19 Jun 2024 00:10:28 +0100 Subject: [PATCH 4/7] Updated CUDA11 version to try to fix build --- .github/workflows/compile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index defe909a0..d2526d254 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -179,7 +179,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, windows-latest] - cuda: ['12.4.1', '11.7.1'] + cuda: ['12.4.1', '11.8.0'] runs-on: ${{ matrix.os }} steps: - name: Clone From 4afb05553a721fb480e894a1f3d85b109600c09d Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Wed, 19 Jun 2024 01:23:43 +0100 Subject: [PATCH 5/7] copied CUDA config from upstream build action script --- .github/workflows/compile.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index d2526d254..477ca034f 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -178,8 +178,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, windows-latest] - cuda: ['12.4.1', '11.8.0'] + os: [ubuntu-20.04, windows-2019] + cuda: ['12.2.0', '11.7.1'] runs-on: ${{ matrix.os }} steps: - name: Clone From 92b1417462b0729261e60fbdb6482c9feb66e4b5 Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Wed, 19 Jun 2024 02:26:49 +0100 Subject: [PATCH 6/7] Fixed file upload for windows cuda --- .github/workflows/compile.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 477ca034f..fa161c6b0 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -216,13 +216,13 @@ jobs: ls -R - name: Upload artifacts (Windows) - if: ${{ matrix.os == 'windows-latest' }} + if: ${{ matrix.os == 'windows-2019' }} uses: actions/upload-artifact@v4 with: path: .\build\bin\Release\llama.dll name: llama-bin-win-cublas-cu${{ matrix.cuda }}-x64.dll - name: Upload llava artifacts (Windows) - if: ${{ matrix.os == 'windows-latest' }} + if: ${{ matrix.os == 'windows-2019' }} uses: actions/upload-artifact@v4 with: path: .\build\bin\Release\llava_shared.dll From 75f3a1af8d7ffc3aadfb0196243e9a91b6091382 Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Wed, 19 Jun 2024 03:07:05 +0100 Subject: [PATCH 7/7] Updated paths for cuda12 --- .github/workflows/compile.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index fa161c6b0..a1057646b 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -308,7 +308,7 @@ jobs: - name: Rearrange Files run: | # Make all directories at once - mkdir --parents deps/{avx,avx2,avx512,osx-arm64,osx-x64,osx-x64-rosetta2,cu11.7.1,cu12.1.0,vulkan} + mkdir --parents deps/{avx,avx2,avx512,osx-arm64,osx-x64,osx-x64-rosetta2,cu11.7.1,cu12.2.0,vulkan} cp artifacts/llama-bin-linux-noavx-x64.so/libllama.so deps/libllama.so cp artifacts/llama-bin-linux-avx-x64.so/libllama.so deps/avx/libllama.so @@ -347,11 +347,11 @@ jobs: cp artifacts/llama-bin-linux-cublas-cu11.7.1-x64.so/libllama.so deps/cu11.7.1/libllama.so cp artifacts/llava-bin-linux-cublas-cu11.7.1-x64.so/libllava_shared.so deps/cu11.7.1/libllava_shared.so - cp artifacts/llama-bin-win-cublas-cu12.1.0-x64.dll/llama.dll deps/cu12.1.0/llama.dll - cp artifacts/llava-bin-win-cublas-cu12.1.0-x64.dll/llava_shared.dll deps/cu12.1.0/llava_shared.dll + cp artifacts/llama-bin-win-cublas-cu12.2.0-x64.dll/llama.dll deps/cu12.2.0/llama.dll + cp artifacts/llava-bin-win-cublas-cu12.2.0-x64.dll/llava_shared.dll deps/cu12.2.0/llava_shared.dll - cp artifacts/llama-bin-linux-cublas-cu12.1.0-x64.so/libllama.so deps/cu12.1.0/libllama.so - cp artifacts/llava-bin-linux-cublas-cu12.1.0-x64.so/libllava_shared.so deps/cu12.1.0/libllava_shared.so + cp artifacts/llama-bin-linux-cublas-cu12.2.0-x64.so/libllama.so deps/cu12.2.0/libllama.so + cp artifacts/llava-bin-linux-cublas-cu12.2.0-x64.so/libllava_shared.so deps/cu12.2.0/libllava_shared.so cp artifacts/llama-bin-win-vulkan-x64.dll/llama.dll deps/vulkan/ cp artifacts/llama-bin-linux-vulkan-x64.so/libllama.so deps/vulkan/