Skip to content

Instantly share code, notes, and snippets.

@cybersholt
Created August 7, 2024 14:27
Show Gist options
  • Save cybersholt/224cea12a4ad08882da0d9049ce2f42a to your computer and use it in GitHub Desktop.
Save cybersholt/224cea12a4ad08882da0d9049ce2f42a to your computer and use it in GitHub Desktop.
#!/bin/bash
# Used this to get things up and running in proxmox / ubuntu vm
# Update package lists
sudo apt-get update
# Install required packages
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
# Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Verify the fingerprint
sudo apt-key fingerprint 0EBFCD88
# Set up the stable Docker repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# Update package lists again
sudo apt-get update
# Install Docker Engine
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# Add your user to the docker group
sudo groupadd docker
sudo usermod -aG docker $USER
# Test Docker installation
docker run hello-world
# Check groups
groups
# Add user to docker group again to ensure changes
sudo usermod -aG docker $USER
# Reboot to apply group changes
sudo reboot
# Check groups after reboot
groups
# Test Docker installation again
docker run hello-world
# Ensure NVIDIA drivers are installed
sudo apt-get install -y nvidia-driver-470
nvidia-smi
# Remove existing NVIDIA Docker installation if any
sudo apt-get purge -y nvidia-docker2
sudo apt-get purge -y nvidia-container-runtime
sudo apt-get autoremove -y
# Add NVIDIA Docker repository GPG key
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
# Set the distribution to Ubuntu 22.04 manually
distribution=ubuntu22.04
# Add the NVIDIA Docker repository
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
# Update package lists
sudo apt-get update
# Install NVIDIA Docker
sudo apt-get install -y nvidia-docker2
# Restart Docker to apply changes
sudo systemctl restart docker
# Test NVIDIA Docker installation with a valid CUDA image
docker run --gpus all nvidia/cuda:11.2.2-base nvidia-smi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment