|
1 |
| -name: Build Release |
2 |
| - |
3 |
| -on: workflow_dispatch |
| 1 | +name: Build Conda Env (CUDA) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + env_name: |
| 7 | + description: "conda environmant name" |
| 8 | + type: string |
| 9 | + required: false |
| 10 | + default: 'win_llamacppgpu' |
| 11 | + target_folder: |
| 12 | + description: 'Envs path (must be on D drive)' |
| 13 | + type: string |
| 14 | + required: false |
| 15 | + default: 'D:\conda_envs_jianlins' |
4 | 16 |
|
5 | 17 | permissions:
|
6 | 18 | contents: write
|
7 | 19 |
|
8 | 20 | jobs:
|
9 |
| - build_wheels: |
10 |
| - name: Build wheels on ${{ matrix.os }} |
11 |
| - runs-on: ${{ matrix.os }} |
12 |
| - strategy: |
13 |
| - matrix: |
14 |
| - os: [ubuntu-20.04, windows-2019, macos-12] |
| 21 | + define_matrix: |
| 22 | + name: Define Build Matrix |
| 23 | + runs-on: ubuntu-latest |
| 24 | + outputs: |
| 25 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 26 | + defaults: |
| 27 | + run: |
| 28 | + shell: pwsh |
15 | 29 |
|
16 | 30 | steps:
|
17 |
| - - uses: actions/checkout@v4 |
18 |
| - with: |
19 |
| - submodules: "recursive" |
20 |
| - |
21 |
| - # Used to host cibuildwheel |
22 |
| - - uses: actions/setup-python@v5 |
23 |
| - with: |
24 |
| - python-version: "3.9" |
25 |
| - |
26 |
| - - name: Install dependencies (Linux/MacOS) |
27 |
| - if: runner.os != 'Windows' |
| 31 | + - name: Define Job Output |
| 32 | + id: set-matrix |
28 | 33 | run: |
|
29 |
| - python -m pip install --upgrade pip |
30 |
| - python -m pip install uv |
31 |
| - RUST_LOG=trace python -m uv pip install -e .[all] --verbose |
32 |
| - shell: bash |
| 34 | + $matrix = @{ |
| 35 | + 'os' = @('windows-2019') |
| 36 | + 'pyver' = @("3.10", "3.12") |
| 37 | + 'cuda' = @("11.8.0", "12.5.0") |
| 38 | + 'releasetag' = @("cuda") |
| 39 | + } |
33 | 40 |
|
34 |
| - - name: Install dependencies (Windows) |
35 |
| - if: runner.os == 'Windows' |
36 |
| - env: |
37 |
| - RUST_LOG: trace |
38 |
| - run: | |
39 |
| - python -m pip install --upgrade pip |
40 |
| - python -m pip install uv |
41 |
| - python -m uv pip install -e .[all] --verbose |
42 |
| - shell: cmd |
| 41 | + $matrixOut = ConvertTo-Json $matrix -Compress |
| 42 | + Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT |
43 | 43 |
|
44 |
| - - name: Build wheels |
45 |
| - uses: pypa/cibuildwheel@v2.21.1 |
46 |
| - env: |
47 |
| - # disable repair |
48 |
| - CIBW_REPAIR_WHEEL_COMMAND: "" |
49 |
| - with: |
50 |
| - package-dir: . |
51 |
| - output-dir: wheelhouse |
| 44 | + build_wheels: |
| 45 | + name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }} |
| 46 | + needs: define_matrix |
| 47 | + runs-on: ${{ matrix.os }} |
| 48 | + strategy: |
| 49 | + matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} |
| 50 | + defaults: |
| 51 | + run: |
| 52 | + shell: pwsh |
| 53 | + env: |
| 54 | + CUDAVER: ${{ matrix.cuda }} |
| 55 | + AVXVER: ${{ matrix.releasetag }} |
52 | 56 |
|
53 |
| - - uses: actions/upload-artifact@v4 |
| 57 | + steps: |
| 58 | + - name: Add MSBuild to PATH |
| 59 | + if: runner.os == 'Windows' |
| 60 | + uses: microsoft/setup-msbuild@v2 |
54 | 61 | with:
|
55 |
| - name: wheels-${{ matrix.os }} |
56 |
| - path: ./wheelhouse/*.whl |
| 62 | + vs-version: '[16.11,16.12)' |
57 | 63 |
|
58 |
| - build_wheels_arm64: |
59 |
| - name: Build arm64 wheels |
60 |
| - runs-on: ubuntu-latest |
61 |
| - steps: |
62 | 64 | - uses: actions/checkout@v4
|
63 | 65 | with:
|
64 | 66 | submodules: "recursive"
|
65 | 67 |
|
66 |
| - - name: Set up QEMU |
67 |
| - uses: docker/setup-qemu-action@v3 |
68 |
| - with: |
69 |
| - platforms: linux/arm64 |
70 |
| - |
71 |
| - - name: Build wheels |
72 |
| - uses: pypa/cibuildwheel@v2.21.1 |
73 |
| - env: |
74 |
| - CIBW_SKIP: "*musllinux* pp*" |
75 |
| - CIBW_REPAIR_WHEEL_COMMAND: "" |
76 |
| - CIBW_ARCHS: "aarch64" |
77 |
| - CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*" |
78 |
| - with: |
79 |
| - output-dir: wheelhouse |
80 |
| - |
81 |
| - - name: Upload wheels as artifacts |
82 |
| - uses: actions/upload-artifact@v4 |
| 68 | + - uses: actions/setup-python@v5 |
83 | 69 | with:
|
84 |
| - name: wheels_arm64 |
85 |
| - path: ./wheelhouse/*.whl |
| 70 | + python-version: ${{ matrix.pyver }} |
| 71 | + cache: 'pip' |
86 | 72 |
|
87 |
| - build_sdist: |
88 |
| - name: Build source distribution |
89 |
| - runs-on: ubuntu-latest |
90 |
| - |
91 |
| - steps: |
92 |
| - - uses: actions/checkout@v4 |
| 73 | + - name: Install miniforge |
| 74 | + uses: conda-incubator/setup-miniconda@v3 |
93 | 75 | with:
|
94 |
| - submodules: "recursive" |
95 |
| - |
96 |
| - - uses: actions/setup-python@v5 |
| 76 | + miniforge-version: latest |
| 77 | + python-version: ${{ matrix.pyver }} |
| 78 | + activate-environment: ${{ github.event.inputs.target_folder }}/${{ github.event.inputs.build_folder }} |
| 79 | + environment-file: ${{ github.event.inputs.build_folder }}/environment.yml |
| 80 | + auto-activate-base: false |
| 81 | + add-pip-as-python-dependency: true |
| 82 | + |
| 83 | + # - name: Setup Mamba |
| 84 | + # uses: conda-incubator/setup-miniconda@v3.0.4 |
| 85 | + # with: |
| 86 | + # activate-environment: ${{ github.event.inputs.target_folder }}\${{ github.event.inputs.env_name }} |
| 87 | + # python-version: ${{ matrix.pyver }} |
| 88 | + # miniforge-variant: Mambaforge |
| 89 | + # miniforge-version: latest |
| 90 | + # use-mamba: true |
| 91 | + # add-pip-as-python-dependency: true |
| 92 | + # auto-activate-base: false |
| 93 | + |
| 94 | + - name: VS Integration Cache |
| 95 | + id: vs-integration-cache |
| 96 | + if: runner.os == 'Windows' |
| 97 | + uses: actions/cache@v4 |
97 | 98 | with:
|
98 |
| - python-version: "3.9" |
| 99 | + path: ./MSBuildExtensions |
| 100 | + key: cuda-${{ matrix.cuda }}-vs-integration |
99 | 101 |
|
100 |
| - - name: Install dependencies (Linux/MacOS) |
101 |
| - if: runner.os != 'Windows' |
| 102 | + - name: Get Visual Studio Integration |
| 103 | + if: runner.os == 'Windows' && steps.vs-integration-cache.outputs.cache-hit != 'true' |
102 | 104 | run: |
|
103 |
| - python -m pip install --upgrade pip |
104 |
| - python -m pip install uv |
105 |
| - RUST_LOG=trace python -m uv pip install -e .[all] --verbose |
106 |
| - python -m uv pip install build |
107 |
| - shell: bash |
108 |
| - |
109 |
| - - name: Install dependencies (Windows) |
| 105 | + if ($env:CUDAVER -eq '12.1.1') {$x = '12.1.0'} else {$x = $env:CUDAVER} |
| 106 | + $links = (Invoke-RestMethod 'https://raw.githubusercontent.com/Jimver/cuda-toolkit/master/src/links/windows-links.ts').Trim().split().where({$_ -ne ''}) |
| 107 | + for ($i=$q=0;$i -lt $links.count -and $q -lt 2;$i++) {if ($links[$i] -eq "'$x',") {$q++}} |
| 108 | + Invoke-RestMethod $links[$i].Trim("'") -OutFile 'cudainstaller.zip' |
| 109 | + & 'C:\Program Files\7-Zip\7z.exe' e cudainstaller.zip -oMSBuildExtensions -r *\MSBuildExtensions\* > $null |
| 110 | + Remove-Item 'cudainstaller.zip' |
| 111 | +
|
| 112 | + - name: Install Visual Studio Integration |
110 | 113 | if: runner.os == 'Windows'
|
111 |
| - env: |
112 |
| - RUST_LOG: trace |
113 | 114 | run: |
|
114 |
| - python -m pip install --upgrade pip |
115 |
| - python -m pip install uv |
116 |
| - python -m uv pip install -e .[all] --verbose |
117 |
| - python -m uv pip install build |
118 |
| - shell: cmd |
| 115 | + $y = (gi '.\MSBuildExtensions').fullname + '\*' |
| 116 | + (gi 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_}) |
| 117 | + $cupath = 'CUDA_PATH_V' + $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','_') |
| 118 | + echo "$cupath=$env:CONDA_PREFIX" >> $env:GITHUB_ENV |
119 | 119 |
|
120 |
| - - name: Build source distribution |
| 120 | + - name: Install Dependencies |
| 121 | + env: |
| 122 | + MAMBA_DOWNLOAD_FAILFAST: "0" |
| 123 | + MAMBA_NO_LOW_SPEED_LIMIT: "1" |
121 | 124 | run: |
|
122 |
| - python -m build --sdist |
123 |
| -
|
124 |
| - - uses: actions/upload-artifact@v4 |
125 |
| - with: |
126 |
| - name: sdist |
127 |
| - path: ./dist/*.tar.gz |
128 |
| - |
129 |
| - release: |
130 |
| - name: Release |
131 |
| - needs: [build_wheels, build_wheels_arm64, build_sdist] |
132 |
| - runs-on: ubuntu-latest |
| 125 | + $cudaVersion = $env:CUDAVER |
| 126 | + conda install -y 'cuda' -c nvidia/label/cuda-$cudaVersion |
| 127 | + python -m pip install build wheel |
133 | 128 |
|
134 |
| - steps: |
135 |
| - - uses: actions/download-artifact@v4 |
136 |
| - with: |
137 |
| - merge-multiple: true |
138 |
| - path: dist |
| 129 | + - name: Build Wheel |
| 130 | + run: | |
| 131 | + $cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','') |
| 132 | + $env:CUDA_PATH = $env:CONDA_PREFIX |
| 133 | + $env:CUDA_HOME = $env:CONDA_PREFIX |
| 134 | + $env:CUDA_TOOLKIT_ROOT_DIR = $env:CONDA_PREFIX |
| 135 | + if ($IsLinux) { |
| 136 | + $env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH |
| 137 | + } |
| 138 | + $env:VERBOSE = '1' |
| 139 | + $env:CMAKE_ARGS = '-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=all' |
| 140 | + $env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_MMQ=ON $env:CMAKE_ARGS" |
| 141 | + # if ($env:AVXVER -eq 'AVX') { |
| 142 | + $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off' |
| 143 | + # } |
| 144 | + # if ($env:AVXVER -eq 'AVX512') { |
| 145 | + # $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX512=on' |
| 146 | + # } |
| 147 | + # if ($env:AVXVER -eq 'basic') { |
| 148 | + # $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX=off -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off' |
| 149 | + # } |
| 150 | + python -m build --wheel |
| 151 | + # write the build tag to the output |
| 152 | + Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV |
139 | 153 |
|
140 | 154 | - uses: softprops/action-gh-release@v2
|
141 | 155 | with:
|
142 | 156 | files: dist/*
|
| 157 | + # Set tag_name to <tag>-cu<cuda_version> |
| 158 | + tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} |
143 | 159 | env:
|
144 | 160 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 161 | + |
0 commit comments