Ubuntu 20.04 Nvidia P400 passthrough GPU with Docker

tech tutorialLeave a Comment on Ubuntu 20.04 Nvidia P400 passthrough GPU with Docker

Ubuntu 20.04 Nvidia P400 passthrough GPU with Docker

UPDATE

Latest steps I took to get p400 working with Ubuntu 22.04 and docker

sudo apt-get remove --purge '^nvidia-.*'
sudo apt-get remove --purge '^libnvidia-.*'
sudo apt-get remove --purge '^cuda-.*'
sudo apt autoremove
sudo reboot
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin

sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600

wget https://developer.download.nvidia.com/compute/cuda/12.0.0/local_installers/cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb

sudo dpkg -i cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb

sudo cp /var/cuda-repo-ubuntu2204-12-0-local/cuda-852BBB4F-keyring.gpg /usr/share/keyrings/

sudo apt-get update
sudo apt-get -y install cuda
sudo reboot
nvidia-smi
nvtop

Commands I used to get my Quadro P400 to work in ubuntu 20.04 on top of ESXI

#get docker setup
sudo apt-get install     apt-transport-https     ca-certificates     curl     gnupg     lsb-releaseecho   "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update
sudo docker stats
sudo groupadd dockersudo usermod -aG docker mike
exit
docker stats
sudo apt intsall docker-compose
reboot
sudo lshw -c Video
#config and build tools for drivers
sudo apt-get install qemu-guest-agent
 
# this is optional if you are virtualizing this machine
sudo apt-get install build-essential 

# build-essential is required for nvidia drivers to compile
#nvidia drivers and docker stuff
sudo apt install --no-install-recommends nvidia-cuda-toolkit nvidia-headless-450 nvidia-utils-450 libnvidia-encode-450
reboot
sudo apt install nvtop

curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update

sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo apt-get install nvidia-container-runtime
sudo apt-get install -y nvidia-docker2
cd /etc/docker 
sudo vi daemon.json
{  "default-runtime": "nvidia",  "runtimes": {    "nvidia": {      "path": "/usr/bin/nvidia-container-runtime",      "runtimeArgs": []    }  }}

#stop kernel from updating
sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic

Process to fix nvtop when it stops showing the gpu

# check if card is still visible `sudo lshw -c Video`

# sudo apt-mark unhold linux-generic linux-image-generic linux-headers-generic
# sudo apt update && sudo apt upgrade
# sudo reboot
# sudo apt remove *nvidia* #remove all nvidia packages
# sudo apt autoremove
# sudo reboot
# sudo apt install --no-install-recommends nvidia-cuda-toolkit nvidia-headless-450 nvidia-utils-450 libnvidia-encode-450
# sudo apt install nvtop# sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
# sudo apt-get install nvidia-container-runtime# sudo apt-get install -y nvidia-docker2
# nvtop #if it sees the gpu we are done

Leave a Reply

Back To Top