8000 Create personalized-cuda-release.yaml · abetlen/llama-cpp-python@9a91a3d · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a91a3d

Browse files
authored
Create personalized-cuda-release.yaml
1 parent b1d23df commit 9a91a3d

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Build Wheels (CUDA)
2+
3+
on: workflow_dispatch
4+
5+
permissions:
6+
contents: write
7+
8+
jobs:
9+
define_matrix:
10+
name: Define Build Matrix
11+
runs-on: ubuntu-latest
12+
outputs:
13+
matrix: ${{ steps.set-matrix.outputs.matrix }}
14+
defaults:
15+
run:
16+
shell: pwsh
17+
18+
steps:
19+
- name: Define Job Output
20+
id: set-matrix
21+
run: |
22+
$matrix = @{
23+
'os' = @('ubuntu-latest')
24+
'pyver' = @("3.12")
25+
'cuda' = @("12.6.1")
26+
'releasetag' = @("basic")
27+
}
28+
29+
$matrixOut = ConvertTo-Json $matrix -Compress
30+
Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT
31+
32+
build_wheels:
33+
name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }}
34+
needs: define_matrix
35+
runs-on: ${{ matrix.os }}
36+
strategy:
37+
matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }}
38+
defaults:
39+
run:
40+
shell: pwsh
41+
env:
42+
CUDAVER: ${{ matrix.cuda }}
43+
AVXVER: ${{ matrix.releasetag }}
44+
45+
steps:
46+
- name: Add MSBuild to PATH
47+
if: runner.os == 'Windows'
48+
uses: microsoft/setup-msbuild@v2
49+
with:
50+
vs-version: '[16.11,16.12)'
51+
52+
- uses: actions/checkout@v4
53+
with:
54+
submodules: "recursive"
55+
56+
- uses: actions/setup-python@v5
57+
with:
58+
python-version: ${{ matrix.pyver }}
59+
cache: 'pip'
60+
61+
- name: Setup Mamba
62+
uses: conda-incubator/setup-miniconda@v3.1.0
63+
with:
64+
activate-environment: "llamacpp"
65+
python-version: ${{ matrix.pyver }}
66+
miniforge-version: latest
67+
add-pip-as-python-dependency: true
68+
auto-activate-base: false
69+
70+
- name: VS Integration Cache
71+
id: vs-integration-cache
72+
if: runner.os == 'Windows'
73+
uses: actions/cache@v4
74+
with:
75+
path: ./MSBuildExtensions
76+
key: cuda-${{ matrix.cuda }}-vs-integration
77+
78+
- name: Get Visual Studio Integration
79+
if: runner.os == 'Windows' && steps.vs-integration-cache.outputs.cache-hit != 'true'
80+
run: |
81+
if ($env:CUDAVER -eq '12.1.1') {$x = '12.1.0'} else {$x = $env:CUDAVER}
82+
$links = (Invoke-RestMethod 'https://raw.githubusercontent.com/Jimver/cuda-toolkit/master/src/links/windows-links.ts').Trim().split().where({$_ -ne ''})
83+
for ($i=$q=0;$i -lt $links.count -and $q -lt 2;$i++) {if ($links[$i] -eq "'$x',") {$q++}}
84+
Invoke-RestMethod $links[$i].Trim("'") -OutFile 'cudainstaller.zip'
85+
& 'C:\Program Files\7-Zip\7z.exe' e cudainstaller.zip -oMSBuildExtensions -r *\MSBuildExtensions\* > $null
86+
Remove-Item 'cudainstaller.zip'
87+
88+
- name: Install Visual Studio Integration
89+
if: runner.os == 'Windows'
90+
run: |
91+
$y = (gi '.\MSBuildExtensions').fullname + '\*'
92+
(gi 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_})
93+
$cupath = 'CUDA_PATH_V' + $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','_')
94+
echo "$cupath=$env:CONDA_PREFIX" >> $env:GITHUB_ENV
95+
96+
- name: Install Dependencies
97+
env:
98+
MAMBA_DOWNLOAD_FAILFAST: "0"
99+
MAMBA_NO_LOW_SPEED_LIMIT: "1"
100+
run: |
101+
$cudaVersion = $env:CUDAVER
102+
mamba install -y 'cuda' -c nvidia/label/cuda-$cudaVersion
103+
python -m pip install build wheel
104+
105+
- name: Build Wheel
106+
run: |
107+
$cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','')
108+
$env:CUDA_PATH = $env:CONDA_PREFIX
109+
$env:CUDA_HOME = $env:CONDA_PREFIX
110+
$env:CUDA_TOOLKIT_ROOT_DIR = $env:CONDA_PREFIX
111+
if ($IsLinux) {
112+
$env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH
113+
}
114+
$env:VERBOSE = '1'
115+
$env:CMAKE_ARGS = '-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=90'
116+
$env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_MMQ=ON $env:CMAKE_ARGS"
117+
# if ($env:AVXVER -eq 'AVX') {
118+
$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off'
119+
# }
120+
# if ($env:AVXVER -eq 'AVX512') {
121+
# $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX512=on'
122+
# }
123+
# if ($env:AVXVER -eq 'basic') {
124+
# $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX=off -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off'
125+
# }
126+
python -m build --wheel
127+
# write the build tag to the output
128+
Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV
129+
130+
- uses: softprops/action-gh-release@v2
131+
with:
132+
files: dist/*
133+
# Set tag_name to <tag>-cu<cuda_version>
134+
tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }}
135+
env:
136+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)
0