We have a fresh system, let’s install Docker. Here we are using CentOS 7.5 and logged in as root.
First make sure your date/clock is correct, if not, fix:
1 2 3 |
date +%Y%m%d -s "20180917" date +%T -s "13:39:00" hwclock -w |
Install Docker
1 2 3 4 5 |
yum install -y yum-utils yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo yum install -y docker-ce systemctl start docker systemctl enable docker |
Install NVIDIA Docker
1 2 3 |
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | \ sudo tee /etc/yum.repos.d/nvidia-docker.repo |
Following the README we do:
1 2 3 4 5 6 |
# Install nvidia-docker2 and reload the Docker daemon configuration sudo yum install -y nvidia-docker2 sudo pkill -SIGHUP dockerd # Test nvidia-smi with the latest official CUDA image docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi |
The output of this command should give you something like the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Mon Sep 17 17:51:02 2018 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 396.44 Driver Version: 396.44 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 Tesla P6 Off | 00000000:D8:00.0 Off | 0 | | N/A 32C P0 27W / 90W | 0MiB / 15261MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | No running processes found | +-----------------------------------------------------------------------------+ |
We can now run the python notebook to get started with Tensorflow
1 2 3 |
sudo nvidia-docker run --rm --name tf1 -p 8888:8888 \ -p 6006:6006 tensorflow/tensorflow:latest-gpu \ jupyter notebook --allow-root |
This will give us a session. The session will look something like this:
1 2 3 4 5 6 |
. . . Copy/paste this URL into your browser when you connect for the first time, to login with a token: http://localhost:8888/?token=259f67059411d2fcc806e06c6bd36002b3597c42e64e7b3c |
Take note of the token printed out above. Yours will look different. Since this is running on a server, we will open an SSH tunnel to be able to talk to the Jupyter notebook
1 |
ssh -L 9999:localhost:8888 gpublade |
We can now open our web browser to http://localhost:9999. This will then redirect us to the :8888 port on the server. This way we can access our machine. It will ask us for a token. Now we can put the token that was outputted when we started the docker container.
After entering the token we can go through the Jupyter Notebook Tensorflow tutorials.
Using Docker is a ton easier than installing everything on this server by hand. We did omit some of the nvidia driver setup requirements found in my previous post.
References
https://www.garron.me/en/linux/set-time-date-timezone-ntp-linux-shell-gnome-command-line.html
https://blog.sicara.com/tensorflow-gpu-opencv-jupyter-docker-10705b6cd1d