|
| 1 | +name: Build Wheels (CUDA) for Windows |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + |
| 9 | +jobs: |
| 10 | + define_matrix: |
| 11 | + name: Define Build Matrix |
| 12 | + runs-on: windows-2022 |
| 13 | + outputs: |
| 14 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 15 | + defaults: |
| 16 | + run: |
| 17 | + shell: pwsh |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Define Job Output |
| 21 | + id: set-matrix |
| 22 | + run: | |
| 23 | + $matrix = @{ |
| 24 | + 'os' = @('windows-2022') |
| 25 | + 'pyver' = @("3.10", "3.11", "3.12") |
| 26 | + 'cuda' = @("12.1.1","12.2.2","12.4.1","12.6.3") |
| 27 | + 'releasetag' = @("AVX2") |
| 28 | + 'cudaarch' = @("all") |
| 29 | + } |
| 30 | +
|
| 31 | + $matrixOut = ConvertTo-Json $matrix -Compress |
| 32 | + Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT |
| 33 | +
|
| 34 | + build_wheels: |
| 35 | + name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }} |
| 36 | + needs: define_matrix |
| 37 | + runs-on: ${{ matrix.os }} |
| 38 | + strategy: |
| 39 | + matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} |
| 40 | + defaults: |
| 41 | + run: |
| 42 | + shell: pwsh |
| 43 | + env: |
| 44 | + CUDAVER: ${{ matrix.cuda }} |
| 45 | + AVXVER: ${{ matrix.releasetag }} |
| 46 | + CUDAARCHVER: ${{ matrix.cudaarch }} |
| 47 | + # https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html |
| 48 | + # https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#gpu-feature-list |
| 49 | + # e.g. "all" "89" |
| 50 | + |
| 51 | + steps: |
| 52 | + - name: Add MSBuild to PATH |
| 53 | + if: runner.os == 'Windows' |
| 54 | + uses: microsoft/setup-msbuild@main |
| 55 | + with: |
| 56 | + vs-version: '[17.12,17.14)' |
| 57 | + msbuild-architecture: x64 |
| 58 | + |
| 59 | + - uses: actions/checkout@main |
| 60 | + with: |
| 61 | + submodules: "recursive" |
| 62 | + |
| 63 | + |
| 64 | + # from kingbri1/flash-attention build-wheels.yml |
| 65 | + - name: Install CUDA ${{ matrix.cuda }} |
| 66 | + uses: Jimver/cuda-toolkit@master |
| 67 | + id: cuda-toolkit |
| 68 | + with: |
| 69 | + cuda: "${{ matrix.cuda }}" |
| 70 | + |
| 71 | + - name: Install the latest version of uv and set the python version |
| 72 | + uses: astral-sh/setup-uv@main |
| 73 | + with: |
| 74 | + python-version: ${{ matrix.pyver }} |
| 75 | + |
| 76 | + - name: Install Dependencies |
| 77 | + run: | |
| 78 | + git config --system core.longpaths true |
| 79 | + uv pip install --upgrade build setuptools wheel packaging |
| 80 | +
|
| 81 | + - name: Build Wheel |
| 82 | + run: | |
| 83 | + # $cupath = 'CUDA_PATH_V' + $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','_') |
| 84 | + # echo "$cupath=$env:CONDA_PREFIX" >> $env:GITHUB_ENV |
| 85 | + |
| 86 | + $cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','') |
| 87 | + # $env:CUDA_PATH = $env:CONDA_PREFIX |
| 88 | + $env:CUDA_HOME = $env:CUDA_PATH |
| 89 | + $env:CUDA_TOOLKIT_ROOT_DIR = $env:CUDA_PATH |
| 90 | + if ($IsLinux) { |
| 91 | + $env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH |
| 92 | + } |
| 93 | + $env:VERBOSE = '1' |
| 94 | + $env:CMAKE_ARGS = '-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=' + $env:CUDAARCHVER |
| 95 | + $env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_MMQ=ON $env:CMAKE_ARGS" |
| 96 | + if ($env:AVXVER -eq 'AVX') { |
| 97 | + $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off' |
| 98 | + } |
| 99 | + if ($env:AVXVER -eq 'AVX2') { |
| 100 | + $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX2=on -DGGML_FMA=off -DGGML_F16C=off' |
| 101 | + } |
| 102 | + # if ($env:AVXVER -eq 'AVX512') { |
| 103 | + # $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX512=on' |
| 104 | + # } |
| 105 | + # if ($env:AVXVER -eq 'basic') { |
| 106 | + # $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX=off -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off' |
| 107 | + # } |
| 108 | + python -m build --wheel |
| 109 | + # write the build tag to the output |
| 110 | + Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV |
| 111 | + |
| 112 | + $wheel = (gi '.\dist\*.whl')[0] |
| 113 | + $tagVer = $wheel.name.split('-')[1] |
| 114 | + Write-Output "TAG_VERSION=$tagVer" >> $env:GITHUB_ENV |
| 115 | +
|
| 116 | + - uses: softprops/action-gh-release@v2 |
| 117 | + with: |
| 118 | + files: dist/* |
| 119 | + # Set tag_name to <tag>-cu<cuda_version> |
| 120 | + tag_name: v${{ env.TAG_VERSION }}-cu${{ env.CUDA_VERSION }}-win |
| 121 | + env: |
| 122 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments