How to Build and Test on a Self-Hosted GPU Runner in GitHub Actions
A labeled GPU runner lets CUDA jobs run where GitHub-hosted runners cannot.
Register a self-hosted runner with a gpu label on a GPU host, then target it with runs-on and confirm the GPU is visible.
Steps
- Register the runner on a GPU machine with a custom
gpulabel. - Target it via
runs-on: [self-hosted, gpu]. - Verify the GPU with
nvidia-smibefore the workload.
Workflow
.github/workflows/train.yml
jobs:
train:
runs-on: [self-hosted, gpu]
steps:
- uses: actions/checkout@v4
- run: nvidia-smi
- run: pip install -r requirements.txt && python train.pyGotchas
- The host needs matching NVIDIA drivers and the CUDA toolkit installed.
- Latchkey can manage GPU runners for you with self-healing provisioning at lower cost than an always-on box.
Related guides
How to Set Up a Self-Hosted Runner in GitHub ActionsRegister and use a self-hosted GitHub Actions runner by installing the runner agent, configuring it with a to…
How to Run a Job in a Custom Container in GitHub ActionsRun a whole GitHub Actions job inside a custom Docker container with the container key, pulling a private ima…