首先参考迁移学习工具对环境安装参考要求:
Transfer Learning Toolkit Requirements and Installation
NVIDIA GPU Cloud account and API key------已经申请,参考https://ngc.nvidia.com/
docker-ce installed------参考博客:
https://blog.csdn.net/weixin_41783910/article/details/108342779
nvidia-docker安装参考:
https://github.com/NVIDIA/nvidia-docker
https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker
curl https://get.docker.com | sh
sudo systemctl start docker && sudo systemctl enable docker
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
url -s -L https://nvidia.github.io/nvidia-container-runtime/experimental/$distribution/nvidia-container-runtime.list | sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.51.06 Driver Version: 450.51.06 CUDA Version: 11.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Tesla T4 On | 00000000:00:1E.0 Off | 0 |
| N/A 34C P8 9W / 70W | 0MiB / 15109MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
实际安装备忘:
zjx@zhou:~$ sudo su - root
[sudo] password for zjx:
root@zhou:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@zhou:~# docker --version
Docker version 19.03.9, build 9d988398e7
root@zhou:~# sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:4cf9c47f86df71d48364001ede3a4fcd85ae80ce02ebad74156906caff5378bc
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
root@zhou:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8dcc9a948f60 hello-world "/hello" 6 seconds ago Exited (0) 5 seconds ago vibrant_maxwell
root@zhou:~# sudo apt-get update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:2 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic InRelease
Hit:3 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
Get:4 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [49.0 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [57.1 kB]
Get:7 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:8 http://cn.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:9 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [295 kB]
Get:10 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [286 kB]
Get:11 http://cn.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,468 B]
Get:12 http://cn.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [9,288 B]
Fetched 953 kB in 4s (252 kB/s)
Reading package lists... Done
root@zhou:~# sudo apt-get install -y nvidia-docker2
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package nvidia-docker2
root@zhou:~# distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
root@zhou:~# curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
Command 'curl' not found, but can be installed with:
apt install curl
gpg: no valid OpenPGP data found.
root@zhou:~# sudo apt-get install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libcurl4
The following NEW packages will be installed:
curl libcurl4
0 upgraded, 2 newly installed, 0 to remove and 277 not upgraded.
Need to get 373 kB of archives.
After this operation, 1,038 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcurl4 amd64 7.58.0-2ubuntu3.10 [214 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 curl amd64 7.58.0-2ubuntu3.10 [159 kB]
Fetched 373 kB in 3s (130 kB/s)
Selecting previously unselected package libcurl4:amd64.
(Reading database ... 140573 files and directories currently installed.)
Preparing to unpack .../libcurl4_7.58.0-2ubuntu3.10_amd64.deb ...
Unpacking libcurl4:amd64 (7.58.0-2ubuntu3.10) ...
Selecting previously unselected package curl.
Preparing to unpack .../curl_7.58.0-2ubuntu3.10_amd64.deb ...
Unpacking curl (7.58.0-2ubuntu3.10) ...
Setting up libcurl4:amd64 (7.58.0-2ubuntu3.10) ...
Setting up curl (7.58.0-2ubuntu3.10) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
root@zhou:~# curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
OK
root@zhou:~# curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
deb https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/$(ARCH) /
#deb https://nvidia.github.io/libnvidia-container/experimental/ubuntu18.04/$(ARCH) /
deb https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/$(ARCH) /
#deb https://nvidia.github.io/nvidia-container-runtime/experimental/ubuntu18.04/$(ARCH) /
deb https://nvidia.github.io/nvidia-docker/ubuntu18.04/$(ARCH) /
root@zhou:~# curl -s -L https://nvidia.github.io/nvidia-container-runtime/experimental/$distribution/nvidia-container-runtime.list | sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
deb https://nvidia.github.io/libnvidia-container/experimental/ubuntu18.04/$(ARCH) /
deb https://nvidia.github.io/nvidia-container-runtime/experimental/ubuntu18.04/$(ARCH) /
root@zhou:~# sudo apt-get update
Hit:1 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 https://nvidia.github.io/libnvidia-container/experimental/ubuntu18.04/amd64 InRelease [1,158 B]
Hit:3 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic InRelease
Get:4 https://nvidia.github.io/nvidia-container-runtime/experimental/ubuntu18.04/amd64 InRelease [1,149 B]
Hit:5 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:6 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease
Get:7 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64 InRelease [1,139 B]
Get:8 https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64 InRelease [1,136 B]
Hit:9 http://cn.archive.ubuntu.com/ubuntu bionic-backports InRelease
Get:10 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64 InRelease [1,129 B]
Get:11 https://nvidia.github.io/libnvidia-container/experimental/ubuntu18.04/amd64 Packages [3,392 B]
Get:12 https://nvidia.github.io/nvidia-container-runtime/experimental/ubuntu18.04/amd64 Packages [804 B]
Get:13 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64 Packages [9,128 B]
Get:14 https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64 Packages [6,148 B]
Get:15 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64 Packages [4,332 B]
Fetched 29.5 kB in 3s (9,890 B/s)
Reading package lists... Done
root@zhou:~# sudo apt-get install -y nvidia-docker2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libnvidia-container-tools libnvidia-container1 nvidia-container-runtime nvidia-container-toolkit
The following NEW packages will be installed:
libnvidia-container-tools libnvidia-container1 nvidia-container-runtime nvidia-container-toolkit nvidia-docker2
0 upgraded, 5 newly installed, 0 to remove and 277 not upgraded.
Need to get 1,471 kB of archives.
After this operation, 4,683 kB of additional disk space will be used.
Get:1 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64 libnvidia-container1 1.3.0-1 [67.0 kB]
Get:2 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64 libnvidia-container-tools 1.3.0-1 [20.4 kB]
Get:3 https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64 nvidia-container-toolkit 1.3.0-1 [763 kB]
Get:4 https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64 nvidia-container-runtime 3.4.0-1 [615 kB]
Get:5 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64 nvidia-docker2 2.5.0-1 [5,912 B]
Fetched 1,471 kB in 2s (840 kB/s)
Selecting previously unselected package libnvidia-container1:amd64.
(Reading database ... 140586 files and directories currently installed.)
Preparing to unpack .../libnvidia-container1_1.3.0-1_amd64.deb ...
Unpacking libnvidia-container1:amd64 (1.3.0-1) ...
Selecting previously unselected package libnvidia-container-tools.
Preparing to unpack .../libnvidia-container-tools_1.3.0-1_amd64.deb ...
Unpacking libnvidia-container-tools (1.3.0-1) ...
Selecting previously unselected package nvidia-container-toolkit.
Preparing to unpack .../nvidia-container-toolkit_1.3.0-1_amd64.deb ...
Unpacking nvidia-container-toolkit (1.3.0-1) ...
Selecting previously unselected package nvidia-container-runtime.
Preparing to unpack .../nvidia-container-runtime_3.4.0-1_amd64.deb ...
Unpacking nvidia-container-runtime (3.4.0-1) ...
Selecting previously unselected package nvidia-docker2.
Preparing to unpack .../nvidia-docker2_2.5.0-1_all.deb ...
Unpacking nvidia-docker2 (2.5.0-1) ...
Setting up libnvidia-container1:amd64 (1.3.0-1) ...
Setting up libnvidia-container-tools (1.3.0-1) ...
Setting up nvidia-container-toolkit (1.3.0-1) ...
Setting up nvidia-container-runtime (3.4.0-1) ...
Setting up nvidia-docker2 (2.5.0-1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
root@zhou:~# sudo systemctl restart docker
root@zhou:~# nvidia-smi
Wed Oct 14 14:16:49 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.80.02 Driver Version: 450.80.02 CUDA Version: 11.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 GeForce GTX 1660 Off | 00000000:01:00.0 On | N/A |
| 31% 34C P8 13W / 120W | 412MiB / 5943MiB | 1% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1278 G /usr/lib/xorg/Xorg 26MiB |
| 0 N/A N/A 1322 G /usr/bin/gnome-shell 50MiB |
| 0 N/A N/A 1768 G /usr/lib/xorg/Xorg 208MiB |
| 0 N/A N/A 1881 G /usr/bin/gnome-shell 116MiB |
| 0 N/A N/A 2536 G /usr/lib/firefox/firefox 2MiB |
| 0 N/A N/A 2578 G /usr/lib/firefox/firefox 2MiB |
+-----------------------------------------------------------------------------+
root@zhou:~# sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
Unable to find image 'nvidia/cuda:11.0-base' locally
11.0-base: Pulling from nvidia/cuda
54ee1f796a1e: Pull complete
f7bfea53ad12: Pull complete
46d371e02073: Pull complete
b66c17bbf772: Pull complete
3642f1a6dfb3: Pull complete
e5ce55b8b4b9: Pull complete
155bc0332b0a: Pull complete
Digest: sha256:774ca3d612de15213102c2dbbba55df44dc5cf9870ca2be6c6e9c627fa63d67a
Status: Downloaded newer image for nvidia/cuda:11.0-base
Wed Oct 14 06:17:29 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.80.02 Driver Version: 450.80.02 CUDA Version: 11.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 GeForce GTX 1660 Off | 00000000:01:00.0 On | N/A |
| 31% 34C P8 14W / 120W | 402MiB / 5943MiB | 2% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
root@zhou:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8dcc9a948f60 hello-world "/hello" 9 minutes ago Exited (0) 9 minutes ago vibrant_maxwell
root@zhou:~#