官术网_书友最值得收藏!

  • Deep Learning Essentials
  • Wei Di Anurag Bhardwaj Jianing Wei
  • 276字
  • 2021-06-30 19:17:50

Setup using Docker

The previous section describes getting started from scratch which can be tricky sometimes given continuous changes to software packages and changing links on the web. One way to avoid dependence on links is to use container technology like Docker.

In this chapter, we will use the official NVIDIA-Docker image that comes pre-packaged with all the necessary packages and deep learning framework to get you quickly started with deep learning application development:

$ sudo add-apt-repository ppa:graphics-drivers/ppa -y
$ sudo apt-get update
$ sudo apt-get install -y nvidia-375 nvidia-settings nvidia-modprobe
  1. We now install Docker Community Edition as follows:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Verify that the key fingerprint is 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
$ sudo apt-key fingerprint 0EBFCD88
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
$ sudo apt-get update
$ sudo apt-get install -y docker-ce
  1. We then install NVIDIA-Docker and its plugin:
$ wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
$ sudo dpkg -i /tmp/nvidia-docker_1.0.1-1_amd64.deb && rm /tmp/nvidia-docker_1.0.1-1_amd64.deb
  1. To validate if the installation happened correctly, we use the following command:
$ sudo nvidia-docker run --rm nvidia/cuda nvidia-smi
  1. Once it’s setup correctly, we can use the official TensorFlow or Theano Docker image:
$ sudo nvidia-docker run -it tensorflow/tensorflow:latest-gpu bash
  1. We can run a simple Python program to check if TensorFlow works properly:
import tensorflow as tf
a = tf.constant(5, tf.float32)
b = tf.constant(5, tf.float32)
with tf.Session() as sess:
sess.run(tf.add(a, b)) # output is 10.0
print("Output of graph computation is = ",output)

You should see the TensorFlow output on the screen now as shown in figure Tensorflow sample output:

Tensorflow sample output
主站蜘蛛池模板: 双峰县| 鹤峰县| 合江县| 潜山县| 望城县| 宝清县| 平乡县| 来宾市| 罗江县| 绩溪县| 华容县| 宜黄县| 义马市| 孝感市| 阿巴嘎旗| 汤原县| 定襄县| 隆尧县| 涟源市| 遵化市| 锦屏县| 饶平县| 安乡县| 秦安县| 五寨县| 南康市| 民勤县| 鹰潭市| 宁波市| 英山县| 吴旗县| 阿图什市| 醴陵市| 东阿县| 甘德县| 三穗县| 辉县市| 红安县| 安泽县| 仙桃市| 两当县|