Configuration Steps
- Install Ubuntu
2. Install Nvidia Driver
From: https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-ubuntu-18-04-bionic-beaver-linux
sudo ubuntu-drivers autoinstall
3. Install Docker
Ref: https://docs.docker.com/engine/install/ubuntu/
Update the apt
package index:
$ sudo apt-get update$ sudo apt-get install \
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 that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
, by searching for the last 8 characters of the fingerprint.
$ sudo apt-key fingerprint 0EBFCD88
Set up the stable repository:
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
Install Docker Engine:
Update the apt
package index, and install the latest version of Docker Engine and containerd:
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
4. Install NVIDIA Docker support
For NVIDIA drivers to work inside a docker, NVIDIA Docker support need to be installed in the host machine.
Add the package repositories:
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
Update apt and install:
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
Restart Docker:
sudo systemctl restart docker
Reboot!
Otherwise this error will show up: https://github.com/NVIDIA/nvidia-docker/issues/1281
5. Download and run TensorFlow docker image
Find a suitable TensorFlow docker image from https://hub.docker.com/r/tensorflow/tensorflow/ and download.
$ sudo docker pull tensorflow/tensorflow:2.2.0-gpu-jupyter
Once the download is complete you can run the image with appropriate options and arguments.
$ sudo docker run -it --rm --gpus all -v $(realpath /notebooks):/tf/notebooks -p 8888:8888 tensorflow/tensorflow:2.2.0-gpu-jupyter
The above command, on successful execution, will fire up a docker container with access to all the GPUs of the host system, /notebooks directory of the host acting as the /tf/notebooks directory of the container and 8888 ports of the host and the container bridged (Jupyter notebooks work on port 8888 by default). Now you can start a notebook by simply opening the host ip in a browser.
6. Run Jupyter notebook
Open notebook in browser:
Open the url 127.0.0.1:8888 in a browser and copy and paste the token of the jupyter instance from the terminal onto the “Password or Token” input box of the page to open the notebook.