Skip to content

Instantly share code, notes, and snippets.

@snoby
Last active December 4, 2023 19:11
Show Gist options
  • Save snoby/08da219a4ba6d7e41a58b165779f0b31 to your computer and use it in GitHub Desktop.
Save snoby/08da219a4ba6d7e41a58b165779f0b31 to your computer and use it in GitHub Desktop.
install into hiveos to allow GPU's to be passed to docker container
#!/bin/bash
set -x
apt update -y && apt install gpg sed curl sudo -y
nvidia-driver-update --version 535.113.01
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt-get update \
&& sudo apt-get install -y\
nvidia-container-toolkit-base \
docker.io \
nvidia-docker2
nvidia-ctk runtime configure --runtime=docker
nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml
systemctl restart docker
#
# Verify everything works with the command
#
docker run --rm --gpus all nvidia/cuda:12.0.1-base-ubuntu20.04 nvidia-smi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment