9
9
name : Build
10
10
runs-on : ubuntu-latest
11
11
steps :
12
- - uses : actions/checkout@v3
13
- - uses : actions/setup-node@v3
12
+ - uses : actions/checkout@v4
13
+ - uses : actions/setup-node@v4
14
14
with :
15
15
node-version : " 20"
16
16
- name : Install modules
@@ -20,27 +20,21 @@ jobs:
20
20
- name : Download latest llama.cpp release
21
21
env :
22
22
CI : true
23
- run : node ./dist/cli/cli.js download --release latest --skipBuild --noBundle --updateBinariesReleaseMetadataAndSaveGitBundle
23
+ run : node ./dist/cli/cli.js download --release latest --skipBuild --noBundle --noUsageExample -- updateBinariesReleaseMetadataAndSaveGitBundle
24
24
- name : Upload build artifact
25
- uses : actions/upload-artifact@v3
25
+ uses : actions/upload-artifact@v4
26
26
with :
27
27
name : " build"
28
28
path : " dist"
29
- - name : Upload binariesGithubRelease.json artifact
30
- uses : actions/upload-artifact@v3
31
- with :
32
- name : " binariesGithubRelease"
33
- path : " llama/binariesGithubRelease.json"
34
29
- name : Upload llama.cpp artifact
35
- uses : actions/upload-artifact@v3
30
+ uses : actions/upload-artifact@v4
36
31
with :
37
32
name : " llama.cpp"
38
- path : " llama/llama.cpp"
39
- - name : Upload gitRelease.bundle artifact
40
- uses : actions/upload-artifact@v3
41
- with :
42
- name : " gitReleaseBundle"
43
- path : " llama/gitRelease.bundle"
33
+ path : |
34
+ llama/binariesGithubRelease.json
35
+ llama/llama.cpp.info.json
36
+ llama/llama.cpp
37
+ llama/gitRelease.bundle
44
38
45
39
build-binaries :
46
40
name : Build binaries - ${{ matrix.config.name }}
@@ -72,29 +66,29 @@ jobs:
72
66
artifact : " mac"
73
67
74
68
steps :
75
- - uses : actions/checkout@v3
76
- - uses : actions/setup-node@v3
69
+ - uses : actions/checkout@v4
70
+ - uses : actions/setup-node@v4
77
71
with :
78
72
node-version : " 20"
79
73
80
74
- name : Download build artifact
81
- uses : actions/download-artifact@v3
75
+ uses : actions/download-artifact@v4
82
76
with :
83
77
name : build
84
78
path : dist
85
79
86
80
- name : Download llama.cpp artifact
87
- uses : actions/download-artifact@v3
81
+ uses : actions/download-artifact@v4
88
82
with :
89
83
name : llama.cpp
90
- path : llama/llama.cpp
84
+ path : llama
91
85
92
- - name : Install dependencies on windows
86
+ - name : Install dependencies on Windows
93
87
if : startsWith(matrix.config.os, 'windows')
94
88
run : |
95
89
choco install ninja cmake
96
90
97
- - name : Install dependencies on ubuntu
91
+ - name : Install dependencies on Ubuntu
98
92
if : startsWith(matrix.config.name, 'Ubuntu GCC')
99
93
run : |
100
94
sudo apt-get update
@@ -106,7 +100,23 @@ jobs:
106
100
which arm-linux-gnueabihf-gcc
107
101
which arm-linux-gnueabihf-g++
108
102
109
- - name : Install dependencies on macos
103
+ - name : Install Cuda on Windows
104
+ if : startsWith(matrix.config.os, 'windows')
105
+
106
+ with :
107
+ cuda : ' 12.2.0'
108
+ method : ' network'
109
+ sub-packages : ' ["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
110
+ use-local-cache : false
111
+
112
+ - name : Install Cuda on Ubuntu
113
+ if : startsWith(matrix.config.name, 'Ubuntu GCC')
114
+
115
+ with :
116
+ cuda : ' 12.2.0'
117
+ method : ' network'
118
+
119
+ - name : Install dependencies on macOS
110
120
if : startsWith(matrix.config.os, 'macos')
111
121
run : |
112
122
brew install cmake ninja
@@ -148,50 +158,46 @@ jobs:
148
158
return {versions, latestVersion};
149
159
}
150
160
151
- function getArches() {
152
- switch (process.env.ARTIFACT_NAME) {
153
- case "win":
154
- return ["x64" /*, "arm64" */ ]; // disabled arm64 for now as compilation doesn't work
155
- case "linux":
156
- return ["x64", "arm64", "armv7l"];
157
- case "mac":
158
- return ["x64", "arm64"];
159
- }
160
-
161
- return ["x64"];
162
- }
163
-
164
161
const {versions: latestNodeVersions} = await getLatestNodeVersions(Date.now() - 1000 * 60 * 60 * 24 * 14);
165
162
166
163
const nodeVersion = latestNodeVersions.get(18);
167
164
const windowsOnArmNodeVersion = latestNodeVersions.get(20);
168
- const arches = getArches();
169
165
170
166
if (nodeVersion == null || windowsOnArmNodeVersion == null) {
171
167
throw new Error("Could not find node versions");
172
168
}
173
169
174
- console.log("Building for node version", nodeVersion, "and archs", arches);
175
-
176
170
await $`mkdir -p llamaBins`;
177
171
178
- for (const arch of arches) {
179
- const additionalFlags = [];
180
- let buildNodeVersion = nodeVersion;
181
-
182
- if (process.env.ARTIFACT_NAME === "win" && arch === "arm64") {
183
- buildNodeVersion = windowsOnArmNodeVersion;
184
- } else if (process.env.ARTIFACT_NAME === "mac" && arch === "arm64") {
185
- additionalFlags.push("--metal");
186
- } else if (process.env.ARTIFACT_NAME === "mac" && arch === "x64") {
187
- additionalFlags.push("--no-metal");
188
- }
189
-
190
- console.log(`Building ${arch} for node ${buildNodeVersion}`);
172
+ async function buildBinary(arch, flags = [], nodeTarget = nodeVersion) {
173
+ console.log(`Building ${arch} for node ${nodeTarget} with flags`, flags);
191
174
192
- const binName = `${process.env.ARTIFACT_NAME}-${arch}`;
193
- await $`node ./dist/cli/cli.js build --arch ${arch} --nodeTarget ${buildNodeVersion} ${additionalFlags}`;
194
- await $`mv ./llama/build/Release ${"./llamaBins/" + binName}`;
175
+ await $`node ./dist/cli/cli.js build --noUsageExample --arch ${arch} --nodeTarget ${nodeVersion} ${flags}`;
176
+ }
177
+
178
+ // build binaries
179
+ if (process.env.ARTIFACT_NAME === "win") {
180
+ await buildBinary("x64");
181
+ await buildBinary("x64", ["--cuda"]);
182
+ // await buildBinary("arm64", [], windowsOnArmNodeVersion); // disabled arm64 for now as compilation doesn't work
183
+ } else if (process.env.ARTIFACT_NAME === "linux") {
184
+ await buildBinary("x64");
185
+ await buildBinary("x64", ["--cuda"]);
186
+ await buildBinary("arm64");
187
+ await buildBinary("armv7l");
188
+ } else if (process.env.ARTIFACT_NAME === "mac") {
189
+ await buildBinary("x64", ["--metal"]);
190
+ await buildBinary("arm64", ["--no-metal"]);
191
+ }
192
+
193
+ // move binaries to llamaBins
194
+ const localBuildsDirectoryPath = path.join(process.cwd(), "llama", "localBuilds");
195
+ const llamaBinsDirectoryPath = path.join(process.cwd(), "llamaBins");
196
+ for (const folderName of await fs.readdir(localBuildsDirectoryPath)) {
197
+ await fs.move(
198
+ path.join(localBuildsDirectoryPath, folderName, "Release"),
199
+ path.join(llamaBinsDirectoryPath, folderName)
200
+ );
195
201
}
196
202
197
203
await $`echo "Built binaries:"`;
@@ -200,7 +206,7 @@ jobs:
200
206
EOF
201
207
202
208
- name : Publish artifact
203
- uses : actions/upload-artifact@v3
209
+ uses : actions/upload-artifact@v4
204
210
with :
205
211
name : " bins-${{ matrix.config.artifact }}"
206
212
path : " llamaBins/*"
@@ -211,22 +217,22 @@ jobs:
211
217
needs :
212
218
- build
213
219
steps :
214
- - uses : actions/checkout@v3
215
- - uses : actions/setup-node@v3
220
+ - uses : actions/checkout@v4
221
+ - uses : actions/setup-node@v4
216
222
with :
217
223
node-version : " 20"
218
224
219
225
- name : Download build artifact
220
- uses : actions/download-artifact@v3
226
+ uses : actions/download-artifact@v4
221
227
with :
222
228
name : build
223
229
path : dist
224
230
225
231
- name : Download llama.cpp artifact
226
- uses : actions/download-artifact@v3
232
+ uses : actions/download-artifact@v4
227
233
with :
228
234
name : llama.cpp
229
- path : llama/llama.cpp
235
+ path : llama
230
236
231
237
- name : Install dependencies on ubuntu
232
238
run : |
@@ -248,22 +254,22 @@ jobs:
248
254
needs :
249
255
- build
250
256
steps :
251
- - uses : actions/checkout@v3
252
- - uses : actions/setup-node@v3
257
+ - uses : actions/checkout@v4
258
+ - uses : actions/setup-node@v4
253
259
with :
254
260
node-version : " 20"
255
261
256
262
- name : Download build artifact
257
- uses : actions/download-artifact@v3
263
+ uses : actions/download-artifact@v4
258
264
with :
259
265
name : build
260
266
path : dist
261
267
262
268
- name : Download llama.cpp artifact
263
- uses : actions/download-artifact@v3
269
+ uses : actions/download-artifact@v4
264
270
with :
265
271
name : llama.cpp
266
- path : llama/llama.cpp
272
+ path : llama
267
273
268
274
- name : Install dependencies on macOS
269
275
run : |
@@ -278,7 +284,7 @@ jobs:
278
284
279
285
- name : Cache models
280
286
id : cache-test-models
281
- uses : actions/cache@v3
287
+ uses : actions/cache@v4
282
288
with :
283
289
path : " test/.models/**.gguf"
284
290
key : cache-test-models-${{ runner.os }}-${{ github.workflow }}
@@ -307,15 +313,15 @@ jobs:
307
313
- build
308
314
- build-binaries
309
315
steps :
310
- - uses : actions/checkout@v3
316
+ - uses : actions/checkout@v4
311
317
with :
312
318
lfs : true
313
- - uses : actions/setup-node@v3
319
+ - uses : actions/setup-node@v4
314
320
with :
315
321
node-version : " 20"
316
322
- name : Install modules
317
323
run : npm ci
318
- - uses : actions/download-artifact@v3
324
+ - uses : actions/download-artifact@v4
319
325
with :
320
326
path : artifacts
321
327
- name : Move artifacts
@@ -324,13 +330,16 @@ jobs:
324
330
mv artifacts/bins-*/* llamaBins/
325
331
mv artifacts/build dist/
326
332
327
- cp -r artifacts/llama.cpp/grammars llama/grammars
333
+ cp -r artifacts/llama.cpp/llama.cpp/ grammars llama/grammars
328
334
329
335
rm -f ./llama/binariesGithubRelease.json
330
- mv artifacts/binariesGithubRelease/binariesGithubRelease.json ./llama/binariesGithubRelease.json
336
+ mv artifacts/llama.cpp/binariesGithubRelease.json ./llama/binariesGithubRelease.json
337
+
338
+ rm -f ./llama/llama.cpp.info.json
339
+ mv artifacts/llama.cpp/llama.cpp.info.json ./llama/llama.cpp.info.json
331
340
332
341
rm -f ./llama/gitRelease.bundle
333
- mv artifacts/gitReleaseBundle /gitRelease.bundle ./llama/gitRelease.bundle
342
+ mv artifacts/llama.cpp /gitRelease.bundle ./llama/gitRelease.bundle
334
343
335
344
echo "Built binaries:"
336
345
ls llamaBins
@@ -356,12 +365,12 @@ jobs:
356
365
npm run docs:build
357
366
- name : Upload docs to GitHub Pages
358
367
if : steps.set-npm-url.outputs.npm-url != '' && github.ref == 'refs/heads/master'
359
- uses : actions/upload-pages- artifact@v2
368
+ uses : actions/upload-artifact@v4
360
369
with :
361
370
name : pages-docs
362
371
path : docs-site
363
372
- name : Deploy docs to GitHub Pages
364
373
if : steps.set-npm-url.outputs.npm-url != '' && github.ref == 'refs/heads/master'
365
- uses : actions/deploy-pages@v2
374
+ uses : actions/deploy-pages@v4
366
375
with :
367
376
artifact_name : pages-docs
0 commit comments