Skip to content

Commit

Permalink
#379 ARM Runner + CUDA (#378)
Browse files Browse the repository at this point in the history
* Add support for ARM architecture for linux local/network installs

---------

Co-authored-by: Jimver <jim.verheijde@hotmail.com>
  • Loading branch information
johnnynunez and Jimver authored Jan 27, 2025
1 parent a47004d commit 8022558
Show file tree
Hide file tree
Showing 15 changed files with 196 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Ubuntu",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"image": "mcr.microsoft.com/devcontainers/base:noble",
"features": {
"ghcr.io/devcontainers-contrib/features/volta:1": {}
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-2022, windows-2019, ubuntu-22.04, ubuntu-20.04]
os: [windows-2025, windows-2022, ubuntu-24.04, ubuntu-22.04, ubuntu-24.04-arm, ubuntu-22.04-arm]
method: [local, network]
runs-on: ${{ matrix.os }}

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This action installs the [NVIDIA® CUDA® Toolkit](https://developer.nvidia.com/

**Optional** The CUDA version to install. View `src/link/windows-links.ts` and `src/link/linux-links.ts` for available versions.

Default: `'12.6.1'`.
Default: `'12.8.0'`.

### `sub-packages`

Expand Down Expand Up @@ -88,7 +88,7 @@ The path where cuda is installed (same as `CUDA_PATH` in `GITHUB_ENV`).

```yaml
steps:
- uses: Jimver/cuda-toolkit@v0.2.20
- uses: Jimver/cuda-toolkit@v0.2.21
id: cuda-toolkit
with:
cuda: '12.5.0'
Expand Down
23 changes: 23 additions & 0 deletions __tests__/arch.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {CPUArch, getArch} from '../src/arch'
import os from 'os'

test.concurrent('Return either x64 or arm64 architecture', async () => {
const archString = os.arch()
let expected: CPUArch
switch (archString) {
case 'x64':
expected = CPUArch.x86_64
break
case 'arm64':
expected = CPUArch.arm64
break
default:
await expect(getArch()).rejects.toThrow(
`Unsupported architecture: ${archString}`
)
return
}

const detectedArch = await getArch()
expect(detectedArch).toBe(expected)
})
3 changes: 2 additions & 1 deletion __tests__/links/linux-links.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ test.concurrent(
'Linux Cuda version to URL map contains valid URLs',
async () => {
for (const version of LinuxLinks.Instance.getAvailableLocalCudaVersions()) {
const url: URL = LinuxLinks.Instance.getLocalURLFromCudaVersion(version)
const url: URL =
await LinuxLinks.Instance.getLocalURLFromCudaVersion(version)
expect(url).toBeInstanceOf(URL)
}
}
Expand Down
3 changes: 2 additions & 1 deletion __tests__/links/windows-links.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ test.concurrent(
'Windows Cuda version to URL map contains valid URLs',
async () => {
for (const version of WindowsLinks.Instance.getAvailableLocalCudaVersions()) {
const url: URL = WindowsLinks.Instance.getLocalURLFromCudaVersion(version)
const url: URL =
await WindowsLinks.Instance.getLocalURLFromCudaVersion(version)
expect(url).toBeInstanceOf(URL)
}
}
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
cuda:
description: 'Cuda version'
required: false
default: '12.6.1'
default: '12.8.0'
sub-packages:
description: 'Only installs specified subpackages, must be in the form of a JSON array. For example, if you only want to install nvcc and visual studio integration: ["nvcc", "visual_studio_integration"] double quotes required! Note that if you want to use this on Linux, ''network'' method MUST be used.'
required: false
Expand Down
116 changes: 105 additions & 11 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cuda-toolkit",
"version": "0.2.20",
"version": "0.2.21",
"description": "GitHub Action to install the NVIDIA CUDA Toolkit",
"main": "lib/main.js",
"scripts": {
Expand Down
16 changes: 15 additions & 1 deletion src/apt-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Method} from './method'
import {SemVer} from 'semver'
import {exec} from '@actions/exec'
import {execReturnOutput} from './run-command'
import {CPUArch, getArch} from './arch'

export async function useApt(method: Method): Promise<boolean> {
return method === 'network' && (await getOs()) === OSType.linux
Expand All @@ -19,8 +20,21 @@ export async function aptSetup(version: SemVer): Promise<void> {
core.debug(`Setup packages for ${version}`)
const ubuntuVersion: string = await execReturnOutput('lsb_release', ['-sr'])
const ubuntuVersionNoDot = ubuntuVersion.replace('.', '')

// Dynamically determine architecture
let arch = 'x86_64' // Default to x86_64
try {
if ((await getArch()) === CPUArch.arm64) {
arch = 'sbsa' // This might not work in the future, they are merging arm64 and sbsa
}
} catch (error) {
core.warning(`Could not detect architecture, using default ${arch}`)
}
core.debug(
`Detected architecture: ${process.arch}, using arch string: ${arch}`
)

const pinFilename = `cuda-ubuntu${ubuntuVersionNoDot}.pin`
const arch = `x86_64`
const pinUrl = `https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${ubuntuVersionNoDot}/${arch}/${pinFilename}`
const repoUrl = `http://developer.download.nvidia.com/compute/cuda/repos/ubuntu${ubuntuVersionNoDot}/${arch}/`
const keyRingVersion = `1.1-1`
Expand Down
20 changes: 20 additions & 0 deletions src/arch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {debug} from '@actions/core'
import os from 'os'

export enum CPUArch {
x86_64 = 'x64',
arm64 = 'arm64'
}

export async function getArch(): Promise<CPUArch> {
const arch = os.arch()
switch (arch) {
case 'x64':
return CPUArch.x86_64
case 'arm64':
return CPUArch.arm64
default:
debug(`Unsupported architecture: ${arch}`)
throw new Error(`Unsupported architecture: ${arch}`)
}
}
Loading

0 comments on commit 8022558

Please sign in to comment.