硬件环境:
系统:Ubuntu16.04
Pytorch:pytorch-1.1.0 + torchvision-0.2.2
显卡:RTX2080Ti + CUDA9.0 + CUDNN7.4
网上说RTX2080Ti 必须用CUDA10,一开始安装的cuda10.0,可能没有配置好,导致最终FCOS运行报错失败,然后尝试cuda9.0最终安装成功。cuda10.0以后有机会在尝试。
FCOS github: https://github.com/tianzhi0549/FCOS
一、INSTALL.md安装
搭建过程参照INSTALL.md文件就好。
此处应该注意 pytorch torchvision 的版本要匹配,否则会报错。
我的版本是:pytorch-1.1.0
torchvision-0.2.2
INSTALL.md 安装 pytorch 和 torchvision 过程中会出现下载失败,安装失败的情况,然后单独安装下载失败的那个包。多试几次就好
二、安装docker
Option2前要先安装docker。
1.
2.
sudo apt-get remove docker docker-engine docker.io containerd runc
3.
# 更新源
4.
sudo apt-get update
5.
# 安装支持apt使用https下载的包
6.
sudo apt-get install \
7.
apt-transport-https \
8.
ca-certificates \
9.
curl \
10.
gnupg-agent \
11.
software-properties-common
12.
# 添加GPG key,用于官方发布的软件包签名,校验软件是否被修改过
13.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
14.
# 通过搜索key的后8位0EBFCD88,查看key是否获取成功
15.
sudo apt-key fingerprint 0EBFCD88
16.
# 添加docker源
17.
sudo add-apt-repository \
18.
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
19.
$(lsb_release -cs) \
20.
stable"
21.
# 更新源
22.
sudo apt-get update
23.
# 安装docker ce
24.
sudo apt-get install docker-ce docker-ce-cli containerd.io
zhexiebao测试
1.
2.
$ sudo docker run hello-world
3.
# 输出如下:
4.
# Unable to find image 'hello-world:latest' locally
5.
# latest: Pulling from library/hello-world
6.
# 1b930d010525: Pull complete
7.
# Digest: # sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e
8.
# Status: Downloaded newer image for hello-world:latest
9.
10.
# Hello from Docker!
11.
# This message shows that your installation appears to be working correctly.
12.
# ...
查看版本
docker -v
然后需要安装nvidia-docker 安装过程参照 :https://github.com/NVIDIA/nvidia-docker
三、nvidia-docker build Dockerfile
建议修改FCOS/docker 目录下的Dockerfile 文件中的默认配置
ARG CUDA="9.0"
ARG CUDNN="7"
这两句改成你自己使用的版本,因为我尝试自定义,但是最终显示安装配置没变,可能是我自己操作原因。
然后执行下面的命令,测试路径应该是在FCOS下。
Build image with defaults (CUDA=9.0
, CUDNN=7
, FORCE_CUDA=1
):
nvidia-docker build -t maskrcnn-benchmark docker/
下面是我自己修改后的Dockerfile,仅供参考
1.
2.
ARG CUDNN="7"
3.
4.
FROM nvidia/cuda:${CUDA}-cudnn${CUDNN}-devel-ubuntu16.04
5.
6.
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
7.
8.
# install basics
9.
RUN apt-get update -y \
10.
&& apt-get install -y apt-utils git curl ca-certificates bzip2 cmake tree htop bmon iotop g++ \
11.
&& apt-get install -y libglib2.0-0 libsm6 libxext6 libxrender-dev
12.
13.
# Install Miniconda
14.
RUN curl -so /miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
15.
&& chmod +x /miniconda.sh \
16.
&& /miniconda.sh -b -p /miniconda \
17.
&& rm /miniconda.sh
18.
19.
ENV PATH=/miniconda/bin:$PATH
20.
21.
# Create a Python 3.6 environment
22.
RUN /miniconda/bin/conda install -y conda-build \
23.
&& /miniconda/bin/conda create -y --name py36 python=3.6.7 \
24.
&& /miniconda/bin/conda clean -ya
25.
26.
ENV CONDA_DEFAULT_ENV=py36
27.
ENV CONDA_PREFIX=/miniconda/envs/$CONDA_DEFAULT_ENV
28.
ENV PATH=$CONDA_PREFIX/bin:$PATH
29.
ENV CONDA_AUTO_UPDATE_CONDA=false
30.
31.
RUN conda install -y ipython
32.
RUN pip install ninja yacs cython matplotlib opencv-python tqdm
33.
34.
35.
RUN pip install yacs cython
36.
#modify self
37.
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ninja cython matplotlib opencv-python tqdm
38.
39.
40.
# Install PyTorch 1.0 Nightly
41.
ARG CUDA
42.
#RUN conda install pytorch-nightly cudatoolkit=${CUDA} -c pytorch \
43.
# && conda clean -ya
44.
45.
#modify self
46.
RUN conda install pytorch torchvision cudatoolkit=${CUDA} \
47.
&& conda clean -ya
48.
49.
# Install TorchVision master
50.
#RUN git clone https://github.com/pytorch/vision.git \
51.
# && cd vision \
52.
# && python setup.py install
53.
54.
# install pycocotools
55.
RUN git clone https://github.com/cocodataset/cocoapi.git \
56.
&& cd cocoapi/PythonAPI \
57.
&& python setup.py build_ext install
58.
59.
# install PyTorch Detection
60.
ARG FORCE_CUDA="1"
61.
ENV FORCE_CUDA=${FORCE_CUDA}
62.
RUN git clone https://github.com/facebookresearch/maskrcnn-benchmark.git \
63.
&& cd maskrcnn-benchmark \
64.
&& python setup.py build develop
65.
66.
WORKDIR /maskrcnn-benchmark
需要说明的地方
1.
RUN conda install pytorch torchvision cudatoolkit=${CUDA} \2.
&& conda clean -ya
# Install TorchVision master 这一项的内容我注释掉,这一步我安装报错,因为torchvision 已经安装过了,所以注释掉这段尝试。
还有就是,这个安装过程可能会失败,需要多次尝试,如果一些包已经安装过了,可以在下次安装时候,不再安装这些包。
absl-py==0.10.0
astor==0.8.1
backports.functools-lru-cache==1.6.1
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
cycler==0.10.0
Cython==0.29.21
decorator==4.4.2
dill==0.2.8.2
# Editable install with no version control (fcos==0.1.9)-e /home/cbpm/wm/FCOS
Flask==1.0.2
flatbuffers==1.10
gast==0.4.0
graphviz==0.8.4
grpcio==1.31.0
h5py==2.10.0
idna==2.10
imageio==2.9.0
importlib-metadata==1.7.0
ipython==5.8.0
ipython-genutils==0.2.0
itsdangerous==1.1.0
Jinja2==2.11.2
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.2
kiwisolver==1.2.0
lmdb==0.93
Markdown==3.2.2
MarkupSafe==1.1.1
matplotlib==3.3.1
networkx==1.11
ninja==1.10.0.post1
numpy==1.19.1
onnx==1.4.1
onnx-tf==1.2.1
opencv-python==3.4.2.16
pexpect==4.8.0
pickleshare==0.7.5
Pillow==7.2.0
ply==3.11
prompt-toolkit==1.0.15
protobuf==3.13.0
psutil==5.6.2
ptyprocess==0.6.0
pycocotools==2.0
Pygments==2.6.1
pyparsing==2.4.7
python-dateutil==2.8.1
PyWavelets==1.1.1
PyYAML==5.3.1
redis==3.5.3
requests==2.24.0
ruamel.yaml==0.15.81
scikit-image==0.17.2
scipy==1.3.0
simplegeneric==0.8.1
six==1.15.0
termcolor==1.1.0
tifffile==2020.8.13
torch @ file:///home/cbpm/wm/torch-1.1.0-cp36-cp36m-linux_x86_64.whl
torchvision==0.2.1
tqdm==4.48.2
traitlets==4.3.3
typing==3.7.4.3
typing-extensions==3.7.4.2
urllib3==1.25.10
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1595859607677/work
Werkzeug==1.0.1
yacs==0.1.8
zipp==3.1.0