Loading

ubuntu1804 安装Nvidia驱动-nvidia-docker

操作

看显卡


lspci | grep  N
01:00.0 3D controller: NVIDIA Corporation GM107M [GeForce GTX 960M] (rev a2)
07:00.0 Network controller: Intel Corporation Dual Band Wireless-AC 3165 Plus Bluetooth (rev 99)


ubuntu-drivers devices
lshw -numeric -C display

驱动下载
https://www.nvidia.com/Download/index.aspx?lang=en-us
http://www.nvidia.cn/Download/driverResults.aspx/156091/cn

删除原有驱动

 sudo apt-get remove --purge nvidia*


#sudo apt-get purge bumblebee* bbswitch-dkms

禁用nouveau驱动

sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf
sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"

看是否成功禁用了开源驱动

cat /etc/modprobe.d/blacklist-nvidia-nouveau.conf
blacklist nouveau
options nouveau modeset=0

禁用nouveau生效

 sudo update-initramfs -u 

重启

reboot


lsmod | grep nouveau
#看是否成功

获取相应的kernel

https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements

$ apt-get install linux-source  gcc
$ apt-get install linux-headers-4.15.0-38-generic

$cat /proc/version

进入命令行操作

重启成功后打开终端,输入如下命令:sudo telinit 3。然后按快捷键:CTRL+ALT+F1 进入字符界面,输入用户名和密码,然后登录系统,进入我们保存下载 NVIDIA 驱动的目录,默认是:Downloads/ 目录,cd Downloads/,然后执行:bash NVIDIA-Linux-x86_64-418.43.bin。注意:NVIDIA-Linux-x86_64-418.43.bin 要根据你下载的驱动文件的名字相应改动。

#安装

$ sudo chmod +x NVIDIA-Linux-x86_64-410.66.run 
$ sudo ./NVIDIA-Linux-x86_64-410.66.run 


报错没有32bite-libriaries ,选择继续安装,然后出现下图


选择中间的选项

检查

$ nvidia-smi

nvidia-docker

先安装docker
https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/amd64/

# 更新源
$ sudo apt update

# 启用HTTPS
$ sudo apt install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

# 添加GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# 添加稳定版的源
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"


# 更新源
$ sudo apt update

# 安装Docker CE
$ sudo apt install -y docker-ce



配置nvidia-docker

# 添加源
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list

# 更新源
$ sudo apt update

安装nvidia-docker2

# 安装nvidia-docker2
$ sudo apt install -y nvidia-docker2

# 重启Docker daemon
$ sudo pkill -SIGHUP dockerd

验证nvidia-docker2

$ sudo nvidia-docker run --rm nvidia/cuda nvidia-smi

普通用户可访问

$ sudo groupadd docker
$ sudo usermod -aG docker $USER

nvidia-docker 插件

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

nvidia-docker 安装

https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(version-2.0)

cuda-cudnn

https://www.cnblogs.com/journeyonmyway/p/10316292.html#4329767

#########################

在默认情况下ubuntu 会把我们通过apt-get 所安装的软件包保存在缓存文件夹里。

我们可以把这个文件夹做个备份。如果需要重装Ubuntu时,可以把备份还原回去。

这样就不能连上网络去大量更新系统软件包了

ubuntu apt-get 下载的软件包放在

/var/cache/apt/archives

如果要清除缓存文件夹,可以执行

sudo apt-get clean

#更新或升级
apt-get update                  # 更新源  
apt-get upgrade                 # 更新所有已安装的包
#安装或重装类操作
apt-get install <pkg>         # 安装软件包<pkg>,多个软件包用空格隔开  
apt-get install --reinstall <pkg> # 重新安装软件包<pkg>  
apt-get install -f <pkg>          # 修复安装(破损的依赖关系)软件包<pkg>
#卸载类操作
apt-get remove <pkg>          # 删除软件包<pkg>(不包括配置文件)  
apt-get purge <pkg>           # 删除软件包<pkg>(包括配置文件)
#下载清除类操作
apt-get source <pkg>              # 下载pkg包的源代码到当前目录  
apt-get download <pkg>            # 下载pkg包的二进制包到当前目录  
apt-get source -d <pkg>           # 下载完源码包后,编译  
apt-get build-dep   <pkg>     # 构建pkg源码包的依赖环境(编译环境?)  
apt-get clean                   # 清除缓存(/var/cache/apt/archives/{,partial}下)中所有已下载的包  
apt-get autoclean               # 类似于clean,但清除的是缓存中过期的包(即已不能下载或者是无用的包)  
apt-get autoremove              # 删除因安装软件自动安装的依赖,而现在不需要的依赖包  

