-
-
Notifications
You must be signed in to change notification settings - Fork 198
feat: riscv64 prebuilt binaries #615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
afc96cd
44e844c
362c8ff
4342c57
aa9fd7f
be14bfe
bf8fe22
d3163b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,13 +75,31 @@ jobs: | |
| - name: "macOS arm64" | ||
| os: macos-26 | ||
| artifact: "mac-arm64" | ||
| - name: "Ubuntu riscv64" | ||
| os: ubuntu-24.04-riscv | ||
| artifact: "linux-riscv64" | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| if: matrix.config.artifact != 'linux-riscv64' | ||
| with: | ||
| node-version: "20" | ||
|
|
||
| - name: Install Node.js (riscv64 unofficial build) | ||
| if: matrix.config.artifact == 'linux-riscv64' | ||
| run: | | ||
| set -e | ||
| # node 24 (npm 11): node 20's npm 10.8.2 trips "set.delete is not a | ||
| # function" during npm ci on riscv64, and several devDeps require | ||
| # node >= 24.10. The built binary still targets node 20 N-API. | ||
| NODE_VER=v24.16.0 | ||
| curl -fsSL -o /tmp/node.tar.xz "https://unofficial-builds.nodejs.org/download/release/${NODE_VER}/node-${NODE_VER}-linux-riscv64.tar.xz" | ||
| mkdir -p "$HOME/node" | ||
| tar -xJf /tmp/node.tar.xz -C "$HOME/node" --strip-components=1 | ||
| echo "$HOME/node/bin" >> "$GITHUB_PATH" | ||
| "$HOME/node/bin/node" --version | ||
|
|
||
| - name: Download build artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
|
|
@@ -131,6 +149,19 @@ jobs: | |
|
|
||
| cmake --version | ||
|
|
||
| - name: Install dependencies on Ubuntu riscv64 | ||
| if: matrix.config.name == 'Ubuntu riscv64' | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y cmake build-essential ninja-build libtbb-dev gcc-14 g++-14 | ||
| # llama.cpp's ggml-cpu uses the RVV _Float16 (zvfh) vector intrinsics, | ||
| # which only exist in GCC 14+. The runner defaults to GCC 13, so make | ||
| # gcc-14/g++-14 the default compilers (same as upstream build-riscv). | ||
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 | ||
| sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100 | ||
| cmake --version | ||
| gcc --version | ||
|
|
||
| - name: Install Cuda 13.1 on Windows (1) | ||
| if: matrix.config.name == 'Windows (1)' | ||
| uses: Jimver/cuda-toolkit@v0.2.30 | ||
|
|
@@ -207,9 +238,15 @@ jobs: | |
| timeout-minutes: 300 | ||
| env: | ||
| ARTIFACT_NAME: ${{ matrix.config.artifact }} | ||
| # electron has no riscv64 prebuilt binary; the binary build does not | ||
| # use it (the electron example is a separate job), so skip its | ||
| # postinstall download to let npm ci complete on riscv64. | ||
| ELECTRON_SKIP_BINARY_DOWNLOAD: ${{ matrix.config.artifact == 'linux-riscv64' && '1' || '' }} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only use the electron types in the build anyway, so we can set that to always skip the binary download |
||
| run: | | ||
| npm ci | ||
|
|
||
| # npm on the unofficial riscv64 node intermittently throws internal | ||
| # TypeErrors (e.g. "key.match is not a function"); retry a few times. | ||
| npm ci || npm ci || npm ci | ||
|
Comment on lines
+246
to
+248
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we update npm will those issues go away? What do they stem from? |
||
|
|
||
| npx zx -y <<'EOF' | ||
|
|
||
| async function getLatestNodeVersions(maxDate) { | ||
|
|
@@ -275,6 +312,8 @@ jobs: | |
| await buildBinary("x64", ["--gpu", "false"]); | ||
| } else if (process.env.ARTIFACT_NAME === "mac-arm64") { | ||
| await buildBinary("arm64", ["--gpu", "metal"]); | ||
| } else if (process.env.ARTIFACT_NAME === "linux-riscv64") { | ||
| await buildBinary("riscv64", ["--gpu", "false"]); | ||
| } | ||
|
|
||
| // move binaries to bins | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /dist |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2024 Gilad S. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # [`node-llama-cpp`](https://github.com/withcatai/node-llama-cpp) | ||
| This is a prebuilt binary package for [`node-llama-cpp`](https://github.com/withcatai/node-llama-cpp) for Linux riscv64. | ||
|
|
||
| Do not install this package directly. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| { | ||
| "name": "@node-llama-cpp/linux-riscv64", | ||
| "version": "0.1.0", | ||
| "description": "Prebuilt binary for node-llama-cpp for Linux riscv64", | ||
| "main": "dist/index.js", | ||
| "type": "module", | ||
| "files": [ | ||
| "dist/", | ||
| "bins/", | ||
| "package.json", | ||
| "README.md", | ||
| "LICENSE" | ||
| ], | ||
| "exports": { | ||
| ".": { | ||
| "import": "./dist/index.js", | ||
| "node": "./dist/index.js", | ||
| "default": "./dist/index.js" | ||
| } | ||
| }, | ||
| "engines": { | ||
| "node": ">=20.0.0" | ||
| }, | ||
| "os": [ | ||
| "linux" | ||
| ], | ||
| "cpu": [ | ||
| "riscv64" | ||
| ], | ||
| "libc": [ | ||
| "glibc" | ||
| ], | ||
| "scripts": { | ||
| "prebuild": "rimraf ./dist ./tsconfig.tsbuildinfo", | ||
| "build": "tsc --build tsconfig.json --force", | ||
| "prewatch": "rimraf ./dist ./tsconfig.tsbuildinfo", | ||
| "watch": "tsc --build tsconfig.json --watch --force", | ||
| "clean": "rm -rf ./node_modules ./dist ./tsconfig.tsbuildinfo" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/withcatai/node-llama-cpp.git" | ||
| }, | ||
| "author": "Gilad S.", | ||
| "license": "MIT", | ||
| "preferUnplugged": true, | ||
| "bugs": { | ||
| "url": "https://github.com/withcatai/node-llama-cpp/issues" | ||
| }, | ||
| "homepage": "https://node-llama-cpp.withcat.ai", | ||
| "devDependencies": { | ||
| "typescript": "^5.2.2" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import path from "path"; | ||
| import {fileURLToPath} from "url"; | ||
| import fs from "node:fs/promises"; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const binsDir = path.join(__dirname, "..", "bins"); | ||
| const packageVersion: string = (JSON.parse(await fs.readFile(path.join(__dirname, "..", "package.json"), "utf8"))).version; | ||
|
|
||
| export function getBinsDir() { | ||
| return { | ||
| binsDir, | ||
| packageVersion | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "lib": ["es2022"], | ||
| "module": "node16", | ||
| "target": "es2022", | ||
| "esModuleInterop": true, | ||
| "noImplicitAny": true, | ||
| "noImplicitReturns": true, | ||
| "noImplicitThis": true, | ||
| "noImplicitOverride": true, | ||
| "removeComments": false, | ||
| "allowSyntheticDefaultImports": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "noFallthroughCasesInSwitch": true, | ||
| "skipLibCheck": true, | ||
| "moduleResolution": "node16", | ||
| "resolveJsonModule": false, | ||
| "strictNullChecks": true, | ||
| "isolatedModules": true, | ||
| "noEmit": false, | ||
| "outDir": "./dist", | ||
| "strict": true, | ||
| "sourceMap": false, | ||
| "composite": false, | ||
| "declaration": false, | ||
| "stripInternal": true | ||
| }, | ||
| "files": [ | ||
| "./src/index.ts" | ||
| ], | ||
| "include": [ | ||
| "./src" | ||
| ] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe updating to
actions/setup-node@v6would work out of the box?Maybe some config option on it would solve the issue so we don't have to run a custom node installation step?