- Detectron
安装准备:
CUDA
cuDNN
CAFFE2
目前电脑配置主要有:
台式机 RTX2070显卡
笔记本 1060显卡
2.1 Detectron 平台安装
CUDA
cuDNN
CAFFE2
Detectron平台安装
目前电脑配置主要有:
台式机 RTX2070显卡
笔记本 1060显卡
2.1.1 安装caffe2
- 安装caffe2
参考:
官方教程:https://caffe2.ai/docs/getting-started.html?platform=ubuntu&configuration=compile#install-with-gpu-support
sudo apt-get update
sudo apt-get install -y --no-install-recommends
build-essential
git
libgoogle-glog-dev
libgtest-dev
libiomp-dev
libleveldb-dev
liblmdb-dev
libopencv-dev
libopenmpi-dev
libsnappy-dev
libprotobuf-dev
openmpi-bin
openmpi-doc
protobuf-compiler
python-dev
python-pip
pip install --user
future
numpy
protobuf
typing
hypothesis
for Ubuntu 14.04
sudo apt-get install -y --no-install-recommends
libgflags2
cmake3
for Ubuntu 16.04
sudo apt-get install -y --no-install-recommends
libgflags-dev
cmake
安装方法1:
Clone Caffe2’s source code from our Github repository
git clone https://github.com/pytorch/pytorch.git && cd pytorch
git submodule update --init --recursive
Create a directory to put Caffe2’s build files in
mkdir build && cd build
Configure Caffe2’s build
This looks for packages on your machine and figures out which functionality
to include in the Caffe2 installation. The output of this command is very
useful in debugging.
cmake …
Compile, link, and install Caffe2
sudo make install
安装方法2:
官方安装方法,****ok
git clone https://github.com/pytorch/pytorch.git && cd pytorch
git submodule update --init --recursive
sudo python setup.py install
会在python文件夹下建立build文件夹
- 检查caffe2是否安装成功
Caffe2
To install Caffe2 with CUDA support, follow the from the . If you already have Caffe2 installed, make sure to update your Caffe2 to a version that includes the .
Please ensure that your Caffe2 installation was successful before proceeding by running the following commands and checking their output as directed in the comments.
To check if Caffe2 build was successful
在根目录下运行:
python -c ‘from caffe2.python import core’ 2>/dev/null && echo “Success” || echo “Failure”
To check if Caffe2 GPU build was successful
This must print a number > 0 in order to use Detectron
python -c ‘from caffe2.python import workspace; print(workspace.NumCudaDevices())’
If the caffe2 Python package is not found, you likely need to adjust your PYTHONPATH environment variable to include its location (/path/to/caffe2/build, where build is the Caffe2 CMake build directory).
2.1.2 增加环境变量
如果是failure,试着cd到caffe2/build的文件夹里,然后执行
python -c ‘from caffe2.python import core’ 2>/dev/null
如果successful,说明是环境变量的设置问题,如果还是失败,则会有具体的提示。
配置环境变量,编辑~/.bashrc
sudo gedit ~/.bashrc
添加以下内容:
export PYTHONPATH=/usr/local:PYTHONPATH:/home/pyhthon/build (后面路径为caffe2的编译路径,在caffe2/build中,命令行输入pwd可以得到这个路径)
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
添加完以后更新一下环境变量
source ~/.bashrc
2.1.3 错误与测试
1.附加测试:确保没有报错/usr/local/cuda-10.0/targets/x86_64-linux/lib/libcudnn.so.7 is not a symbolic link
cd /usr/local/lib
sudo ldconfig
/usr/local/cuda-9.0/targets/x86_64-linux/lib/libcudnn.so.7 is not a symbolic link解决方法 - 阿耀的博客 - ****博客
- 运行在python2 下错误:
错误1:
ERROR: Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-install-4HhZog/future/
解决:
python -m pip install --upgrade --force pip
pip install setuptools
结果:
Successfully installed setuptools-41.0.1
- 错误2:
Traceback (most recent call last):
File “/usr/bin/pip”, line 9, in
from pip import main
ImportError: cannot import name ‘main’
解决:
sudo gedit /usr/bin/pip
编辑
修改:
from pip import main # 需要修改
if name == ‘main’:
sys.exit(main._main()) # 需要修改
- 错误3:
RuntimeError: Missing build dependency: Unable toimport yaml
.
Please install it viaconda install pyyaml
orpip install pyyaml
解决:
pip install --user -i https://pypi.tuna.tsinghua.edu.cn/simple pyyaml
2.1.4 安装 COCO API
- 安装COCO API
Install the :
COCOAPI=/path/to/clone/cocoapi
git clone https://github.com/cocodataset/cocoapi.git $COCOAPI
cd $COCOAPI/PythonAPI
安装到全局第三方库中
sudo make install
Alternatively, if you do not have permissions or prefer
安装到用户Python库中
sudo python2 setup.py install --user
结果:
- 错误与解决
a) 错误1:
Makefile:7: recipe for target ‘install’ failed
make: *** [install] Error 1
解决:
安装make
sudo apt-get update
sudo apt-get install ubuntu-make
b) 错误2:
x86_64-linux-gnu-gcc: error: pycocotools/_mask.c: No such file or directory
x86_64-linux-gnu-gcc: fatal error: no input files
compilation terminated.
error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1
Makefile:3: recipe for target ‘all’ failed
解决方法:
pip install cython
pip install --user -i https://pypi.tuna.tsinghua.edu.cn/simple cython
2.1.5 安装 Detectron
- 安装Detectron
克隆Detectron存储库:
DETECTRON=/path/to/clone/detectron
git clone https://github.com/facebookresearch/detectron $DETECTRON
安装Python依赖项:
pip install --user -r $DETECTRON/requirements.txt
设置Python模块:
cd $DETECTRON && make
14) 测试Detectron
检查Detectron测试是否通过(例如):
python $DETECTRON/detectron/tests/test_spatial_narrow_as_op.py
- 错误与解决
错误
or: [Errno 13] Permission denied: ‘/home/lijie/.local/lib/python2.7/site-packages/easy-install.pth’
Makefile:17: recipe for target ‘dev’ failed
make: *** [dev] Error 1
解决:
安装make
sudo apt-get update
sudo apt-get install ubuntu-make