Skip to content


2 posts with the tag “hosted-runner”

How to setup docker with NVIDIA GPU support on Ubuntu 22

This took a bit of a search for me, so here it is in case it’s useful:

Terminal window
cd /tmp/
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get install -y cuda-drivers-545 nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

Then you should be able to run the following docker container with gpu enabled:

Terminal window
docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi

And get the following output:

Fri Dec 8 14:49:32 2023
| NVIDIA-SMI 545.23.08 Driver Version: 545.23.08 CUDA Version: 12.3 |
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
| 0 Tesla T4 On | 00000000:00:1E.0 Off | 0 |
| N/A 29C P0 25W / 70W | 5MiB / 15360MiB | 0% Default |
| | | N/A |
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
| No running processes found |

How to setup GitHub hosted runner with a simple cloud-init script

Edit: RunsOn is now available as a modern way to setup self-hosted GitHub Actions runners!

While waiting for the RunsOn ephemeral self-hosted runners service, here is a short bash script, that can also be used as cloud-init script for launching GitHub hosted runners non-interactively:

#!/bin/bash -ex
set -o pipefail
# update this to the latest version
# Install docker, then additional packages and stuff:
apt update -qq
apt install -y ruby awscli
curl | tar -xJf - --strip=1 -C /usr/local/
curl | sh
cat > /etc/cron.daily/docker-prune <<EOF
docker image prune -a --filter="until=96h" --force
docker volume prune --force
chmod a+x /etc/cron.daily/docker-prune
# Create dedicated user
useradd -m -d /home/runner -s /bin/bash runner
usermod -G docker runner
# Download and install runner script
cd /home/runner
mkdir -p actions-runner
cd actions-runner
curl -o actions-runner-linux-x64-$RUNNER_VERSION.tar.gz -L$RUNNER_VERSION/actions-runner-linux-x64-$RUNNER_VERSION.tar.gz
tar xzf ./actions-runner-linux-x64-$RUNNER_VERSION.tar.gz
# Configure runner
su - runner -c "
/home/runner/actions-runner/ --url$RUNNER_ORG --token $RUNNER_TOKEN --labels $RUNNER_LABELS --unattended
# Setup systemd scripts
cd /home/runner/actions-runner/
./ install runner
./ start
./ status

You should be good to go!

Note that those runners won’t be ephemeral, so usual caveats apply regarding security of those runners.