Installing a Docker container that uses nvidia-docker--to use the GPU

Source: Internet
Author: User
Tags nvidia docker

nvidia-dockeris a can be GPU used docker , nvidia-docker is docker done in a layer of encapsulation, through nvidia-docker-plugin , and then call to docker on, its final implementation or on docker the start command to carry some necessary parameters. This is why you need to install it before you install it nvidia-docker docker .

dockeris generally based on CPU the use of applications, and if GPU so, you need to install a unique hardware environment, such as the need to install nvidia driver . So docker containers are not directly supported Nvidia GPU . To solve this problem, the earliest way to do this is to reinstall it all inside the container and nvidia driver then start it by setting the appropriate device parameters container , but this approach is fragile. Because the host's driver version must exactly match the version within the container, which leads to the driver docker image inability to share, it is likely that the inconsistency of the local machine causes each machine to repeat its operation, which is a big violation docker of the design.

In order to make it easy to docker image use Nvidia GPU , which is produced nvidia-docker by it, it nvidia driver image is required to start on the target machine, to container ensure that the character device and the driver file has been mounted.

nvidia-docker-pluginis one docker plugin that is used to help us easily deploy container to GPU mixed environments. Similar to a daemon, discovers host drive files and GPU devices, and mounts them to docker守护进程 requests from. To support docker GPU the use of this.

Software docker that needs to be installed well in advance

Because Nvidia Docker runs on a docker basis, native Docker needs to be installed.

1.12.6Version of the docker installation can be viewed in this article: Docker installation using commands. Http://www.linuxidc.com/Linux/2017-12/149575.htm

Docker CEVersion to see this article: Docker CE installation tutorial. Http://www.linuxidc.com/Linux/2017-12/149576.htm

NVIDIA Graphics drivers

There is no doubt that, to be used GPU , the graphics driver must be installed to nvidia docker run properly.

How to install the graphics driver view this article: CentOS Integrated gtx-1080ti Graphics to build a deep learning environment throughout the process. Http://www.linuxidc.com/Linux/2017-12/149577.htm

This article explains the CentOS installation of video cards to build a deep learning environment of the entire process, graphics driver is one of the work, so here is not alone, this article has the installation process.

Installing NVIDIA Docker

1. Download nvidia-docker.repo the file and export the file to/etc/yum.repos.d/nvidia-docker.repo

curl -s -L https://nvidia.github.io/nvidia-docker/centos7/x86_64/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo 

Operation Result:

2. Find an installable nvidia docker version

yum search --showduplicates nvidia-docker

Running the above statement, you will see the information in the diagram below, one clicky

The final output is shown below:

You can choose the version you want to install nvidia docker , and here I install the docker 1.12.6 version. So I chose to install the countdown to the first version nvidia docker .

3. Installationnvidia-docker

install nvidia-docker-1.0.1-1.x86_64

Click Enter, the system will be installed nvidia-docker , you need to select yes\no the place input y , and then click Enter, the final installation success.

Running Nvidia Docker

1. Operation docker :

// 运行dockersystemctl start docker// 加入开机启动systemctl enable docker// 查看状态systemctl status coker

2. Operation nvidia-docker :

systemctl start nvidia-dockersystemctl enable nvidia-dockersystemctl status nvidia-docker

nvidia-dockerOperation commands are the docker same as the basic, so there is no obstacle to operation.

Kubernetes calling the GPU

Yaml file configuration:

apiversion:v1kind:podmetadata:name:gpu-testspec : volumes:- name:nvidia-driver Hostpath:path:/var/lib/nvidia-do cker/volumes/nvidia_driver/384.69- name:cgroup Hostpath:path:/sy S/fs/cgroup containers:- name:tensorflow Image:tensorflow:0.11.0-gpu Ports:- containerport: 8000 resources: Limits:alpha.kubernetes.io/nvidia-gpu:1 volumemounts:- name: Nvidia-driver Mountpath:/usr/local/nvidia/readonly:true- name: Cgroup Mountpath:/sys/fs/cgroup            
    1. alpha.kubernetes.io/nvidia-gpu: 1: Indicates that only 1 GPUs are used

    2. path: /var/lib/nvidia-docker/volumes/nvidia_driver/384.69: Host driver location, installed nvidia-docker after some, of course, it is necessary to ensure that the host nvidia driver is installed OK, should be installed nvidia-docker , will find the host driver , and then mapped to this.

    3. path: /sys/fs/cgroup: Mounting The directory is also to identify the video card so that the host card can be used inside the container.

    4. volumeMounts: Mount the host directory inside the container, the configuration item under this tab is to mount the host directory to the directory inside the container, through the name identity.

With these directory mount configurations, after the pod is started, the container will be able to recognize the GPU and work properly.

For more information about Docker tutorials, see the following :

Docker installation Application (CentOS 6.5_x64) http://www.linuxidc.com/Linux/2014-07/104595.htm

The Ubuntu 16.04 server is configured to use Docker http://www.linuxidc.com/Linux/2017-06/145176.htm

Install Docker http://www.linuxidc.com/Linux/2015-07/120444.htm under Ubuntu 15.04

Docker Installation Instance http://www.linuxidc.com/Linux/2017-04/142666.htm

Docker Create base image http://www.linuxidc.com/Linux/2017-05/144112.htm

How to install Docker and basic usage on Ubuntu 15.04 http://www.linuxidc.com/Linux/2015-09/122885.htm

Ubuntu 16.04 on the use of Docker http://www.linuxidc.com/Linux/2016-12/138490.htm

Use Docker to start a common application in minutes http://www.linuxidc.com/Linux/2017-04/142649.htm

Ubuntu 16.04 Under Docker Modify configuration file does not take effect workaround http://www.linuxidc.com/Linux/2017-05/143862.htm

more about Docker : please click here
Docker's : please click here

This article permanently updates the link address : http://www.linuxidc.com/Linux/2017-12/149578.htm

Install a Docker container that uses nvidia-docker--to use the GPU

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.