如何使用 dockerfile 安装 .whl 文件

乘风 pytorch 653

原文标题How to install .whl files using dockerfile

我正在尝试使用 Dockerfile 安装 .whl 文件。这是我的码头文件。

FROM us-docker.pkg.dev/vertex-ai/training/tf-gpu.2-8:latest
USER root
CMD python --version
COPY *.txt /
ADD ./train/ /train/
RUN pip install ./whl_files/*.whl
# RUN pip install whl_files/torchaudio-0.11.0+cu113-cp39-cp39-linux_x86_64.whl
# RUN pip install whl_files/torchvision-0.12.0+cu113-cp39-cp39-linux_x86_64.whl
# RUN pip3 install --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
# RUN pip3 install --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
RUN pip3 install --ignore-installed -r requirements.txt --trusted-host pypi.org --trusted-host files.pythonhosted.org
COPY *.py /root/
RUN chmod +x /root/docker_fetch.py
RUN python /root/docker_fetch.py

ENTRYPOINT ["/bin/bash"]

我收到此错误:

 => ERROR [4/8] RUN pip install ./whl_files/*.whl                                                                                                                                                                  0.9s
------                                                                                                                                                                                                                  
 > [4/8] RUN pip install ./whl_files/*.whl:                                                                                                                                                                             
#8 0.711 WARNING: Requirement './whl_files/*.whl' looks like a filename, but the file does not exist
#8 0.711 ERROR: *.whl is not a valid wheel filename.
#8 0.856 Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)'))) - skipping
------
executor failed running [/bin/bash -c pip install ./whl_files/*.whl]: exit code: 1

没有防火墙问题。

我也尝试使用它进行安装,但这也没有用。

RUN pip3 install --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html

原文链接:https://stackoverflow.com//questions/71483736/how-to-install-whl-files-using-dockerfile

回复

我来回复
  • AKX的头像
    AKX 评论

    扩展我的评论:

    看起来,您还没有将任何文件复制到容器中的 whl_files 中。您只需添加和复制一些 txt 文件和 train/ 文件夹。

    whl 文件需要存在于容器中(就像要使用的任何其他文件一样)才能安装(除非您改用 Buildkit 的缓存卷,但这会使事情变得更加复杂)。

    2年前 0条评论