Docker installs TensorFlow GPU in action

Installation background

AI has sprung up like mushrooms after a rain, and the theory of DEVOPS continues to deepen. All Tall open source products support two environments: docker and Linux. This article mainly explains how to install the tensorflow docker image in a centos7 environment with GPU installed. Students from a few major factories in China can enjoy this advanced environment treatment. If you have this environment, it is recommended to try it. After all, AI can give us one more skill.
Install nvidia-docker

nvidia encapsulates docker and supports nivdia cpu.
For the specific installation process, please refer to:
https://github.com/NVIDIA/nvidia-docker?utm_source=tuicool&utm_medium=referral

The command to use nvidia configuration after installation and play:

[root@~]#
nvidia-nvidia-bug-report.sh nvidia-debugdump nvidia-installer nvidia-settings nvidia-xconfig
nvidia-cuda-mps-control nvidia-docker nvidia-modprobe nvidia-smi              
nvidia-cuda-mps-server nvidia-docker-plugin nvidia-persistenced nvidia-uninstall


if the following Error, indicating that the related service is not started:

[root@ourui]# nvidia-docker run -it -p 8888:8888 tensorflow/tensorflow:latest-gpu
docker: Error response from daemon: create nvidia_driver_367.48: create nvidia_driver_367.48: Error looking up volume plugin nvidia-docker: legacy plugin: plugin not found.
See 'docker run --help'.



使用下面命令查看nvidia-docker 是否启动

root@ourui]# systemctl status nvidia-docker
● nvidia-docker.service - NVIDIA Docker plugin
   Loaded: loaded (/usr/lib/systemd/system/nvidia-docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://github.com/NVIDIA/nvidia-docker/wiki
[root@ourui]# systemctl start nvidia-docker
[root@ourui]# systemctl status nvidia-docker
● nvidia-docker.service - NVIDIA Docker plugin
   Loaded: loaded (/usr/lib/systemd/system/nvidia-docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2017-03-27 10:39:16 CST; 2s ago
     Docs: https://github.com/NVIDIA/nvidia-docker/wiki
  Process: 51649 ExecStartPost=/bin/sh -c /bin/echo unix://$SOCK_DIR/nvidia-docker.sock > $SPEC_FILE (code=exited, status=0/SUCCESS)
  Process: 51644 ExecStartPost=/bin/sh -c /bin/mkdir -p $( dirname $SPEC_FILE ) (code=exited, status=0/SUCCESS)
 Main PID: 51643 (nvidia-docker-p)
   Memory: 13.9M
   CGroup: /system.slice/nvidia-docker.service
           └─51643 /usr/bin/nvidia-docker-plugin -s /var/lib/nvidia-docker

Mar 27 10:39:16 ctum2e1302005.idc.wanda-group.net systemd[1]: Starting NVIDIA Docker plugin...
Mar 27 10:39:16 ctum2e1302005.idc.wanda-group.net systemd[1]: Started NVIDIA Docker plugin.

This step installs the basic nvidia docker environment. It should be noted that nvidia does not provide the latest version of the docker release, if you need to test the latest docker release version, you need to use other methods.
Download docker images

The tensorflow community provides a set of images download addresses on docker hub:
https://hub.docker.com/r/tensorflow/tensorflow/

For reasons we all know, sometimes it is a problem to download images from docker hub in China . I reminded me of a sentence: This is the best of times and the worst of times. Find a way to get your own mortgage!

There are many docker hubs in China. Of course, you can directly use the domestic docker hub, and also provide some accelerators. You understand the so-called acceleration. Let's take a look at using Aliyun accelerator:

https://yq.aliyun.com/articles/29941

After setting, you can download docker iamges directly

nvidia-docker pull tensorflow/tensorflow:latest-gpu

 

start container

[root@ourui]# nvidia-docker run -it -d -p  8888:8888 tensorflow/tensorflow:latest-gpu 
69fede4460082f3e4aa847fc34ac0f58e797dc44b10d65643a70d2a1e7e4ba03
[root@ourui]#
[root@ourui]# nvidia-docker logs 69fede4460082f3e4aa847fc34ac0f58e797dc44b10d65643a70d2a1e7e4ba03
[I 02:45:08.016 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 02:45:08.031 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 02:45:08.037 NotebookApp] Serving notebooks from local directory: /notebooks
[I 02:45:08.037 NotebookApp] 0 active kernels
[I 02:45:08.037 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/?token=f1d1717e2fdbf8c1807f5017315396be05a6b95310d87cb9
[I 02:45:08.038 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 02:45:08.038 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=f1d1717e2fdbf8c1807f5017315396be05a6b95310d87cb9

测试

打开web:
http://ip:8888/?token=f1d1717e2fdbf8c1807f5017315396be05a6b95310d87cb9

这里写图片描述
这里写图片描述  

http://blog.csdn.net/u011291159/article/details/66970202

https://github.com/NVIDIA/nvidia-docker

https://hub.docker.com/r/tensorflow/tensorflow/

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326959854&siteId=291194637