Assuming you are running Ubuntu 20.04 LTS, you will need CUDA 11.2, nvidia-docker and a few other dependencies.
CUDA 11.2
Begin with downloading the deb file from the CUDA repository based on your platform.
Once you have selected your platform appropriately, you will be provided installation commands. If your platform is similar to that of mine, you can install it as follows —
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pinsudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600wget https://developer.download.nvidia.com/compute/cuda/11.2.1/local_installers/cuda-repo-ubuntu2004-11-2-local_11.2.1-460.32.03-1_amd64.debsudo dpkg -i cuda-repo-ubuntu2004-11-2-local_11.2.1-460.32.03-1_amd64.debsudo apt-key add /var/cuda-repo-ubuntu2004-11-2-local/7fa2af80.pubsudo apt updatesudo apt -y install cudasudo reboot
If done right, you should have the following output when you run nvidia-smi
Docker
Docker is a platform that helps in the containerization of apps by providing OS-level virtualization.
First, uninstall any older versions you may have lingering on your device —
sudo apt-get remove docker docker-engine docker.io containerd runc
Get dependencies that will allow you to use the apt
repository
sudo apt-get updatesudo apt-get install
apt-transport-https
ca-certificates
curl
gnupg
Add docker’s official GPG key
curl -fsSL https://downloads.docker.com/linux/ubuntu/gpg | sudo gpg — dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Add the repository to apt
echo
"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
Now, install the docker-engine
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
Verify by running the hello-world container
sudo docker run hello-world
If done correctly, you should see an output like so —
Psst! Let’s remove the need for using sudo
with docker commands
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
With this, you will no longer find the need for super-user control when using docker!
nvidia-docker2
nvidia-docker2 helps to bridge the GPU to docker containers.
distribution=ubuntu20.04curl -s -L https://nvidia.github.io/nvidia-container-runtime/experimental/$distribution/nvidia-container-runtime.list | sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.listsudo apt-get updatesudo apt-get install -y nvidia-docker2sudo systemctl restart dockersudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
TLT Python packages
These python packages help in pulling containers and mounting targets.
sudo apt install python3-dev python3-pip
pip3 install nvidia-pyindex
pip3 install nvidia-tlt
pip3 install jupyter
NVIDIA container registry login
This step is vital to access containers from NVIDIA. Sign up at https://ngc.nvidia.com/signin and generate an API Key to login.
docker login nvcr.io
Enter your username as $oauthtoken
and for password use your NGC API Key.
This marks the end of setting up dependencies. Now you should be all set to get your hands dirty and train models!