我正在尝试从我的 docker 容器内部使用 GPU。我在 Ubuntu 18.04 上使用版本为 19.03 的 docker。
如果我运行 nvidia-smi,在 docker 容器之外,我会得到以下输出。
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.51.05 Driver Version: 450.51.05 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 30C P8 9W / 70W | 0MiB / 15109MiB | 0% Default …Run Code Online (Sandbox Code Playgroud) 我有一个Dockerfile基于nvidia/cuda这样的:
FROM nvidia/cuda:11.0-base
...
Run Code Online (Sandbox Code Playgroud)
我希望能够Dockerfile在我们没有 Nvidia GPU 的 CI 服务器上构建它。当我尝试这样做时,我收到此错误:
------
> [1/6] FROM docker.io/nvidia/cuda:11.0-base:
------
failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: rpc error: code = Unknown desc = failed to build LLB: failed to load cache key: docker.io/nvidia/cuda:11.0-base not found
Run Code Online (Sandbox Code Playgroud)
该错误表示未找到图像,但我认为这有点误导。我已经能够将问题与是否存在 GPU 隔离开来。
在Dockerfile带有 Nvidia GPU 的服务器上构建它时,我没有收到此错误。是否可以在没有 GPU 的服务器Dockerfile上构建基于nvidia/cuda图像的图像?这将节省我们 CI 服务器的成本。
我计划将生成的 docker 容器部署在具有 GPU 的服务器上,换句话说,是否可以将 GPU 的存在推迟到运行时间而不是构建时间?
官方的PyTorch Docker映像基于nvidia/cuda,可以在Docker CE上运行,而无需任何GPU。它也可以在nvidia-docker上运行,我假设已启用CUDA支持。是否可以在没有任何GPU的x86 CPU上运行nvidia-docker本身?有没有一种构建单个Docker映像的方法,该映像在可用时(例如,在内部运行时nvidia-docker)利用CUDA支持,否则使用CPU?torch.cuda在Docker CE内部使用时会发生什么?Docker CE之间到底有什么区别,为什么不能nvidia-docker合并到Docker CE中?
我看到了几个关于这个主题的问答,并尝试了这两种方法。任何关于如何继续任何一条路线的建议表示赞赏:
我关注了NVIDIA 文档和本教程。一切都docker在 Ubuntu 20.04 中安装和运行。但是,sudo service docker start返回:
docker: unrecognized service
更新:这变成了一个已知问题。我能够按照这些说明在 Ubuntu 上安装和运行 docker 。但是,接下来我遇到了这样的问题
$docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark
Status: Downloaded newer image for nvcr.io/nvidia/k8s/cuda-sample:nbody
docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: Running hook #0:: error running hook: exit status 1, stdout: , …Run Code Online (Sandbox Code Playgroud) 我未能成功使用 Dockerfile 为包含以下内容的映像创建 Docker 映像:
我尝试使用 Dockerfile 从 Python 基础映像开始构建映像,然后添加 NVIDIA 驱动程序,如下所示:
# minimal Python-enabled base image
FROM python:3.7
# add the NVIDIA driver
RUN apt-get update
RUN apt-get -y install software-properties-common
RUN add-apt-repository ppa:graphics-drivers/ppa
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FCAE110B1118213C
RUN apt-get update
RUN apt-get --yes install nvidia-driver-418
Run Code Online (Sandbox Code Playgroud)
我在上面的 Dockerfile 上运行 a 得到了很多输出docker build,但最后,它给出的消息表明它正在尝试安装我指定的更高版本的驱动程序(430 而不是 418),然后提示用户输入设置键盘: …
我试图从 Github重新实现这段代码,它要求我安装 nvidia-docker 并运行它。安装 nvidia-docker 似乎成功了。但是,当我运行命令时nvidia-docker run -it --ipc=host deep-colorization,它会引发以下错误:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"process_linux.go:432: running prestart hook 1 caused \\\"error running hook: exit status 1, stdout: , stderr: nvidia-container-cli: initialization error: driver error: failed to process request\\\\n\\\"\"": unknown.
Run Code Online (Sandbox Code Playgroud)
ERRO[0002] 错误等待容器:上下文取消
我不确定这个错误是什么意思,因为我之前没有任何使用 docker 生态系统的经验。任何形式的帮助表示赞赏。顺便说一下,我正在运行 Ubuntu 18。
提前谢谢你。
在 4 个 A6000 GPU 上运行分布式训练时,出现以下错误:
[E ProcessGroupNCCL.cpp:630] [Rank 3] Watchdog caught collective operation timeout: WorkNCCL(OpType=BROADCAST, Timeout(ms)=1800000) ran for 1803710 milliseconds before timing out.
[E ProcessGroupNCCL.cpp:390] Some NCCL operations have failed or timed out. Due to the asynchronous nature of CUDA kernels, subsequent GPU operations might run on corrupted/incomplete data. To avoid this inconsistency, we are taking the entire process down.
terminate called after throwing an instance of 'std::runtime_error'
what(): [Rank 2] Watchdog caught collective operation timeout:
WorkNCCL(OpType=BROADCAST, Timeout(ms)=1800000) ran …Run Code Online (Sandbox Code Playgroud) 在命令行中,我习惯使用 --gpus 参数运行/创建具有特定 GPU 的容器:
docker run -it --gpus '"device=0,2"' ubuntu nvidia-smi
Docker SDK for Python 文档不是很有帮助,我找不到关于如何使用 python SDK 执行相同操作的良好解释。有办法做到吗?
我按照此处的说明安装了 nvidia-docker2 。运行以下命令时,我将得到如图所示的预期输出。
sudo docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 495.29.05 Driver Version: 495.29.05 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 ... On | 00000000:0B:00.0 On | N/A |
| 24% 31C P8 13W / 250W | 222MiB / 11011MiB | 0% Default | …Run Code Online (Sandbox Code Playgroud) 我正在为 NVIDIA GPU 构建 DeepStream Docker 映像,如本链接中所述。
我安装了NVIDIA 容器工具包,原始 Dockerfile 可以运行,构建后我可以使用以下命令启动具有 GPU 支持的容器:
sudo docker run --runtime=nvidia --gpus all --name Test -it deepstream:dgpu
Run Code Online (Sandbox Code Playgroud)
问题是我想在docker build序列期间安装 PyTorch 并使用它。一旦 PyTorch 在构建序列中导入,Found no NVIDIA driver on your system就会出现错误:
#0 0.895 Traceback (most recent call last):
#0 0.895 File "./X.py", line 15, in <module>
#0 0.895 dummy_input = torch.randn([1, 3, 224, 224], device='cuda')
#0 0.895 File "/usr/local/lib/python3.8/dist-packages/torch/cuda/__init__.py", line 229, in _lazy_init
#0 0.895 torch._C._cuda_init()
#0 0.895 …Run Code Online (Sandbox Code Playgroud) nvidia-docker ×10
docker ×9
pytorch ×4
cuda ×3
gpu ×3
nvidia ×3
python ×3
distributed ×1
dockerfile ×1
dockerpy ×1
linux ×1
ubuntu-20.04 ×1
wsl-2 ×1