4

我未能成功使用 Dockerfile 为包含以下内容的图像创建 Docker 图像:

  1. Python3 和 pip,因此我可以使用 pip 安装我的 Python 应用程序的包要求,然后可以访问 Python3 解释器来运行主要涉及 Keras、TensorFlow 和 OpenCV 的应用程序
  2. NVIDIA 驱动程序和 CUDA 支持足以让 TensorFlow 在运行应用程序时利用 GPU

我尝试使用 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

我从上面的 Dockerfile 上运行 a 得到了很多输出,docker build但最后,它给出的消息表明它正在尝试安装我指定的更高版本的驱动程序(430 而不是 418),然后它提示用户输入设置键盘:

Building for architecture x86_64
Building initial module for 4.19.0-5-amd64
Error! Bad return status for module build on kernel: 4.19.0-5-amd64 (x86_64)
Consult /var/lib/dkms/nvidia/430.40/build/make.log for more information.
dpkg: error processing package nvidia-dkms-430 (--configure):
 installed nvidia-dkms-430 package post-installation script subprocess returned error exit status 10
Setting up xfonts-base (1:1.0.5) ...
Setting up libdrm2:amd64 (2.4.97-1) ...
dpkg: dependency problems prevent configuration of nvidia-driver-430:
 nvidia-driver-430 depends on nvidia-dkms-430 (= 430.40-0ubuntu0~gpu19.10.1); however:
  Package nvidia-dkms-430 is not configured yet.

dpkg: error processing package nvidia-driver-430 (--configure):
 dependency problems - leaving unconfigured
Setting up xauth (1:1.0.10-1) ...
Setting up xserver-common (2:1.20.4-1) ...
Setting up keyboard-configuration (1.191) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Configuring keyboard-configuration
----------------------------------

Please select the layout matching the keyboard for this machine.

  1. English (US)
  2. English (US) - Cherokee
  3. English (US) - English (Colemak)
  4. English (US) - English (Dvorak)
  5. English (US) - English (Dvorak, alt. intl.)
  6. English (US) - English (Dvorak, intl., with dead keys)
  7. English (US) - English (Dvorak, left-handed)
  8. English (US) - English (Dvorak, right-handed)
  9. English (US) - English (Macintosh)
  10. English (US) - English (US, alt. intl.)
  11. English (US) - English (US, euro on 5)
  12. English (US) - English (US, intl., with dead keys)
  13. English (US) - English (Workman)
  14. English (US) - English (Workman, intl., with dead keys)
  15. English (US) - English (classic Dvorak)
  16. English (US) - English (intl., with AltGr dead keys)
  17. English (US) - English (programmer Dvorak)
  18. English (US) - English (the divide/multiply keys toggle the layout)
  19. English (US) - Russian (US, phonetic)
  20. English (US) - Serbo-Croatian (US)
  21. Other
Keyboard layout: 

当我输入时1,一切似乎都挂起,所以这还不行。

我还尝试了一个以 NVIDIA 图像开头的 Dockerfile,然后在顶部添加 Python 和 pip,如下所示:

FROM nvidia/driver:418.40.04-ubuntu18.04
RUN apt-get update
RUN apt-get -y install python3
RUN apt-get -y install python3-pip

docker build使用上述运行会出现此错误:

Step 4/8 : RUN apt-get -y install python3-pip
 ---> Running in eaa9a2ec71a9
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package python3-pip
The command '/bin/sh -c apt-get -y install python3-pip' returned a non-zero code: 100

对于上述尝试之一,我可以尝试哪些其他方法或修复?

4

1 回答 1

4

你可以使用这个:

FROM nvidia/driver:418.40.04-ubuntu18.04
RUN apt-get -y update \
    && apt-get install -y software-properties-common \
    && apt-get -y update \
    && add-apt-repository universe
RUN apt-get -y update
RUN apt-get -y install python3
RUN apt-get -y install python3-pip
于 2019-08-05T05:27:54.373 回答