Created
June 22, 2022 17:58
-
-
Save leikahing/da689afc5cfe52ac430407d1e6d5c10f to your computer and use it in GitHub Desktop.
Dockerfile for Facebook Detectron2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM nvidia/cuda:11.1.1-cudnn8-devel-centos8 | |
RUN cd /etc/yum.repos.d/ && \ | |
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && \ | |
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* && \ | |
dnf check-update; dnf install -y ca-certificates python38 python38-devel git sudo which gcc-c++ mesa-libGL && \ | |
dnf clean all | |
RUN alternatives --set python /usr/bin/python3 && alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 | |
# create a non-root user | |
ARG USER_ID=1000 | |
RUN useradd -m --no-log-init --system --uid ${USER_ID} appuser -g wheel | |
RUN echo '%wheel ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | |
USER appuser | |
WORKDIR /home/appuser | |
ENV PATH="/home/appuser/.local/bin:${PATH}" | |
# install dependencies | |
# See https://pytorch.org/ for other options if you use a different version of CUDA | |
ARG CXX="g++" | |
RUN pip install --user tensorboard ninja cmake opencv-python opencv-contrib-python # 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 --user 'git+https://github.com/facebookresearch/fvcore' | |
# install detectron2 | |
RUN git clone https://github.com/facebookresearch/detectron2 detectron2_repo | |
# 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/detectron2_repo | |
# run detectron2 under user "appuser": | |
# curl -o input.jpg http://images.cocodataset.org/val2017/000000439715.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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment