当前位置:   article > 正文

detectron2容器环境安装问题(1)_error: package 'detectron2' requires a different p

error: package 'detectron2' requires a different python: 3.6.13 not in '>=3.

1为避免后面出现需求python版本低于3.7的情况

ERROR: Package 'detectron2' requires a different Python: 3.6.9 not in '>=3.7'

可以第一步就使用 nvidia/cuda:11.1.1-cudnn8-devel-ubuntu20.04镜像

2如果使用了18.04的镜像nvidia/cuda:11.1.1-cudnn8-devel-ubuntu18.04'

可以使用我修改过的dockerfile文件,已修改为python3.7版本

docker build -t detectron2 .

RUN pip install --user -e detectron2_repo 这一步detectron2_repo需要镜像建立后进入容器安装,在生成镜像中会失败,所以我将其注释,账户为appuser,无密码,可以sudo passwd appuser修改密码,部分下载失败的依赖包也已用清华源代替

  1. FROM nvidia/cuda:11.1.1-cudnn8-devel-ubuntu18.04
  2. # use an older system (18.04) to avoid opencv incompatibility (issue#3524)
  3. ENV DEBIAN_FRONTEND noninteractive
  4. RUN apt-get update && apt-get install -y \
  5. python3.7 python3.7-dev python3.7-distutils \
  6. python3-opencv ca-certificates git wget sudo ninja-build
  7. # Make python3 available for python3.7
  8. RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
  9. RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2
  10. RUN update-alternatives --config python3
  11. # Make python available for python3.7
  12. RUN ln -sv /usr/bin/python3.7 /usr/bin/python
  13. # create a non-root user
  14. ARG USER_ID=1000
  15. RUN useradd -m --no-log-init --system --uid ${USER_ID} appuser -g sudo
  16. RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
  17. USER appuser
  18. WORKDIR /home/appuser
  19. ENV PATH="/home/appuser/.local/bin:${PATH}"
  20. RUN wget https://bootstrap.pypa.io/pip/get-pip.py && \
  21. python3.7 get-pip.py --user && \
  22. rm get-pip.py
  23. # Important! Otherwise, it uses existing numpy from host-modules which throws error
  24. RUN pip install --user numpy==1.20.3
  25. # install dependencies
  26. # See https://pytorch.org/ for other options if you use a different version of CUDA
  27. RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple tensorboard cmake onnx # cmake from apt-get is too old
  28. RUN pip install --user torch==1.10 torchvision==0.11.1 -f https://download.pytorch.org/whl/cu111/torch_stable.html
  29. RUN pip install fvcore
  30. # install detectron2
  31. RUN git clone https://github.com/facebookresearch/detectron2 detectron2_repo --depth 1
  32. # set FORCE_CUDA because during `docker build` cuda is not accessible
  33. ENV FORCE_CUDA="1"
  34. # This will by default build detectron2 for all common cuda architectures and take a lot more time,
  35. # because inside `docker build`, there is no way to tell which architecture will be used.
  36. ARG TORCH_CUDA_ARCH_LIST="Kepler;Kepler+Tesla;Maxwell;Maxwell+Tegra;Pascal;Volta;Turing"
  37. ENV TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST}"
  38. #RUN pip install --user -e detectron2_repo
  39. # Set a fixed model cache directory.
  40. ENV FVCORE_CACHE="/tmp"
  41. WORKDIR /home/appuser
  42. # run detectron2 under user "appuser":
  43. # wget http://images.cocodataset.org/val2017/000000439715.jpg -O input.jpg
  44. # python3 demo/demo.py \
  45. #--config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \
  46. #--input input.jpg --output outputs/ \
  47. #--opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl

3其他问题

(1)GPG error: The following signatures couldn't be verified because the public key XXXXXX is not available

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys xxxxxxxxx

(2)缺少安装包 non-zero code 100

换源ADD sources.list /etc/apt/

(3) fvcore包下载安装失败,直接 RUN pip install -U fvcore

4后续如何使用镜像构建容器和pycharm调试程序在下一篇更新

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号