#查询类操作
apt-cache stats             # 显示系统软件包的统计信息  
apt-cache search <pkg>            # 使用关键字pkg搜索软件包  
apt-cache show   <pkg_name>   # 显示软件包pkg_name的详细信息  
apt-cache depends <pkg>       # 查看pkg所依赖的软件包  
apt-cache rdepends <pkg>      # 查看pkg被那些软件包所依赖  

关于软件安装目录的说明:

	一般的deb包(包括新立得或者apt-get下载的)都在/usr/share。
	自己下载的压缩包或者编译的包,有些可以选择安装目录,一般放在/usr/local/,也有在/opt的
	
缓存目录
默认的缓存目录是/var/cache/apt/archives/
	为日后重装系统后安装软件节省下载时间或者将软件包给别人用,可以将该目录下的软件包压缩备份后清理以节省空间

一,离线安装docker

github 地址
https://github.com/gzvincen/docker-offline-install-package

https://github.com/gzvincen/docker-offline-install-package/blob/master/centos7.3-7.4/pkg_offline-docker-centos.sh

Ubuntu16.04
docker最新版下载
https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/
需要的三个文件(版本可能不一致)
containerd.io_1.2.0-1_amd64.deb 
docker-ce-cli_18.09.1~3-0~ubuntu-xenial_amd64.deb  
docker-ce_18.09.1~3-0~ubuntu-xenial_amd64.deb
一块安装
dpkg -i containerd.io_1.2.0-1_amd64.deb docker-ce-cli_18.09.1~3-0~ubuntu-xenial_amd64.deb  docker-ce_18.09.1~3-0~ubuntu-xenial_amd64.deb 
缺少依赖:
apt-get -f install 命令修复

二,离线安装nvidia

ubuntu1604
下载方法:
参考 https://github.com/NVIDIA/nvidia-docker  ,在一台可以上网的机器上,配置apt源,但不要执行后续的命

#Ubuntu 16.04/18.04, Debian Jessie/Stretch
# Add the package repositories
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

$ sudo apt-get update

distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
root@ubuntu:~/nvidia-docker-package# . /etc/os-release;echo $ID$VERSION_ID
ubuntu16.04

#下载包
  apt download libnvidia-container1
  apt download libnvidia-container-tools
  apt download nvidia-container-runtime-hook
  apt download nvidia-docker2
  apt download nvidia-container-toolkit
  apt download nvidia-container-runtime_2.0.0+docker18.03.0-1_amd64.deb
  apt download nvidia-docker2_2.0.3+docker18.03.0-1_all.deb



安装显示需要下载的包

执行 apt-get -y install docker-ce后的操作

