硬件环境:
系统: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。
# 移除旧版本,如果没有安装旧版本也可以正常执行
sudo apt-get remove docker docker-engine docker.io containerd runc
# 更新源
sudo apt-get update
# 安装支持apt使用https下载的包
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
# 添加GPG key,用于官方发布的软件包签名,校验软件是否被修改过
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# 通过搜索key的后8位0EBFCD88,查看key是否获取成功
sudo apt-key fingerprint 0EBFCD88
# 添加docker源
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# 更新源
sudo apt-get update
# 安装docker ce
sudo apt-get install docker-ce docker-ce-cli containerd.io
zhexiebao测试
# 测试是否安装成功,会自动下载测试镜像
$ sudo docker run hello-world
# 输出如下:
# Unable to find image 'hello-world:latest' locally
# latest: Pulling from library/hello-world
# 1b930d010525: Pull complete
# Digest: # sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e
# Status: Downloaded newer image for hello-world:latest
# Hello from Docker!
# This message shows that your installation appears to be working correctly.
# ...
查看版本
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,仅供参考
ARG CUDA="9.0"
ARG CUDNN="7"
FROM nvidia/cuda:${CUDA}-cudnn${CUDNN}-devel-ubuntu16.04
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
# install basics
RUN apt-get update -y \
&& apt-get install -y apt-utils git curl ca-certificates bzip2 cmake tree htop bmon iotop g++ \
&& apt-get install -y libglib2.0-0 libsm6 libxext6 libxrender-dev
# Install Miniconda
RUN curl -so /miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& chmod +x /miniconda.sh \
&& /miniconda.sh -b -p /miniconda \
&& rm /miniconda.sh
ENV PATH=/miniconda/bin:$PATH
# Create a Python 3.6 environment
RUN /miniconda/bin/conda install -y conda-build \
&& /miniconda/bin/conda create -y --name py36 python=3.6.7 \
&& /miniconda/bin/conda clean -ya
ENV CONDA_DEFAULT_ENV=py36
ENV CONDA_PREFIX=/miniconda/envs/$CONDA_DEFAULT_ENV
ENV PATH=$CONDA_PREFIX/bin:$PATH
ENV CONDA_AUTO_UPDATE_CONDA=false
RUN conda install -y ipython
RUN pip install ninja yacs cython matplotlib opencv-python tqdm
RUN pip install yacs cython
#modify self
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ninja cython matplotlib opencv-python tqdm
# Install PyTorch 1.0 Nightly
ARG CUDA
#RUN conda install pytorch-nightly cudatoolkit=${CUDA} -c pytorch \
# && conda clean -ya
#modify self
RUN conda install pytorch torchvision cudatoolkit=${CUDA} \
&& conda clean -ya
# Install TorchVision master
#RUN git clone https://github.com/pytorch/vision.git \
# && cd vision \
# && python setup.py install
# install pycocotools
RUN git clone https://github.com/cocodataset/cocoapi.git \
&& cd cocoapi/PythonAPI \
&& python setup.py build_ext install
# install PyTorch Detection
ARG FORCE_CUDA="1"
ENV FORCE_CUDA=${FORCE_CUDA}
RUN git clone https://github.com/facebookresearch/maskrcnn-benchmark.git \
&& cd maskrcnn-benchmark \
&& python setup.py build develop
WORKDIR /maskrcnn-benchmark
需要说明的地方
# Install PyTorch 1.0 Nightly 我第一次安装失败,后来就改成了安装pytorch 而 不是 pytorch-nightly ,同时使用的不是官方的源,官方的源(-c pytorch 这个命令)真心下载慢失败,
RUN conda install pytorch torchvision cudatoolkit=${CUDA} \
&& conda clean -ya
# Install TorchVision master 这一项的内容我注释掉,这一步我安装报错,因为torchvision 已经安装过了,所以注释掉这段尝试。
还有就是,这个安装过程可能会失败,需要多次尝试,如果一些包已经安装过了,可以在下次安装时候,不再安装这些包。