当前位置: 首页 > news >正文

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调试程序在下一篇更新

http://www.lryc.cn/news/23947.html

相关文章:

  • JAVA线程池原理详解二
  • Java 常用 API
  • 记一次分布式环境下TOKEN实现用户登录
  • 用cpolar发布本地的论坛网站 1
  • CSS的4种引入方式
  • Shell高级——Linux中的文件描述符(本质是数组的下标)
  • Nvidia jetson nano硬件架构
  • ffmpeg多路同时推流
  • 一次性搞定 `SHOW SLAVE STATUS` 的解读
  • 【代码随想录训练营】【Day25】第七章|回溯算法 |216.组合总和III|17.电话号码的字母组合
  • docker使用
  • 手把手docker registry配置登录名/密码
  • 一步打通多渠道服务场景 中电金信源启移动开发平台MADP功能“上新”
  • Kubernetes06:Controller (Deployment无状态应用)
  • 低代码开发平台选型必看指南
  • OVN:ovn20.03.1/ovs2.13.0编译rpm过程
  • Shell管道
  • Zynq UltraScale系列使用MIPI CSI-2 RX Subsystem 解码MIPI视频PD输出 提供2套工程源码和技术支持
  • C++:详解C++11 线程休眠函数
  • TryHackMe-The Great Escape(Docker)
  • 这么强才给我28k,我头都不回,转身拿下40k~
  • 【Python学习笔记】第二十一节 Python Lambda 函数
  • Nginx学习整理
  • 阿里面试之Hr面,这个套路把我坑惨了......
  • 域基础和基本环境搭建
  • Java Map集合体系(HashMap、LinkedHashMap、TreeMap、集合嵌套)
  • 使用邮箱验证实现登录功能(发送邮件,redis)
  • 【Linux】网卡的7种bond模式
  • AQS抽象队列同步器
  • springBoot对REST支持源码解析