After this operation, 390 MB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu xenial/universe amd64 pigz amd64 2.3.1-2 [61.1 kB]
Get:2 http://mirrors.aliyun.com/ubuntu xenial/universe amd64 aufs-tools amd64 1:3.2+20130722-1.1ubuntu1 [92.9 kB]
Get:3 http://mirrors.aliyun.com/ubuntu xenial/universe amd64 cgroupfs-mount all 1.2 [4,970 B]
Get:4 http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 containerd.io amd64 1.2.6-3 [22.6 MB]
Get:5 http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 docker-ce-cli amd64 5:19.03.1~3-0~ubuntu-xenial [42.2 MB]
Get:6 http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 docker-ce amd64 5:19.03.1~3-0~ubuntu-xenial [22.6 MB]                          
Get:7 http://mirrors.aliyun.com/ubuntu xenial/main amd64 libltdl7 amd64 2.4.6-0.1 [38.3 kB]                                                               
Fetched 87.7 MB in 15s (5,618 kB/s)                                                                                                                       
Selecting previously unselected package pigz.
(Reading database ... 84922 files and directories currently installed.)
Preparing to unpack .../pigz_2.3.1-2_amd64.deb ...
Unpacking pigz (2.3.1-2) ...
Selecting previously unselected package aufs-tools.
Preparing to unpack .../aufs-tools_1%3a3.2+20130722-1.1ubuntu1_amd64.deb ...
Unpacking aufs-tools (1:3.2+20130722-1.1ubuntu1) ...
Selecting previously unselected package cgroupfs-mount.
Preparing to unpack .../cgroupfs-mount_1.2_all.deb ...
Unpacking cgroupfs-mount (1.2) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../containerd.io_1.2.6-3_amd64.deb ...
Unpacking containerd.io (1.2.6-3) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../docker-ce-cli_5%3a19.03.1~3-0~ubuntu-xenial_amd64.deb ...
Unpacking docker-ce-cli (5:19.03.1~3-0~ubuntu-xenial) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../docker-ce_5%3a19.03.1~3-0~ubuntu-xenial_amd64.deb ...
Unpacking docker-ce (5:19.03.1~3-0~ubuntu-xenial) ...
Selecting previously unselected package libltdl7:amd64.
Preparing to unpack .../libltdl7_2.4.6-0.1_amd64.deb ...
Unpacking libltdl7:amd64 (2.4.6-0.1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu11) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu21.16) ...
Setting up pigz (2.3.1-2) ...
Setting up aufs-tools (1:3.2+20130722-1.1ubuntu1) ...
Setting up cgroupfs-mount (1.2) ...
Setting up containerd.io (1.2.6-3) ...
Setting up docker-ce-cli (5:19.03.1~3-0~ubuntu-xenial) ...
Setting up docker-ce (5:19.03.1~3-0~ubuntu-xenial) ...
Setting up libltdl7:amd64 (2.4.6-0.1) ...
Processing triggers for libc-bin (2.23-0ubuntu11) ...
Processing triggers for systemd (229-4ubuntu21.16) ...
Processing triggers for ureadahead (0.100.0-19) ..

centos 7
1,安装插件
yum install yum-downloadonly
yum就多了两个命令参数,分别是:
--downloadonly
--downloaddir=/path/to/dir

yum  localinstall  xxxx   xx  xx  


2,不使用yum-downloadonly 插件,自动安装或升级的同时保留RPM包
vim/etc/yum.conf
[main]
cachedir=c
keepcache=0

将 keepcache=0 修改为 keepcache=1, 安装或者升级后,在目录 /var/cache/yum 下就会有下载的 rpm 包

#yumdownloader  由yum-utils提供
yum -y install yum-utils*

######使用repotrack
yum install yum-utils
repotrack -a x86_64 -p /path/to/dir    packname
cd /path/to/dir
rpm -Uvh *.rpm


##repotrack    -q  httpd   下载指定的包到当前目录 下载所有依赖
##
repotrack    -u  nvidia-container-toolkit 
https://nvidia.github.io/libnvidia-container/centos7/x86_64/libnvidia-container-tools-1.0.3-1.x86_64.rpm
https://nvidia.github.io/libnvidia-container/centos7/x86_64/libnvidia-container1-1.0.3-1.x86_64.rpm
https://nvidia.github.io/nvidia-container-runtime/centos7/x86_64/nvidia-container-toolkit-1.0.2-2.x86_64.rpm

三 oracle linux 7

sudo yum install -y yum-utils device-mapper-persistent-data lvm2  
依赖
 device-mapper.x86_64 7:1.02.158-2.0.1.el7 device-mapper-event.x86_64 7:1.02.158-2.0.1.el7 device-mapper-event-libs.x86_64 7:1.02.158-2.0.1.el7 device-mapper-libs.x86_64 7:1.02.158-2.0.1.el7
  lvm2-libs.x86_64 7:2.02.185-2.0.1.el7
