Set up a specific version of NVIDIA CUDA in GitHub Actions.
- π Dynamic Version Selection: Install any CUDA version without waiting for action updates
- π― Flexible Version Specification: Support for
latest,Major,Major.Minor, orMajor.Minor.Patchformats - β‘οΈ Automatic Installation Method Selection: Intelligently chooses between network and local installers
- π» Cross-Platform Support: Works on both Linux (x86_64 and ARM64) and Windows (x86_64) runners
- π₯ Supports Both Debian-based and Fedora-based Distributions: Works seamlessly on Ubuntu, Debian, Fedora, AlmaLinux, and other related container/VM environments
- π οΈ Environment Configuration: Automatically sets up all necessary environment variables
- β Supported Versions: Supports CUDA versions >= 10.0
- Linux: ubuntu-latest, ubuntu-24.04, ubuntu-22.04, ubuntu-24.04-arm, ubuntu-22.04-arm, fedora, almalinux, manylinux_2_28_x86_64
- Windows: windows-latest, windows-2025, windows-2022
steps:
- name: Setup CUDA
uses: mjun0812/setup-cuda@v1
with:
version: '12.4'steps:
- name: Setup latest CUDA
uses: mjun0812/setup-cuda@v1
with:
version: 'latest'The latest patch version will be automatically selected.
steps:
- name: Setup CUDA 12.4
uses: mjun0812/setup-cuda@v1
with:
version: '12.4'steps:
- name: Setup CUDA 12.4.1
uses: mjun0812/setup-cuda@v1
with:
version: '12.4.1'steps:
- name: Setup CUDA with network installer
uses: mjun0812/setup-cuda@v1
with:
version: '12.4'
method: 'network' # or 'local', 'auto'TestContainer:
runs-on: ubuntu-latest
container:
image: fedora:latest
steps:
- name: Install System Dependencies
shell: bash
run: |
# POSIX-compatible redirection so it works even without bash
if command -v dnf >/dev/null 2>&1; then
echo "dnf found"
dnf install -y --allowerasing libxml2 wget gcc gcc-c++ make curl sudo git
elif command -v yum >/dev/null 2>&1; then
echo "yum found"
yum install -y libxml2 wget gcc gcc-c++ make curl sudo git
elif command -v apt-get >/dev/null 2>&1; then
echo "apt-get found"
apt-get update
apt-get install -y libxml2 curl wget build-essential sudo git
fi
- name: Setup CUDA
uses: mjun0812/setup-cuda@v1
with:
version: '12.4'Description: The version of NVIDIA CUDA to install (supports versions > 10.0).
Format:
latest: Install the latest available versionMajor(e.g.,13): Install the latest minor version for the specified major versionMajor.Minor(e.g.,12.4): Install the latest patch version for the specified major.minor versionMajor.Minor.Patch(e.g.,12.4.1): Install the exact version specified
Required: No
Default: latest
Description: The method to use to install CUDA.
Options:
auto: Tries thenetworkmethod first. If it fails or is unavailable, falls back tolocalnetwork: Uses the CUDA network installer. Faster download, but supported combinations of CUDA versions and OS are limitedlocal: Downloads the full local installer. More robust availability, but larger download size
Required: No
Default: auto
The full version string of NVIDIA CUDA that was actually installed (e.g., 12.4.1).
Example:
- name: Setup CUDA
id: cuda
uses: mjun0812/setup-cuda@v1
with:
version: '12.4'
- name: Print installed version
run: echo "Installed CUDA version ${{ steps.cuda.outputs.version }}"The absolute path to the NVIDIA CUDA installation directory.
Example:
- name: Setup CUDA
id: cuda
uses: mjun0812/setup-cuda@v1
- name: Use CUDA path
run: echo "CUDA installed at ${{ steps.cuda.outputs.cuda-path }}"This action automatically configures the following environment variables for subsequent steps:
CUDA_PATH: Path to the CUDA installation directoryCUDA_HOME: Alias forCUDA_PATH(commonly used by build systems)PATH: Prepends${CUDA_PATH}/binfor access to CUDA binaries (nvcc, etc.)
LD_LIBRARY_PATH: Prepends${CUDA_PATH}/lib64for runtime library loading
PATH: Also includes${CUDA_PATH}/lib/x64for DLL access
If the network installer fails, the action will automatically fall back to the local installer when using method: auto. You can also explicitly specify method: local.
- name: Setup CUDA with local installer
uses: mjun0812/setup-cuda@v1
with:
version: '12.4'
method: 'local'Ensure the version you specified is available on the NVIDIA website. You can check available versions at:
If you encounter an error like No space left on device, you can try to expand the disk space before running the action:
- name: Expand disk space
run: |
df -h
sudo rm -rf /usr/share/dotnet || true
sudo rm -rf /usr/local/lib/android || true
echo "-------"
df -hWhat is the difference between this repository and Jimver/cuda-toolkit?
Jimver/cuda-toolkit is a same Github Action for installing NVIDIA CUDA.
That action installs CUDA from hard-coded URLs, whereas this repository installs CUDA from dynamically generated URLs. Therefore, you can download the latest CUDA without waiting for the Action to be updated.
In addition, it supports specifying versions as latest or by major/minor version, and automatically selects between network and local installers.
Furthermore, this repository supports ARM64 architecture on Linux, which is not supported by Jimver/cuda-toolkit.