In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you the relevant knowledge points about how to build the CentOS7 Nvidia Docker environment. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Environment:
System: centos7 7.4 1708
Video card: nvidia 1080ti
Download everything you need
1 、 docker-ce yum repo:
2 、 nvidia-docker yum repo:
3 、 nvidia cuda yum repo:
4 、 nvidia cudnn:
This thing needs to sign up for a nvidia account, so you won't give it a direct download address.
5. Nvidia driver: http://www.nvidia.cn/download/index.aspx?lang=cn
Download according to your video card model
6 、 nvidia docker file:
You can see a lot of dockerfile here, choose
9.0-base-centos7 (9.0/base/dockerfile)
Other cuda9.1 these should also be available, in addition, such as devel and runtime, in fact, the cuda package installed by yum is not the same, it doesn't matter much.
Click in and copy it and save it as a dockerfile file, but when you do it later, you find something wrong. You can copy it here.
From centos:7label maintainer "nvidia corporation" run nvidia_gpgkey_sum=d1be581509378368edeec8c1eb2958702feedf3bc3d17011adbf24efacce4ab5 & &\ curl-fssl https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/7fa2af80.pub | sed'/ ^ version/d' > / etc/pki/rpm-gpg/rpm-gpg-key-nvidia & &\ echo "$nvidia_gpgkey_sum / etc/pki/rpm-gpg/rpm-gpg-key-nvidia" | sha256sum-c-strict-# copy cuda.repo / etc/ Yum.repos.d/cuda.repoenv cuda_version 9.0.176env cuda_pkg_version 9-0-$cuda_version-1#run yum install-y\ # cuda-cudart-$cuda_pkg_version & &\ # ln-s cuda-9.0 / usr/local/cuda & &\ # rm-rf / var/cache/yum/*# nvidia-docker 1.0label com.nvidia.volumes.needed= "nvidia_driver" label com.nvidia.cuda.version= "${cuda_version } "run echo" / usr/local/nvidia/lib "> > / etc/ld.so.conf.d/nvidia.conf & &\ echo" / usr/local/nvidia/lib64 "> > / etc/ld.so.conf.d/nvidia.confenv path / usr/local/nvidia/bin:/usr/local/cuda/bin:$ {path} env ld_library_path / usr/local/nvidia/lib:/usr/local/nvidia/lib64# nvidia-container-runtimeenv nvidia_visible_devices allenv nvidia_driver_capabilities compute Utilityenv nvidia_require_cuda "cuda > = 9.0"
All the files.
[root@localhost nvidia] # pwd/root/nvidia [root@localhost nvidia] # lltotal 420000drwxr-xr-x. 2 root root 4096 feb 10 10:50 centos-gpu-rw-r--r--. 1 root root 3335 jan 29 10:36 cuda-repo-rhel7-9.1.85-1.x86 colors 64.rpmWhrwMui. 1 root root 348817823 feb 6 16:26 cudnn-9.0-linux-x64-v7.tgz-rw-r--r--. 1 root root 2424 feb 9 10:36 docker-ce.repo-rw-r--r--. 1 root root 796 feb 9 17:11 nvidia-docker.repo-rwxr-xr-x. 1 root root 81242220 jan 31 14:19 nvidia-linux-x86_64-390.25.run
There are dockerfile files in centos-gpu.
Preparatory work
Give the order directly and you can understand it at a glance.
[root@localhost nvidia] # cp docker-ce.repo nvidia-docker.repo / etc/yum.repos.d/ [root@localhost nvidia] # rpm-ivh cuda-repo-rhel7-9.1.85-1.x8664.rpm [root @ localhost nvidia] # yum install epel-release [root@localhost nvidia] # yum install gcc gcc-c++ [root@localhost nvidia] # yum install kernel*
Install the driver
[root@localhost nvidia] # echo "blacklist nouveau" > > / etc/modprobe.d/blacklist.conf [root@localhost nvidia] # mv / boot/initramfs-$ (uname-r). Img / boot/initramfs-$ (uname-r). Img.bak dracut-v / boot/initramfs-$ (uname-r). Img $(uname-r) [root@localhost nvidia] # init 3 [root@localhost nvidia] # chmod + x nvidia-linux-x86_64-390.25.run [root@localhost nvidia] # . / nvidia-linux-x86_64-390.25.run
This is the approximate step. If there is a problem, you can look for it directly on the Internet. It should not be too difficult.
Install and start docker
[root@localhost nvidia] # yum install docker-ce nvidia-docker [root@localhost nvidia] # systemctl enable docker [root@localhost nvidia] # systemctl start docker [root@localhost nvidia] # systemctl enable nvidia-docker [root@localhost nvidia] # systemctl start nvidia-docker
Remember that the graphics card driver must be installed before the nvidia-docker can start normally.
Make a docker image
[root@localhost nvidia] # yum install cuda-cudart-9-0-9.0.176-1 [root@localhost nvidia] # ln-s cuda-9.0 / usr/local/cuda [root@localhost nvidia] # nvidia-docker build-t centos-nvidia / root/nvidia/centos-gpu
If you are using my modified dockfile, there should be no problem. If you are using the original version, it may be in the
# copy cuda.repo / etc/yum.repos.d/cuda.repo
Error, but we have downloaded repo for cuda and installed it, so this step can be avoided.
After the image production is finished, you can check it with the command docker images:
[root@localhost centos-gpu] # docker imagesrepository tag image id created sizecentos-nvidia latest a02c8e0ad5ca 2 hours ago 207mb
If there is such a business, it should be considered a success.
Generate docker
[root@localhost centos-gpu] # nvidia-docker run-- name= "centos-gpu2"-- ti a02c / bin/bash [root@34d532e76913 /] # nvidia-smi sat feb 10 03:42:20 2018 +- -+ | nvidia-smi 390.25 driver version: 390.25 | |-- + | gpu name persistence-m | bus-id disp.a | volatile uncorr. Ecc | | fan temp perf pwr:usage/cap | memory-usage | gpu-util compute m. | | = = + = | 0 geforce gtx 108. Off | 0000000010mib 0210mib 00.0 off | Numbera | | 23% 17c p8 8w / 250w | 10mib / 11178mib | 0% default | +-- + +-- + | processes: gpu memory | | gpu pid type process Name usage | | = = | | no running processes found | +-+ [root@34d532e76913 /] # exit
If it's similar to the output above, it's almost fine.
Use docker
[root@localhost centos-gpu] # nvidia-docker ps-acontainer id image command created status ports names34d532e76913 a02c "/ bin/bash" 3 minutes ago exited (0) 12 seconds ago centos-gpu2d16c2db2bf2e a02c "/ bin/bash" 2 hours ago exited (0) 19 minutes ago centos-gpu370671db8df1 3afd "/ bin/bash" 19 hours ago exited 3 hours ago centos-dronemap [root@localhost centos-gpu] # nvidia-docker start 34d534d5 [root@localhost centos-gpu] # nvidia-docker cp / root/nvidia/cuda-repo-rhel7-9.1.85-1.x86_64.rpm 34d532e76913:/root [root@localhost centos-gpu] # nvidia-docker exec-ti 34d5 / bin/bash [root@34d532e76913 /] # cd [root@34d532e76913 ~] # lsanaconda-ks.cfg cuda-repo-rhel7 -9.1.85-1.x8664.rpm [root @ 34d532e76913 ~] # rpm-ivh cuda-repo-rhel7-9.1.85-1.x86_64.rpm warning: cuda-repo-rhel7-9.1.85-1.x86_64.rpm: header v3 rsa/sha512 signature Key id 7fa2af80: nokeypreparing... # # [100%] updating / installing... 1:cuda-repo-rhel7-9.1.85-1 # # [root@34d532e76913] # yum install cuda-*9-0 *
It is important to note that numbers like 34d532e76913 are automatically generated by docker and need to be modified at run time.
So far, basically, the environment for cuda has been set up.
Tensorflow
Copy the downloaded cudnn package to docker with docker cp, unzip it, add the lib64 path inside to / etc/ld.so.conf.d/nvidia.conf, run ldconfig, and ok.
After the above environment is good, install python and other software, this is not to say. Then some examples of tensorflow can be run in docker. Of course, you have to install the gpu version in order to exert the power of the graphics card.
In addition, there is no need to be so troublesome. There are already made images that can be used. Please refer to:
Other
In addition, ready-made cuda images are also available. Refer to:
Directly use the command: docker pull nvidia/cuda can download the image, but this is the ubuntu version, and our build environment does not match, if you want other versions can refer to the above example.
These are all the contents of the article "how to build a CentOS7 Nvidia Docker Environment". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.