yum install -y yum-utils device-mapper-persistent-data lvm2
已加载插件:ulninfo
软件包 yum-utils-1.1.31-52.0.1.el7.noarch 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 device-mapper-persistent-data.x86_64.0.0.7.3-3.el7 将被 升级
---> 软件包 device-mapper-persistent-data.x86_64.0.0.8.5-1.el7 将被 更新
---> 软件包 lvm2.x86_64.7.2.02.180-8.el7 将被 升级
---> 软件包 lvm2.x86_64.7.2.02.185-2.0.1.el7 将被 更新
--> 正在处理依赖关系 lvm2-libs = 7:2.02.185-2.0.1.el7,它被软件包 7:lvm2-2.02.185-2.0.1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 lvm2-libs.x86_64.7.2.02.180-8.el7 将被 升级
---> 软件包 lvm2-libs.x86_64.7.2.02.185-2.0.1.el7 将被 更新
--> 正在处理依赖关系 device-mapper-event = 7:1.02.158-2.0.1.el7,它被软件包 7:lvm2-libs-2.02.185-2.0.1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 device-mapper-event.x86_64.7.1.02.149-8.el7 将被 升级
---> 软件包 device-mapper-event.x86_64.7.1.02.158-2.0.1.el7 将被 更新
--> 正在处理依赖关系 device-mapper = 7:1.02.158-2.0.1.el7,它被软件包 7:device-mapper-event-1.02.158-2.0.1.el7.x86_64 需要
--> 正在处理依赖关系 device-mapper-event-libs = 7:1.02.158-2.0.1.el7,它被软件包 7:device-mapper-event-1.02.158-2.0.1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 device-mapper.x86_64.7.1.02.149-8.el7 将被 升级
--> 正在处理依赖关系 device-mapper = 7:1.02.149-8.el7,它被软件包 7:device-mapper-libs-1.02.149-8.el7.x86_64 需要
---> 软件包 device-mapper.x86_64.7.1.02.158-2.0.1.el7 将被 更新
---> 软件包 device-mapper-event-libs.x86_64.7.1.02.149-8.el7 将被 升级
---> 软件包 device-mapper-event-libs.x86_64.7.1.02.158-2.0.1.el7 将被 更新
--> 正在检查事务
---> 软件包 device-mapper-libs.x86_64.7.1.02.149-8.el7 将被 升级
---> 软件包 device-mapper-libs.x86_64.7.1.02.158-2.0.1.el7 将被 更新
--> 解决依赖关系完成

依赖关系解决

================================================================================================================================================================================================
 Package                                                    架构                                版本                                              源                                       大小
================================================================================================================================================================================================
正在更新:
 device-mapper-persistent-data                              x86_64                              0.8.5-1.el7                                       ol7_latest                              422 k
 lvm2                                                       x86_64                              7:2.02.185-2.0.1.el7                              ol7_latest                              1.3 M
为依赖而更新:
 device-mapper                                              x86_64                              7:1.02.158-2.0.1.el7                              ol7_latest                              294 k
 device-mapper-event                                        x86_64                              7:1.02.158-2.0.1.el7                              ol7_latest                              189 k
 device-mapper-event-libs                                   x86_64                              7:1.02.158-2.0.1.el7                              ol7_latest                              189 k
 device-mapper-libs                                         x86_64                              7:1.02.158-2.0.1.el7                              ol7_latest                              321 k
 lvm2-libs                                                  x86_64                              7:2.02.185-2.0.1.el7                              ol7_latest                              1.1 M

事务概要
================================================================================================================================================================================================
升级  2 软件包 (+5 依赖软件包)

