detectron2容器环境安装问题(1)

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修改密码,部分下载失败的依赖包也已用清华源代替

FROM nvidia/cuda:11.1.1-cudnn8-devel-ubuntu18.04
# use an older system (18.04) to avoid opencv incompatibility (issue#3524)
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
    python3.7 python3.7-dev python3.7-distutils \
    python3-opencv ca-certificates git wget sudo ninja-build
# Make python3 available for python3.7
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2
RUN update-alternatives --config python3
# Make python available for python3.7
RUN ln -sv /usr/bin/python3.7 /usr/bin/python
# create a non-root user
ARG USER_ID=1000
RUN useradd -m --no-log-init --system  --uid ${USER_ID} appuser -g sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER appuser
WORKDIR /home/appuser
ENV PATH="/home/appuser/.local/bin:${PATH}"
RUN wget https://bootstrap.pypa.io/pip/get-pip.py && \
python3.7 get-pip.py --user && \
rm get-pip.py
# Important! Otherwise, it uses existing numpy from host-modules which throws error
RUN pip install --user numpy==1.20.3
# install dependencies
# See https://pytorch.org/ for other options if you use a different version of CUDA
RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple tensorboard cmake onnx  # cmake from apt-get is too old
RUN pip install --user torch==1.10 torchvision==0.11.1 -f https://download.pytorch.org/whl/cu111/torch_stable.html
RUN pip install fvcore
# install detectron2
RUN git clone https://github.com/facebookresearch/detectron2 detectron2_repo --depth 1
# set FORCE_CUDA because during `docker build` cuda is not accessible
ENV FORCE_CUDA="1"
# This will by default build detectron2 for all common cuda architectures and take a lot more time,
# because inside `docker build`, there is no way to tell which architecture will be used.
ARG TORCH_CUDA_ARCH_LIST="Kepler;Kepler+Tesla;Maxwell;Maxwell+Tegra;Pascal;Volta;Turing"
ENV TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST}"
#RUN pip install --user -e detectron2_repo
# Set a fixed model cache directory.
ENV FVCORE_CACHE="/tmp"
WORKDIR /home/appuser
# run detectron2 under user "appuser":
# wget http://images.cocodataset.org/val2017/000000439715.jpg -O input.jpg
# python3 demo/demo.py  \
#--config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \
#--input input.jpg --output outputs/ \
#--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调试程序在下一篇更新

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值