|
| 1 | +# setup_cuda |
| 2 | + |
| 3 | +A reusable action to install NVIDIA CUDA Toolkit on Linux runners using the runfile installer. |
| 4 | + |
| 5 | +This action provides a consistent way to install CUDA Toolkit across different Linux runners, including both standard |
| 6 | +Ubuntu and ARM-based Ubuntu runners. The installation uses NVIDIA's official runfile installers and sets up all |
| 7 | +necessary environment variables for C/C++ compilation. |
| 8 | + |
| 9 | +## 🛠️ Prep Work |
| 10 | + |
| 11 | +This action is designed for Linux runners only and requires: |
| 12 | +- Ubuntu-based runner (standard x86_64 or ARM64/aarch64) |
| 13 | +- Sufficient disk space (CUDA Toolkit requires ~3-4 GB) |
| 14 | +- `sudo` access (required for installation) |
| 15 | + |
| 16 | +> [!NOTE] |
| 17 | +> This action installs the CUDA Toolkit only (compiler, libraries, headers) and does not install GPU drivers, |
| 18 | +> as they are not needed for compilation and are not available in standard GitHub Actions runners. |
| 19 | +
|
| 20 | +> [!TIP] |
| 21 | +> To find the correct CUDA version and driver version combination, visit the |
| 22 | +> [NVIDIA CUDA Toolkit Downloads](https://developer.nvidia.com/cuda-downloads) page and select your desired version. |
| 23 | +> The driver version is part of the runfile name. |
| 24 | +
|
| 25 | +## 🚀 Basic Usage |
| 26 | + |
| 27 | +See [action.yml](action.yml) |
| 28 | + |
| 29 | +### CUDA 12.4.1 |
| 30 | +```yaml |
| 31 | +steps: |
| 32 | + - name: Setup CUDA 12.4.1 |
| 33 | + uses: LizardByte/actions/actions/setup_cuda@master |
| 34 | + with: |
| 35 | + cuda-version: '12.4.1' |
| 36 | + driver-version: '550.54.15' |
| 37 | + - name: Verify CUDA Version |
| 38 | + run: nvcc --version |
| 39 | +``` |
| 40 | +
|
| 41 | +### Custom Installation Path |
| 42 | +```yaml |
| 43 | +steps: |
| 44 | + - name: Setup CUDA |
| 45 | + uses: LizardByte/actions/actions/setup_cuda@master |
| 46 | + with: |
| 47 | + cuda-version: '12.6.2' |
| 48 | + driver-version: '560.35.03' |
| 49 | + install-path: '/opt/cuda' |
| 50 | +``` |
| 51 | +
|
| 52 | +## 📥 Inputs |
| 53 | +
|
| 54 | +| Name | Description | Default | Required | |
| 55 | +|----------------|-------------------------------------------------------------------------|-------------------|----------| |
| 56 | +| cuda-version | The version of CUDA Toolkit to install (e.g., '12.6.2', '11.8.0') | | `true` | |
| 57 | +| driver-version | The driver version in the runfile name (e.g., '560.35.03', '520.61.05') | | `true` | |
| 58 | +| install-path | Installation path for CUDA Toolkit | `/usr/local/cuda` | `false` | |
| 59 | + |
| 60 | +> [!NOTE] |
| 61 | +> The `driver-version` is the version number included in NVIDIA's runfile name. For example, for the file |
| 62 | +> `cuda_12.4.1_550.54.15_linux.run`, the cuda-version is `12.4.1` and the driver-version is `550.54.15`. |
| 63 | +> You can find these on the [NVIDIA CUDA Downloads](https://developer.nvidia.com/cuda-downloads) page. |
| 64 | + |
| 65 | +## 📤 Outputs |
| 66 | + |
| 67 | +| Name | Description | |
| 68 | +|--------------|----------------------------------------| |
| 69 | +| cuda-version | The version of CUDA that was installed | |
| 70 | +| cuda-path | The installation path of CUDA Toolkit | |
| 71 | +| nvcc-path | The path to the nvcc compiler | |
| 72 | + |
| 73 | +## 📝 Notes |
| 74 | + |
| 75 | +### Supported CUDA Versions |
| 76 | + |
| 77 | +This action can install **any** CUDA Toolkit version available from NVIDIA, as long as you provide the correct |
| 78 | +`cuda-version` and `driver-version` combination. There is no hardcoded list of supported versions. |
| 79 | + |
| 80 | +> [!TIP] |
| 81 | +> To find the driver version for any CUDA version: |
| 82 | +> 1. Visit [NVIDIA CUDA Toolkit Archive](https://developer.nvidia.com/cuda-toolkit-archive) |
| 83 | +> 2. Select your desired CUDA version |
| 84 | +> 3. Choose "Linux" → "x86_64" (or "sbsa" for ARM) → "Ubuntu" → "runfile (local)" |
| 85 | +> 4. The download link will show the full runfile name, which includes the driver version |
| 86 | +> |
| 87 | +> For example: `cuda_12.4.1_550.54.15_linux.run` means driver version is `550.54.15` |
| 88 | + |
| 89 | +> [!NOTE] |
| 90 | +> The action automatically detects your architecture and downloads the appropriate installer: |
| 91 | +> - **x86_64**: Downloads `cuda_X.Y.Z_DDD.DD.DD_linux.run` |
| 92 | +> - **aarch64**: Downloads `cuda_X.Y.Z_DDD.DD.DD_linux_sbsa.run` (Server Base System Architecture) |
| 93 | + |
| 94 | +### Environment Variables |
| 95 | + |
| 96 | +This action automatically sets up the following environment variables for subsequent steps: |
| 97 | + |
| 98 | +- `CUDA_PATH` - Path to CUDA installation (e.g., `/usr/local/cuda`) |
| 99 | +- `CUDA_HOME` - Same as CUDA_PATH (for compatibility) |
| 100 | +- `CUDA_ROOT` - Same as CUDA_PATH (for compatibility) |
| 101 | +- `CMAKE_CUDA_COMPILER` - Path to nvcc compiler |
| 102 | +- `PATH` - Updated to include `${CUDA_PATH}/bin` |
| 103 | +- `LD_LIBRARY_PATH` - Updated to include `${CUDA_PATH}/lib64` |
| 104 | +- `LIBRARY_PATH` - Updated to include `${CUDA_PATH}/lib64` |
| 105 | +- `CPATH` - Updated to include `${CUDA_PATH}/include` |
| 106 | + |
| 107 | +These variables make it easy to compile CUDA code with various build systems (Make, CMake, etc.). |
| 108 | + |
| 109 | +### Installation Details |
| 110 | + |
| 111 | +- **Installation Method**: Official NVIDIA runfile installer |
| 112 | +- **Components Installed**: CUDA Toolkit only (compiler, libraries, headers) |
| 113 | +- **Components NOT Installed**: GPU drivers, OpenGL libraries (not needed for compilation) |
| 114 | +- **Installation Size**: ~3-4 GB depending on version |
| 115 | +- **Installation Time**: ~2-5 minutes depending on runner speed |
| 116 | + |
| 117 | +### CMake Integration |
| 118 | + |
| 119 | +The action sets `CMAKE_CUDA_COMPILER` automatically, so CMake will find the correct nvcc compiler. |
| 120 | + |
| 121 | +## 🔗 See Also |
| 122 | + |
| 123 | +- [more_space](../more_space) - Free up disk space if needed before CUDA installation |
| 124 | +- [monitor_space](../monitor_space) - Monitor disk space usage during CUDA installation |
| 125 | + |
| 126 | +## ⚠️ Limitations |
| 127 | + |
| 128 | +- **Linux Only**: This action only supports Linux runners (Ubuntu-based) |
| 129 | +- **No GPU Execution**: GitHub Actions runners don't have GPUs, so you can compile CUDA code but not run it |
| 130 | +- **No Driver Installation**: GPU drivers are not installed (not needed for compilation) |
| 131 | +- **Architecture Support**: Only x86_64 and ARM64/aarch64 architectures are supported |
0 commit comments