总下载量:3.8 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/7): device-mapper-event-1.02.158-2.0.1.el7.x86_64.rpm                                                                                                                 | 189 kB  00:00:02     
(2/7): device-mapper-1.02.158-2.0.1.el7.x86_64.rpm                                                                                                                       | 294 kB  00:00:02     
(3/7): device-mapper-event-libs-1.02.158-2.0.1.el7.x86_64.rpm                                                                                                            | 189 kB  00:00:00     
(4/7): device-mapper-libs-1.02.158-2.0.1.el7.x86_64.rpm                                                                                                                  | 321 kB  00:00:00     
(5/7): device-mapper-persistent-data-0.8.5-1.el7.x86_64.rpm                                                                                                              | 422 kB  00:00:00     
(6/7): lvm2-2.02.185-2.0.1.el7.x86_64.rpm                                                                                                                                | 1.3 MB  00:00:00     
(7/7): lvm2-libs-2.02.185-2.0.1.el7.x86_64.rpm                                                                                                                           | 1.1 MB  00:00:00     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                            1.0 MB/s | 3.8 MB  00:00:03     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : 7:device-mapper-libs-1.02.158-2.0.1.el7.x86_64                                                                                                                             1/14 
  正在更新    : 7:device-mapper-1.02.158-2.0.1.el7.x86_64                                                                                                                                  2/14 
  正在更新    : 7:device-mapper-event-libs-1.02.158-2.0.1.el7.x86_64                                                                                                                       3/14 
  正在更新    : 7:device-mapper-event-1.02.158-2.0.1.el7.x86_64                                                                                                                            4/14 
  正在更新    : 7:lvm2-libs-2.02.185-2.0.1.el7.x86_64                                                                                                                                      5/14 
  正在更新    : device-mapper-persistent-data-0.8.5-1.el7.x86_64                                                                                                                           6/14 
  正在更新    : 7:lvm2-2.02.185-2.0.1.el7.x86_64                                                                                                                                           7/14 
  清理        : 7:lvm2-2.02.180-8.el7.x86_64                                                                                                                                               8/14 
  清理        : 7:lvm2-libs-2.02.180-8.el7.x86_64                                                                                                                                          9/14 
  清理        : 7:device-mapper-event-1.02.149-8.el7.x86_64                                                                                                                               10/14 
  清理        : 7:device-mapper-event-libs-1.02.149-8.el7.x86_64                                                                                                                          11/14 
  清理        : 7:device-mapper-1.02.149-8.el7.x86_64                                                                                                                                     12/14 
  清理        : 7:device-mapper-libs-1.02.149-8.el7.x86_64                                                                                                                                13/14 
  清理        : device-mapper-persistent-data-0.7.3-3.el7.x86_64                                                                                                                          14/14 
  验证中      : device-mapper-persistent-data-0.8.5-1.el7.x86_64                                                                                                                           1/14 
  验证中      : 7:lvm2-libs-2.02.185-2.0.1.el7.x86_64                                                                                                                                      2/14 
  验证中      : 7:lvm2-2.02.185-2.0.1.el7.x86_64                                                                                                                                           3/14 
  验证中      : 7:device-mapper-1.02.158-2.0.1.el7.x86_64                                                                                                                                  4/14 
  验证中      : 7:device-mapper-libs-1.02.158-2.0.1.el7.x86_64                                                                                                                             5/14 
  验证中      : 7:device-mapper-event-libs-1.02.158-2.0.1.el7.x86_64                                                                                                                       6/14 
  验证中      : 7:device-mapper-event-1.02.158-2.0.1.el7.x86_64                                                                                                                            7/14 
  验证中      : device-mapper-persistent-data-0.7.3-3.el7.x86_64                                                                                                                           8/14 
  验证中      : 7:lvm2-2.02.180-8.el7.x86_64                                                                                                                                               9/14 
  验证中      : 7:device-mapper-event-1.02.149-8.el7.x86_64                                                                                                                               10/14 
  验证中      : 7:lvm2-libs-2.02.180-8.el7.x86_64                                                                                                                                         11/14 
  验证中      : 7:device-mapper-1.02.149-8.el7.x86_64                                                                                                                                     12/14 
  验证中      : 7:device-mapper-libs-1.02.149-8.el7.x86_64                                                                                                                                13/14 
  验证中      : 7:device-mapper-event-libs-1.02.149-8.el7.x86_64                                                                                                                          14/14 

