# 21.Centos安装cuda和docker等工具

  1. 下载驱动程序 versionNvidia=<版本号>

wget http://xxxx/www/upload/NVIDIA-Linux-x86_64-${versionNvidia}.run -P /root/initial

  1. 安装依赖
  • modprobe -r nvidia
  • modprobe -r nvidia-uvm
  • modprobe -r nvidia_drm
  • modprobe -r nvidia-modeset

echo -e "blacklist nouveau\noptions nouveau modeset=0" > /etc/modprobe.d/blacklist.conf #dracut -v /boot/initramfs-$(uname -r).img $(uname -r) --force

ERROR: Unable to find the development tool cc in your path; please make sure that you have the package 'gcc' installed. If gcc is installed on your system, then please check that cc is in your PATH.

这个命令会安装gcc、cpp等软件包

rpm -q dkms || yum -y install dkms

ERROR: Unable to find the kernel source tree for the currently running kernel. Please make sure you have installed the kernel source files for your kernel and that they are properly configured; on Red Hat Linux systems, for example, be sure you have the 'kernel-source' or 'kernel-devel' RPM installed. If you know the correct kernel source files are installed, you may specify the kernel source path with the '--kernel-source-path' command line option. rpm -q kernel-source || yum install kernel-source-$(uname -r) rpm -q kernel-devel || yum install kernel-devel-$(uname -r) bash /root/initial/NVIDIA-Linux-x86_64-${versionNvidia}.run --silent 如果找不到对应版本的kernel-devel,可以直接安装新版本

yum install kernel kernel-devel kernel-headers kernel-tools
reboot
1
2
  1. 安装二进制程序
bash /root/initial/NVIDIA-Linux-x86_64-${versionNvidia}.run -k $(uname -r) --silent
1

# nvidia驱动的Persistence-M是持续模式 。Persistence-M默认关闭,开启后能够让GPU更快响应任务,但待机功耗增加。

nvidia-smi -pm 1
nvidia-smi --query-gpu=driver_version --format=csv,noheader
1
2
  1. 安装docker-ce和nvidia-docker2

install docker

rpm -ivh http://xxx.xxx.xxx.xxx/www/packages/docker-ce-18.06.3/container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm --nodeps &> /dev/null
rpm -ivh http://xxx.xxx.xxx.xxx/www/packages/docker-ce-18.06.3/docker-ce-18.06.3.ce-3.el7.x86_64.rpm  --nodeps &> /dev/null
# install nvidia-docker2
rpm -ivh http://xxx.xxx.xxx.xxx/www/upload/libnvidia-container1-1.4.0-1.x86_64.rpm --nodeps &> /dev/null
rpm -ivh http://xxx.xxx.xxx.xxx/www/upload/libnvidia-container-tools-1.4.0-1.x86_64.rpm --nodeps &> /dev/null
rpm -ivh http://xxx.xxx.xxx.xxx/www/upload/nvidia-container-runtime-2.0.0-3.docker18.06.3.x86_64.rpm --nodeps &> /dev/null
rpm -ivh http://xxx.xxx.xxx.xxx/www/upload/nvidia-container-toolkit-1.5.0-2.x86_64.rpm --nodeps &> /dev/null
rpm -ivh http://xxx.xxx.xxx.xxx/www/upload/nvidia-docker2-2.0.3-3.docker18.06.3.ce.noarch.rpm --nodeps &> /dev/null
1
2
3
4
5
6
7
8

config docker-ce

mkdir -p /etc/docker/ /data/docker
cat > /etc/docker/daemon.json  <<EOF
{
    "data-root":"/data/docker",
    "exec-opts": ["native.cgroupdriver=systemd"],
    "storage-driver": "overlay2",
    "storage-opts": [
      "overlay2.override_kernel_check=true"
    ],
    "log-driver":"json-file",
    "log-opts":{
        "max-size":"1024m",
        "max-file":"3"
    },
    "registry-mirrors":[
        "https://pqbap4ya.mirror.aliyuncs.com"
    ],
    "live-restore":true,
    "default-runtime": "nvidia",
    "runtimes": {
        "nvidia": {
            "path": "/usr/bin/nvidia-container-runtime",
            "runtimeArgs": []
        }
    }
}
EOF
systemctl restart docker

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  1. 安装docker-compse

参考文章 How To Install and Use Docker Compose on CentOS 7 (opens new window)



Last Updated: 5/6/2024, 7:34:57 PM
Apache License 2.0 | Copyright © 2022 by xueliang.wu 苏ICP备15016087号