{"id":3647,"date":"2018-09-17T12:57:29","date_gmt":"2018-09-17T18:57:29","guid":{"rendered":"http:\/\/benincosa.com\/?p=3647"},"modified":"2018-09-18T15:01:42","modified_gmt":"2018-09-18T21:01:42","slug":"docker-based-jupyter-notebook-on-b200-m5-with-tesla-p6","status":"publish","type":"post","link":"https:\/\/benincosa.com\/?p=3647","title":{"rendered":"Docker based Jupyter Notebook on B200 M5 with Tesla P6"},"content":{"rendered":"<p>We have a fresh system, let&#8217;s install Docker.\u00a0 Here we are using CentOS 7.5 and logged in as root.<\/p>\n<p>First make sure your date\/clock is correct, if not, fix:<\/p>\n<pre class=\"lang:sh decode:true\">date +%Y%m%d -s \"20180917\"\r\ndate +%T -s \"13:39:00\"\r\nhwclock -w<\/pre>\n<p>Install Docker<\/p>\n<pre class=\"lang:sh decode:true\">yum install -y yum-utils\r\nyum-config-manager --add-repo https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo\r\nyum install -y docker-ce\r\nsystemctl start docker\r\nsystemctl enable docker<\/pre>\n<p>Install <a href=\"https:\/\/github.com\/NVIDIA\/nvidia-docker\">NVIDIA Docker<\/a><\/p>\n<pre class=\"lang:sh decode:true \">distribution=$(. \/etc\/os-release;echo $ID$VERSION_ID)\r\ncurl -s -L https:\/\/nvidia.github.io\/nvidia-docker\/$distribution\/nvidia-docker.repo | \\\r\n  sudo tee \/etc\/yum.repos.d\/nvidia-docker.repo<\/pre>\n<p>Following the README we do:<\/p>\n<pre class=\"lang:sh decode:true \"># Install nvidia-docker2 and reload the Docker daemon configuration\r\nsudo yum install -y nvidia-docker2\r\nsudo pkill -SIGHUP dockerd\r\n\r\n# Test nvidia-smi with the latest official CUDA image\r\ndocker run --runtime=nvidia --rm nvidia\/cuda nvidia-smi<\/pre>\n<p>The output of this command should give you something like the following:<\/p>\n<pre class=\"lang:sh decode:true \">Mon Sep 17 17:51:02 2018\r\n+-----------------------------------------------------------------------------+\r\n| NVIDIA-SMI 396.44                 Driver Version: 396.44                    |\r\n|-------------------------------+----------------------+----------------------+\r\n| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |\r\n| Fan  Temp  Perf  Pwr:Usage\/Cap|         Memory-Usage | GPU-Util  Compute M. |\r\n|===============================+======================+======================|\r\n|   0  Tesla P6            Off  | 00000000:D8:00.0 Off |                    0 |\r\n| N\/A   32C    P0    27W \/  90W |      0MiB \/ 15261MiB |      0%      Default |\r\n+-------------------------------+----------------------+----------------------+\r\n\r\n+-----------------------------------------------------------------------------+\r\n| Processes:                                                       GPU Memory |\r\n|  GPU       PID   Type   Process name                             Usage      |\r\n|=============================================================================|\r\n|  No running processes found                                                 |\r\n+-----------------------------------------------------------------------------+<\/pre>\n<p>We can now run the python notebook to get started with Tensorflow<\/p>\n<pre name=\"d97a\" id=\"d97a\" class=\"graf graf--pre graf-after--p \">sudo nvidia-docker run --rm --name tf1 -p 8888:8888 \\\r\n   -p 6006:6006 tensorflow\/tensorflow:latest-gpu \\\r\n   jupyter notebook --allow-root<\/pre>\n<p>This will give us a session.\u00a0 The session will look something like this:<\/p>\n<pre class=\"lang:sh decode:true\">.\r\n.\r\n.\r\nCopy\/paste this URL into your browser when you connect for the first time,\r\n    to login with a token:\r\n        http:\/\/localhost:8888\/?token=259f67059411d2fcc806e06c6bd36002b3597c42e64e7b3c<\/pre>\n<p>Take note of the token printed out above.\u00a0 Yours will look different.\u00a0 Since this is running on a server, we will open an SSH tunnel to be able to talk to the Jupyter notebook<\/p>\n<pre class=\"lang:sh decode:true \">ssh -L 9999:localhost:8888 gpublade<\/pre>\n<p>We can now open our web browser to http:\/\/localhost:9999.\u00a0 This will then redirect us to the :8888 port on the server.\u00a0 This way we can access our machine.\u00a0 It will ask us for a token.\u00a0 Now we can put the token that was outputted when we started the docker container.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-3648\" src=\"http:\/\/benincosa.com\/wp-content\/uploads\/2018\/09\/Screen-Shot-2018-09-17-at-11.49.45-AM-300x252.png\" alt=\"\" width=\"300\" height=\"252\" srcset=\"https:\/\/benincosa.com\/wp-content\/uploads\/2018\/09\/Screen-Shot-2018-09-17-at-11.49.45-AM-300x252.png 300w, https:\/\/benincosa.com\/wp-content\/uploads\/2018\/09\/Screen-Shot-2018-09-17-at-11.49.45-AM.png 616w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>After entering the token we can go through the Jupyter Notebook Tensorflow tutorials.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-3649\" src=\"http:\/\/benincosa.com\/wp-content\/uploads\/2018\/09\/Screen-Shot-2018-09-17-at-11.50.06-AM-300x90.png\" alt=\"\" width=\"300\" height=\"90\" srcset=\"https:\/\/benincosa.com\/wp-content\/uploads\/2018\/09\/Screen-Shot-2018-09-17-at-11.50.06-AM-300x90.png 300w, https:\/\/benincosa.com\/wp-content\/uploads\/2018\/09\/Screen-Shot-2018-09-17-at-11.50.06-AM-768x230.png 768w, https:\/\/benincosa.com\/wp-content\/uploads\/2018\/09\/Screen-Shot-2018-09-17-at-11.50.06-AM-1024x306.png 1024w, https:\/\/benincosa.com\/wp-content\/uploads\/2018\/09\/Screen-Shot-2018-09-17-at-11.50.06-AM.png 1184w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>Using Docker is a ton easier than installing everything on this server by hand.\u00a0 We did omit some of the nvidia driver setup requirements found in <a href=\"http:\/\/benincosa.com\/?p=3641\">my previous post<\/a>.<\/p>\n<h2>References<\/h2>\n<p><a href=\"https:\/\/www.garron.me\/en\/linux\/set-time-date-timezone-ntp-linux-shell-gnome-command-line.html\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.garron.me\/en\/linux\/set-time-date-timezone-ntp-linux-shell-gnome-command-line.html<\/a><\/p>\n<p><a href=\"https:\/\/medium.com\/@lucasrg\/using-jupyter-notebook-running-on-a-remote-docker-container-via-ssh-ea2c3ebb9055\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/medium.com\/@lucasrg\/using-jupyter-notebook-running-on-a-remote-docker-container-via-ssh-ea2c3ebb9055<\/a><\/p>\n<p><a href=\"https:\/\/blog.sicara.com\/tensorflow-gpu-opencv-jupyter-docker-10705b6cd1d\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/blog.sicara.com\/tensorflow-gpu-opencv-jupyter-docker-10705b6cd1d<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have a fresh system, let&#8217;s install Docker.\u00a0 Here we are using CentOS 7.5 and logged in as root. First make sure your date\/clock is correct, if not, fix: date +%Y%m%d -s &#8220;20180917&#8221; date +%T -s &#8220;13:39:00&#8221; hwclock -w Install Docker yum install -y yum-utils yum-config-manager &#8211;add-repo https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo yum install -y docker-ce systemctl start docker&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[856,857,478,638],"tags":[991,858,860,859,861],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/3647"}],"collection":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3647"}],"version-history":[{"count":5,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/3647\/revisions"}],"predecessor-version":[{"id":3656,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/3647\/revisions\/3656"}],"wp:attachment":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}