更新完毕:
  device-mapper-persistent-data.x86_64 0:0.8.5-1.el7                                                      lvm2.x86_64 7:2.02.185-2.0.1.el7                                                     

作为依赖被升级:
  device-mapper.x86_64 7:1.02.158-2.0.1.el7 device-mapper-event.x86_64 7:1.02.158-2.0.1.el7 device-mapper-event-libs.x86_64 7:1.02.158-2.0.1.el7 device-mapper-libs.x86_64 7:1.02.158-2.0.1.el7
  lvm2-libs.x86_64 7:2.02.185-2.0.1.el7
curl -s -L https://nvidia.github.io/nvidia-docker/centos7/nvidia-docker.repo | \
  sudo tee /etc/yum.repos.d/nvidia-docker.repo

yum   -y install   docker-ce 
 yum -y install docker-ce    
已加载插件:ulninfo
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.3.19.03.1-3.el7 将被 安装
--> 正在处理依赖关系 containerd.io >= 1.2.2-3,它被软件包 3:docker-ce-19.03.1-3.el7.x86_64 需要
--> 正在处理依赖关系 docker-ce-cli,它被软件包 3:docker-ce-19.03.1-3.el7.x86_64 需要
--> 正在检查事务
---> 软件包 containerd.io.x86_64.0.1.2.6-3.3.el7 将被 安装
---> 软件包 docker-ce-cli.x86_64.1.19.03.1-3.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================================================================================================================================
 Package                                       架构                                   版本                                               源                                                大小
================================================================================================================================================================================================
正在安装:
 docker-ce                                     x86_64                                 3:19.03.1-3.el7                                    docker-ce-stable                                  24 M
为依赖而安装:
 containerd.io                                 x86_64                                 1.2.6-3.3.el7                                      docker-ce-stable                                  26 M
 docker-ce-cli                                 x86_64                                 1:19.03.1-3.el7                                    docker-ce-stable                                  39 M

事务概要
================================================================================================================================================================================================
安装  1 软件包 (+2 依赖软件包)

总下载量:90 M
安装大小:368 M
Downloading packages:
警告:/var/cache/yum/x86_64/7Server/docker-ce-stable/packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 621e9f35: NOKEY      ] 8.9 MB/s |  37 MB  00:00:05 ETA 
containerd.io-1.2.6-3.3.el7.x86_64.rpm 的公钥尚未安装
(1/3): containerd.io-1.2.6-3.3.el7.x86_64.rpm                                                                                                                            |  26 MB  00:00:02     
(2/3): docker-ce-19.03.1-3.el7.x86_64.rpm                                                                                                                                |  24 MB  00:00:04     
(3/3): docker-ce-cli-19.03.1-3.el7.x86_64.rpm                                                                                                                            |  39 MB  00:00:03     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                             13 MB/s |  90 MB  00:00:06     
从 https://mirrors.aliyun.com/docker-ce/linux/centos/gpg 检索密钥
导入 GPG key 0x621E9F35:
 用户ID     : "Docker Release (CE rpm) <docker@docker.com>"
 指纹       : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 来自       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
  正在安装    : containerd.io-1.2.6-3.3.el7.x86_64                                                                                                                                          1/3 
  正在安装    : 1:docker-ce-cli-19.03.1-3.el7.x86_64                                                                                                                                        2/3 
  正在安装    : 3:docker-ce-19.03.1-3.el7.x86_64                                                                                                                                            3/3 
  验证中      : 1:docker-ce-cli-19.03.1-3.el7.x86_64                                                                                                                                        1/3 
  验证中      : 3:docker-ce-19.03.1-3.el7.x86_64                                                                                                                                            2/3 
  验证中      : containerd.io-1.2.6-3.3.el7.x86_64                                                                                                                                          3/3 

已安装:
  docker-ce.x86_64 3:19.03.1-3.el7                                                                                                                                                              

