maskrcnn 环境搭建

1,GCC 4.9  GCC降级

~$ sudo apt-get install gcc-4.9 g++-4.9

--> Set "priority=100" for gcc-4.9 and "priority=50" for gcc-5.
~$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 100
~$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5.0 50

--> Set "priority=100" for g++-4.9 and "priority=50" for g++-5.
~$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 100
~$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5.0 50

2,安装cuda

sudo add-apt-repository ppa:graphics-drivers/ppa

sudo apt-get update

sudo apt-get install nvidia-390 nvidia-settings nvidia-prime 

(connect net )

sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb
sudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub#具体版本号不同可以使用tab键补全
sudo apt-get update
sudo apt-get install cuda

安装cuDNN

再次重申需要选择正确对应版本,选择的是cuDNN v7的版本

下载完成后,cd到文件文件目录,执行安装命令

sudo dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb#具体版本可能不同,不用复制这个命令

安装anaconda

从这里下载速度比较快,下载链接https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.0-Linux-x86_64.sh

cd到文件的目录,假如默认下载目录是download

cd download
bash Anaconda3-5.3.0-Linux-x86_64.sh#可使用tab补全

安装maskrcnn_benchmark

在cuda安装完成,gcc也成功降级之后,到这一步直接按照maskrcnn_benchmark的官方教程按照就可以了,只不过要安装opencv,就稍加修改。中文部分就是添加的部分

# first, make sure that your conda is setup properly with the right environment
# for that, check that `which conda`, `which pip` and `which python` points to the
# right path. From a clean conda env, this is what you need to do

conda create --name maskrcnn_benchmark
source activate maskrcnn_benchmark

#安装opencv
conda install -c conda-forge opencv
#安装opencv

# this installs the right pip and dependencies for the fresh python
conda install ipython

# maskrnn_benchmark and coco api dependencies
pip install ninja yacs cython matplotlib

# follow PyTorch installation in https://pytorch.org/get-started/locally/
# we give the instructions for CUDA 9.0
conda install pytorch-nightly -c pytorch

# install torchvision
cd ~/github
git clone https://github.com/pytorch/vision.git
cd vision
python setup.py install

# install pycocotools
cd ~/github
git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
python setup.py build_ext install

# install PyTorch Detection
cd ~/github
git clone https://github.com/facebookresearch/maskrcnn-benchmark.git
cd maskrcnn-benchmark
# the following will install the lib with
# symbolic links, so that you can modify
# the files if you want and won't need to
# re-build it
python setup.py build develop

# or if you are on macOS
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py build develop

#到这里发现opencv失效,但是conda list查看包还在
pip install opencv-python

附上demo的测试使用

cd demo
# by default, it runs on the GPU
# for best results, use min-image-size 800  显示我的驱动版本低
python webcam.py --min-image-size 800
# can also run it on the CPU  插上摄像头即可
python webcam.py --min-image-size 300 MODEL.DEVICE cpu
# or change the model that you want to use
python webcam.py --config-file ../configs/caffe2/e2e_mask_rcnn_R_101_FPN_1x_caffe2.yaml --min-image-size 300 MODEL.DEVICE cpu
# in order to see the probability heatmaps, pass --show-mask-heatmaps
python webcam.py --min-image-size 300 --show-mask-heatmaps MODEL.DEVICE cpu

 

 

你可能感兴趣的:(maskrcnn 环境搭建)