Build Release (CUDA) #43
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Release (CUDA) | |
| on: workflow_dispatch | |
| permissions: | |
| contents: write | |
| jobs: | |
| define_matrix: | |
| name: Define Build Matrix | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| defaults: | |
| run: | |
| shell: pwsh | |
| steps: | |
| - name: Define Job Output | |
| id: set-matrix | |
| run: | | |
| $matrix = @{ | |
| 'os' = @('ubuntu-latest') | |
| 'pyver' = @("3.13") | |
| 'cuda' = @("12.8.1") #12.9.0 >= is not supported (12.8.1 works) | |
| 'releasetag' = @("basic") | |
| } | |
| $matrixOut = ConvertTo-Json $matrix -Compress | |
| Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT | |
| build_wheels: | |
| name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }} | |
| needs: define_matrix | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} | |
| defaults: | |
| run: | |
| shell: pwsh | |
| env: | |
| CUDAVER: ${{ matrix.cuda }} | |
| AVXVER: ${{ matrix.releasetag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: "recursive" | |
| - name: Install the latest version of uv | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: "latest" | |
| activate-environment: true | |
| - name: Setup Mamba | |
| uses: conda-incubator/[email protected] | |
| with: | |
| activate-environment: "build" | |
| python-version: ${{ matrix.pyver }} | |
| miniforge-version: latest | |
| add-pip-as-python-dependency: true | |
| auto-activate-base: false | |
| - name: Install Dependencies | |
| env: | |
| MAMBA_DOWNLOAD_FAILFAST: "0" | |
| MAMBA_NO_LOW_SPEED_LIMIT: "1" | |
| run: | | |
| $cudaVersion = $env:CUDAVER | |
| mamba install -y 'cuda' -c nvidia/label/cuda-$cudaVersion | |
| - name: Build Wheel | |
| working-directory: vendor/llama-cpp-python | |
| run: | | |
| $cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','') | |
| $env:CUDA_PATH = $env:CONDA_PREFIX | |
| $env:CUDA_HOME = $env:CONDA_PREFIX | |
| $env:CUDA_TOOLKIT_ROOT_DIR = $env:CONDA_PREFIX | |
| if ($IsLinux) { | |
| $env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH | |
| } | |
| $env:VERBOSE = '1' | |
| $env:CMAKE_ARGS = '-DGGML_CUDA=on -DLLAVA_BUILD=off -DCMAKE_CUDA_ARCHITECTURES=70' | |
| $env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_MMQ=OFF $env:CMAKE_ARGS" | |
| $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off' | |
| # Rename the release version with +cu{cuda_ver} build tag | |
| (Get-Content llama_cpp/__init__.py) -replace '__version__ = "([^"]*)"', ('__version__ = "' + '$1' + '+cu' + $cudaVersion + '"') | Set-Content llama_cpp/__init__.py | |
| #Build wheel | |
| uv -v build --python cpython@${{ matrix.pyver }} --wheel | |
| # write the build tag to the output | |
| Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV | |
| - uses: softprops/action-gh-release@v2 | |
| with: | |
| files: vendor/llama-cpp-python/dist/* | |
| tag_name: ${{ github.ref_name }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |