运行pip install-r requirements.txt在Dockerfile中不工作

运行pip install-r requirements.txt在Dockerfile中不工作,docker,nvidia-docker,Docker,Nvidia Docker,我试图通过向我的基本docker映像添加一些python包来构建一个新的docker映像。sudo docker build-t myimage1:cuda10.2.运行时没有任何问题,但我无法导入新映像中的任何包。我正在使用sudockerrun--gpusall-it myimage1:cuda10.2来运行映像。有人能帮我理解我在这里遗漏了什么吗 Dockerfile FROM nvcr.io/nvidia/rapidsai/rapidsai:cuda10.2-runtime-ubuntu

我试图通过向我的基本docker映像添加一些python包来构建一个新的docker映像。sudo docker build-t myimage1:cuda10.2.运行时没有任何问题,但我无法导入新映像中的任何包。我正在使用
sudockerrun--gpusall-it myimage1:cuda10.2
来运行映像。有人能帮我理解我在这里遗漏了什么吗

Dockerfile

FROM nvcr.io/nvidia/rapidsai/rapidsai:cuda10.2-runtime-ubuntu18.04

WORKDIR /rapids/notebooks/

COPY requirements.txt ./

RUN pip install --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt
requirements.txt

ujson
这是docker build的跟踪

Sending build context to Docker daemon  4.096kB
Step 1/5 : FROM nvcr.io/nvidia/rapidsai/rapidsai:cuda10.2-runtime-ubuntu18.04
 ---> 98901cabda0a
Step 2/5 : WORKDIR /rapids/notebooks/
 ---> Using cache
 ---> 162a9bb732c7
Step 3/5 : COPY requirements.txt ./
 ---> 7bb48a384987
Step 4/5 : RUN pip install --upgrade pip &&     pip install --no-cache-dir -r requirements.txt
 ---> Running in 5f3ca4ed3f93
Collecting pip
  Downloading pip-20.2.4-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Uninstalling pip-20.0.2:
      Successfully uninstalled pip-20.0.2
Successfully installed pip-20.2.4
Collecting ujson
  Downloading ujson-4.0.1-cp38-cp38-manylinux1_x86_64.whl (181 kB)
Installing collected packages: ujson
Successfully installed ujson-4.0.1
Removing intermediate container 5f3ca4ed3f93
 ---> 58e94a2c4c98
Step 5/5 : COPY . .
 ---> d5897f4da4ff
Successfully built d5897f4da4ff
Successfully tagged myimage1:cuda10.2
如果我运行映像并执行
pip安装ujson
这就是我得到的结果

Collecting ujson
  Downloading ujson-4.0.1-cp37-cp37m-manylinux1_x86_64.whl (179 kB)
     |████████████████████████████████| 179 kB 947 kB/s
Installing collected packages: ujson
Successfully installed ujson-4.0.1

唯一的区别是ujson包是cp37,而Dockerfile安装的是cp38?有人能解释一下为什么安装的包是针对不同的Python版本的吗?

在rapids容器中,有一个名为
rapids
的虚拟环境,其中安装了所有包,并在容器的默认入口点激活。您应该将
RUN
命令更改为:

RUN source activate rapids && \
    pip install --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt