|
4 | 4 | workflow_dispatch: |
5 | 5 | inputs: |
6 | 6 | version: |
7 | | - description: 'Version tag of llama-cpp-python to build: v0.2.2' |
8 | | - default: 'v0.2.2' |
| 7 | + description: 'Version tag of llama-cpp-python to build: v0.2.6' |
| 8 | + default: 'v0.2.6' |
9 | 9 | required: false |
10 | 10 | type: string |
11 | 11 | workflow_call: |
12 | 12 | inputs: |
13 | 13 | version: |
14 | | - description: 'Version tag of llama-cpp-python to build: v0.2.2' |
15 | | - default: 'v0.2.2' |
| 14 | + description: 'Version tag of llama-cpp-python to build: v0.2.6' |
| 15 | + default: 'v0.2.6' |
16 | 16 | required: false |
17 | 17 | type: string |
18 | 18 |
|
19 | 19 | jobs: |
20 | | - build_wheels: |
21 | | - name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }} |
| 20 | + build_wheels_main: |
| 21 | + name: ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.avx }} |
22 | 22 | runs-on: ${{ matrix.os }} |
23 | 23 | strategy: |
24 | 24 | matrix: |
25 | | - os: [ubuntu-20.04, windows-latest] |
| 25 | + os: [macos-13, macos-12, macos-11] |
| 26 | + arch: ["x86_64","arm64"] |
26 | 27 | pyver: ["3.10"] |
27 | | - cuda: ["11.7.1"] |
28 | | - releasetag: ["wheels"] |
29 | | - defaults: |
30 | | - run: |
31 | | - shell: pwsh |
32 | 28 | env: |
33 | | - CUDAVER: ${{ matrix.cuda }} |
34 | | - AVXVER: ${{ matrix.releasetag }} |
| 29 | + CMAKE_OSX_ARCHITECTURES: ${{ matrix.arch }} |
35 | 30 | PCKGVER: ${{ inputs.version }} |
36 | 31 |
|
37 | 32 | steps: |
38 | | - - uses: actions/checkout@v4 |
| 33 | + - uses: actions/checkout@v3 |
39 | 34 | with: |
40 | 35 | repository: 'abetlen/llama-cpp-python' |
41 | 36 | ref: ${{ inputs.version }} |
42 | 37 | submodules: 'recursive' |
43 | 38 |
|
44 | | - - uses: actions/setup-python@v4 |
| 39 | + - uses: actions/setup-python@v3 |
45 | 40 | with: |
46 | 41 | python-version: ${{ matrix.pyver }} |
47 | | - |
48 | | - - name: Setup Mamba |
49 | | - uses: conda-incubator/[email protected] |
50 | | - with: |
51 | | - activate-environment: "build" |
52 | | - python-version: ${{ matrix.pyver }} |
53 | | - miniforge-variant: Mambaforge |
54 | | - miniforge-version: latest |
55 | | - use-mamba: true |
56 | | - add-pip-as-python-dependency: true |
57 | | - auto-activate-base: false |
58 | | - |
59 | | - - name: VS Integration Cache |
60 | | - id: vs-integration-cache |
61 | | - if: runner.os == 'Windows' |
62 | | - |
63 | | - with: |
64 | | - path: ./MSBuildExtensions |
65 | | - key: cuda-${{ matrix.cuda }}-vs-integration |
66 | | - |
67 | | - - name: Get Visual Studio Integration |
68 | | - if: runner.os == 'Windows' && steps.vs-integration-cache.outputs.cache-hit != 'true' |
69 | | - run: | |
70 | | - if ($env:CUDAVER -eq '12.1.1') {$x = '12.1.0'} else {$x = $env:CUDAVER} |
71 | | - $links = (Invoke-RestMethod 'https://github.com/Jimver/cuda-toolkit/raw/257a101bc5c656053b5dc220126744980ef7f5b8/src/links/windows-links.ts').Trim().split().where({$_ -ne ''}) |
72 | | - for ($i=$q=0;$i -lt $links.count -and $q -lt 2;$i++) {if ($links[$i] -eq "'$x',") {$q++}} |
73 | | - Invoke-RestMethod $links[$i].Trim("'") -OutFile 'cudainstaller.zip' |
74 | | - & 'C:\Program Files\7-Zip\7z.exe' e cudainstaller.zip -oMSBuildExtensions -r *\MSBuildExtensions\* > $null |
75 | | - Remove-Item 'cudainstaller.zip' |
76 | | - |
77 | | - - name: Install Visual Studio Integration |
78 | | - if: runner.os == 'Windows' |
79 | | - run: | |
80 | | - $y = (gi '.\MSBuildExtensions').fullname + '\*' |
81 | | - (gi 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_}) |
82 | | - $cupath = 'CUDA_PATH_V' + $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','_') |
83 | | - echo "$cupath=$env:CONDA_PREFIX" >> $env:GITHUB_ENV |
84 | 42 |
|
85 | 43 | - name: Install Dependencies |
86 | 44 | run: | |
87 | | - $cudaVersion = $env:CUDAVER |
88 | | - $cudaChannels = '' |
89 | | - $cudaNum = [int]$cudaVersion.substring($cudaVersion.LastIndexOf('.')+1) |
90 | | - while ($cudaNum -ge 0) { $cudaChannels += '-c nvidia/label/cuda-' + $cudaVersion.Remove($cudaVersion.LastIndexOf('.')+1) + $cudaNum + ' '; $cudaNum-- } |
91 | | - mamba install -y 'cuda' $cudaChannels.TrimEnd().Split() |
92 | | - if (!(mamba list cuda)[-1].contains('cuda')) {sleep -s 10; mamba install -y 'cuda' $cudaChannels.TrimEnd().Split()} |
93 | | - if (!(mamba list cuda)[-1].contains('cuda')) {throw 'CUDA Toolkit failed to install!'} |
94 | | - python -m pip install build wheel |
| 45 | + python -m pip install build wheel cmake |
95 | 46 | |
96 | 47 | - name: Build Wheel |
97 | 48 | run: | |
98 | | - $packageVersion = [version]$env:PCKGVER.TrimStart('v') |
99 | | - $cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','') |
100 | | - $env:CUDA_PATH = $env:CONDA_PREFIX |
101 | | - $env:CUDA_HOME = $env:CONDA_PREFIX |
102 | | - if ($IsLinux) {$env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH} |
103 | | - $env:VERBOSE = '1' |
104 | | - $env:CMAKE_ARGS = '-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=all' |
105 | | - if ($packageVersion -gt [version]'0.1.68' -and $packageVersion -lt [version]'0.1.71') {$env:CMAKE_ARGS = '-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=35-real;37-real;52;61-real;70-real;72-real;75-real;80-real;86-real;89-real;90'} |
106 | | - if ($packageVersion -gt [version]'0.1.68' -and $packageVersion -lt [version]'0.1.71' -and [version]$env:CUDAVER -ge [version]'12.0') {$env:CMAKE_ARGS = '-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=52;61-real;70-real;72-real;75-real;80-real;86-real;89-real;90'} |
107 | | - if ($packageVersion -gt [version]'0.1.68' -and $packageVersion -lt [version]'0.1.71' -and [version]$env:CUDAVER -lt [version]'11.8') {$env:CMAKE_ARGS = '-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=35-real;37-real;52;61-real;70-real;72-real;75-real;80-real;86'} |
108 | | - if ($packageVersion -lt [version]'0.1.66') {$env:CUDAFLAGS = '-arch=all'} |
109 | | - if ($env:AVXVER -eq 'AVX') {$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DLLAMA_AVX2=off -DLLAMA_FMA=off -DLLAMA_F16C=off'} |
110 | | - if ($env:AVXVER -eq 'AVX512') {$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DLLAMA_AVX512=on'} |
111 | | - if ($env:AVXVER -eq 'basic') {$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DLLAMA_AVX=off -DLLAMA_AVX2=off -DLLAMA_FMA=off -DLLAMA_F16C=off'} |
112 | | - $buildtag = "+cu$cudaVersion" |
113 | | - if ($packageVersion -lt [version]'0.2.0') { |
114 | | - $env:FORCE_CMAKE = '1' |
115 | | - python -m build --wheel -C--build-option=egg_info "-C--build-option=--tag-build=$buildtag" |
116 | | - } else { |
117 | | - $initpath = Join-Path '.' 'llama_cpp' '__init__.py' -resolve |
118 | | - $initcontent = Get-Content $initpath -raw |
119 | | - $regexstr = '(?s)(?<=__version__ \= ")\d+(?:\.\d+)*(?=")' |
120 | | - $regexmatch = [Regex]::Matches($initcontent,$regexstr) |
121 | | - if (!($regexmatch[0].Success)) {throw '__init__.py parsing failed'} |
122 | | - $newinit = $regexmatch[0].Result(('$`' + '$&' + $buildtag + '$''')) |
123 | | - New-Item $initpath -itemType File -value $newinit -force |
124 | | - python -m build --wheel |
125 | | - } |
| 49 | + export CMAKE_ARGS="-DLLAMA_METAL=on" |
| 50 | + CMAKE_ARGS="-DLLAMA_METAL=on" VERBOSE=1 python -m build --wheel |
126 | 51 | |
127 | 52 | - uses: actions/upload-artifact@v3 |
128 | 53 | if: steps.upload-release.outcome == 'failure' |
129 | 54 | with: |
130 | | - name: ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }} |
| 55 | + name: ${{ format('wheel-{0}-{1}', matrix.os, matrix.arch) }} |
131 | 56 | path: ./dist/*.whl |
0 commit comments