前提条件就不多提啦,首先得装好nvidia驱动和Docker19以上版本,网上有很多教程。
尝试1:拉取现有的deepo镜像制作
deepo是一个囊括几乎所有深度学习框架的开源镜像,这里我们选择拉取一个tensorflow-gpu版本的,避免占用储存过大。
# 拉取
root@master:/home/hqc# docker pull ufoym/deepo:tensorflow-py36
# 查看该容器是否可见
root@master:/home/hqc# sudo docker run --rm --gpus all ufoym/deepo:tensorflow-py36 nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 495.44 Driver Version: 495.44 CUDA Version: 11.5 |
|-------------------------------+----------------------+----------------------+
| 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 NVIDIA GeForce ... Off | 00000000:01:00.0 Off | N/A |
| 23% 38C P8 9W / 250W | 11MiB / 11178MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
# 可见
# 进入容器
root@master:/home/hqc# docker run -gpus all -it ufoym/deepo:tensorflow-py36 bash
root@6ef50267dc04:/# nvidia-smi
Tue Jun 7 05:59:34 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 495.44 Driver Version: 495.44 CUDA Version: 11.5 |
|-------------------------------+----------------------+------------