我正在使用一个python:3.7.4-slim-buster
的 Docker 镜像,但我不能更改它。我想知道如何在其中使用我的nvidia gpu。
通常我使用的是tensorflow/tensorflow:1.14.0-gpu-py3
镜像,在docker run
命令中使用简单的--runtime=nvidia
就可以正常运行,但现在我有这个限制。
我认为在此类型的镜像上不存在快捷方式,因此我正在按照以下指南https://towardsdatascience.com/how-to-properly-use-the-gpu-within-a-docker-container-4c699c78c6d1构建提供的 Dockerfile:
FROM python:3.7.4-slim-buster
RUN apt-get update && apt-get install -y build-essential
RUN apt-get --purge remove -y nvidia*
ADD ./Downloads/nvidia_installers /tmp/nvidia > Get the install files you used to install CUDA and the NVIDIA drivers on your host
RUN /tmp/nvidia/NVIDIA-Linux-x86_64-331.62.run -s -N --no-kernel-module > Install the driver.
RUN rm -rf /tmp/selfgz7 > For some reason the driver installer left temp files when used during a docker build (i dont have any explanation why) and the CUDA installer will fail if there still there so we delete them.
RUN /tmp/nvidia/cuda-linux64-rel-6.0.37-18176142.run -noprompt > CUDA driver installer.
RUN /tmp/nvidia/cuda-samples-linux-6.0.37-18176142.run -noprompt -cudaprefix=/usr/local/cuda-6.0 > CUDA samples comment if you dont want them.
RUN export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64 > Add CUDA library into your PATH
RUN touch /etc/ld.so.conf.d/cuda.conf > Update the ld.so.conf.d directory
RUN rm -rf /temp/* > Delete installer files.
但是它会引发一个错误:
ADD failed: stat /var/lib/docker/tmp/docker-builder080208872/Downloads/nvidia_installers: no such file or directory
我应该怎样调整设置,让Docker镜像能够轻松地识别我的GPU?
python:3.7.4-slim-buster
,因为你需要这个特定的 Python 版本,对吧? - anemyte