Deap learning/Useful library
[Deep learning - Useful library] mmdetection 설치 및 테스트
_JSP_
2023. 3. 29. 23:36
mmdetection이란?
Tensorflow object detection API처럼 다양한 객체 탐지 모델을 제공하고 학습, 추론, 파인튜닝, 모델 수정 등 다양한 기능을 제공하는 open source이며, pytorch을 기반으로 구성되어있다.
1. mmdetection 다운로드
git clone https://github.com/open-mmlab/mmdetection.git
2. Dockerfile 빌드
- GPU 이름 확인
nvidia-smi --query | fgrep 'Product Name'
- CUDA GPU와 호환되는 Compute Capability 확인(링크)
- GTX3090 :
8.6
- GTX3090 :
- pytorch docker image을 통한 버전확인
- pytorch :
1.9.0
- cuda :
11.1
- cudnn :
8
- pytorch :
- Dockerfile 수정
ARG PYTORCH="1.9.0"
ARG CUDA="11.1"
ARG CUDNN="8"
FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel
ENV TORCH_CUDA_ARCH_LIST="8.6"
ENV TORCH_NVCC_FLAGS="-Xfatbin -compress-all"
ENV CMAKE_PREFIX_PATH="$(dirname $(which conda))/../"
# To fix GPG key error when running apt-get update
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
RUN apt-get update && apt-get install -y ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install MMCV
RUN pip install --no-cache-dir --upgrade pip wheel setuptools
RUN pip install --no-cache-dir mmcv-full==1.3.17 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html
# Install MMDetection
RUN conda clean --all
RUN git clone https://github.com/open-mmlab/mmdetection.git /mmdetection
WORKDIR /mmdetection
ENV FORCE_CUDA="1"
- 빌드
cd mmdetection/docker
docker build -t mmdetection .
3. 실행
docker run -itd --net=host --gpus all --shm-size=8gb --name mmdet mmdetection:latest /bin/bash
4. 패키지 설치
pip install -r requirements/build.txt
pip install --no-cache-dir -e .
pip install jupyter notebook
apt-get update
apt-get install wget
5. 데모 테스트
- jupyter notebook 접속
nohup jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root --NotebookApp.token='' &
- model checkpoint 다운로드
mkdir checkpoints
cd checkpoints
wget https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
- demo 실행 및 결과 확인