作为依赖被安装:
  containerd.io.x86_64 0:1.2.6-3.3.el7                                                           docker-ce-cli.x86_64 1:19.03.1-3.el7  

nvidia-docker

curl -s -L https://nvidia.github.io/nvidia-docker/centos7/nvidia-docker.repo | \
  sudo tee /etc/yum.repos.d/nvidia-docker.repo
  
  
  已安装:
  nvidia-docker2.noarch 0:2.2.0-1                                                             
作为依赖被安装:
  libnvidia-container-tools.x86_64 0:1.0.3-1       libnvidia-container1.x86_64 0:1.0.3-1       nvidia-container-runtime.x86_64 0:3.1.1-1       nvidia-container-toolkit.x86_64 0:1.0.2-2     

oracle74

 

安装docker
#1,
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
#2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache fast
sudo yum -y install docker-ce
sudo service docker start
#3配置nvidia-docker  源
curl -s -L https://nvidia.github.io/nvidia-docker/centos7/nvidia-docker.repo | \
  sudo tee /etc/yum.repos.d/nvidia-docker.repo
sudo yum  -y install nvidia-docker2

设置默认的nvidia-runtime 



*****************************************************************************************
############创建repo
createrepo的用法
安装createrepo包可参考这个网站  http://createrepo.baseurl.org/download/

1 安装包  rpm -ivh http://createrepo.baseurl.org/download/createrepo-0.4.4-1.noarch.rpm
2 mkdir /custem
3 cp  *.rpm /custem   将rpm放到此目录中,注意这个命令支队rpm包文件生效
4 createrepo /custem
5 编写/etc/yum.repos.d/sf.repo
name=da
baseurl=file:///custem
enabled=1
gpgcheck=0
 	

自动安装脚本

1,将nvidia-docker.tar.gz 在root目录下解压,生成localrepo目录
2,进入localrepo目录执行
bash install-nvidia-docker-for-oracle-linux7.4.sh     安装
3,完成后重启docker ,验证nvidia-docker  info 
4,恢复本机原来的repo文件
将/etc/yum.repos.d/back  里的备份文件恢复至/etc/yum.repos.d/下

 cat install-nvidia-docker-for-oracle-linux7.4.sh 
#!/bin/bash
# date: 2019.8.24
# author: yon
#
echo  "check the rpm  packages...."
sleep  3
[ -d /root/localrepo/oracle-linux-7.4-last  ] &&  echo  ok  ||   (echo  "no data dir,pls  check you rpm packags." ; exit  )

echo  "backup  your repos into  /etc/yum.repos.d/back "
sleep  2 
mkdir   -p  /etc/yum.repos.d/back
mv  /etc/yum.repos.d/*    /etc/yum.repos.d/back 

echo  "build  local repodata"
sleep 2 

cat  > /etc/yum.repos.d/nvidia.repo << EOF
[local-yum-for-nvidia-docker]
name=nvidia-docker-local
baseurl=file:///root/localrepo/oracle-linux-7.4-last
enabled=1
gpgcheck=0
EOF


yum  clean  all 
yum makecache

echo "installing   yum-utils device-mapper-persistent-data lvm2 ...."
sleep  2
sudo yum install -y yum-utils device-mapper-persistent-data lvm2


echo  "installing docker-ce ...."
sleep  2  
yum -y install docker-ce

echo  "nvidia-docker...."
sleep 2 
sudo yum  -y install nvidia-docker2

echo 
echo 
echo 
echo  "Ps:   set the  default  runtime for docker  in /etc/docker/daemon.json "
echo  "run: systemctl restart docker "
echo  "run  nvidia-docker   to  test "

nvidia docker官方仓库配置网站

https://nvidia.github.io/nvidia-docker/

已经离线的包

https://github.com/xiangxiaoc/docker-ce_docker-compose_nvidia-docker2

离线的包,支持特定版本的docker-ce

有用的链接

https://blog.csdn.net/ComeTender/article/details/107713355

posted @ 2019-12-24 17:40  Lust4Life  阅读(3606)  评论(2编辑  收藏  举报