碎碎念.......
哇!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!我终于安装成功了caffe2.
Segmentation fault (core dumped)这个问题了,翻遍全网啊什么bing\google\github.都没用啊.还有我出现的奇奇怪怪的问题,几乎都是靠我自己解决了.我真是个厉害\坚持\漂亮\顽强\善良....集所有优点于一身的的女人!!!!!!!!!
(昨晚调到两点,躺床上大脑浑浊,突然想到一个可能的方法,就睡不着,干脆爬起来试一试.....额...尝试到两点五十,没用,哈哈哈哈.真是笑死我了.跟自己说早上最多一上午解决,不行就直接删了重建一次一次环境.今早我就不信邪(主要是我什么用pytorch的build\setup和caffe2的build\setup以及各种野方法试了不下十遍了,也重建了好几个虚拟环境,最好的结果也就是1)import caffe2可以 import caffe2.python可以 from caffe2.python import core 就是 分段故障(核心转储)
2)import caffe2可以 import caffe2.python分段故障(核心转储),
刚刚我又灵光一现(其实一大早就现了),但我总想着网上或者作者的解决办法,就放后了,真真是都不行了,我试了试我的灵光.
哈哈哈哈.果然还是个优秀的女人.)
Table of Contents
一 安装caffe2
官网方法安装:地址
1. anaconda,cuda,cudnn
2. gcc 版本
3.安装对应系统的nccl
4.opencv
5.cmake版本最低要求 3.2
6. Install Dependencies
7.Note libgflags2 is for Ubuntu 14.04. libgflags-dev is for Ubuntu 16.04.
8.Clone & Build
9.测试
10.记录下之前没gcc opencv nccl时候出现的
因为我搜了太多资料,所以记录下tips,或许你们可以去试试第二部分的内容,但我凭着一股倔劲,用这个方法安好了.想安装caffe2,有三种方法,要安装detectron的话一般是:
1) 这个方法,这是个轻量级的script,大概是说这个安装比较安全的,比较好,但好像也会出错吧,我试了一遍,出错我没改,但有人提出的解决办法是添加 -DUSE_OPENCV=OFF -DCUDA_HOME=/usr/local/cuda在下面命令下.具体参考其他人吧.
./scripts/build_anaconda.sh --install-locally --cuda 8.0 --cudnn 7
2) caffe2. 这个需要先build一下,但我没成功.这种下载完你会发现caffe2下只有三个.txt文件;因为隐藏了.ctrl+h可以显示.
3) pytorch.
这个有教程是建立build 再cmake 巴拉巴拉的;;还有python setup.py install 添加各种flags的,巴拉巴拉.
这里只记录我成功的,还有一些问题.要没问题直接走
libgflags2
is for Ubuntu 14.04. libgflags-dev
is for Ubuntu 16.04.综合参考:1 2 3
caffe2的cuda8预编译是gcc4.9以上的. gcc4.9以下的只有cuda9和cpu版本,而ubuntu14的gcc为4.8.对于gcc4.8和cuda8的caffe2没有预编译.先升级gcc.
1)安装
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
#如果是从来没有安装出错,则需要安装必要的依赖。
sudo apt-get install software-properties-common
sudo apt-get upgrade
sudo apt-get install gcc-4.9 g++-4.9
#还有个一步到位的,可尝试
sudo apt-get update && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update && \
sudo apt-get install software-properties-common -y && \
sudo apt-get upgrade && \
sudo apt-get install gcc-4.9 g++-4.9 -y
2) 安装完成之后,可以查看一下此时的版本号。
gcc -v
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
3)优先级.(可以改环境变量,没这个方便)
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 gcc-4.9优先60
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 gcc-4.8优先50
4) 切换
查看被update-alternatives管理的gcc不同版本,
sudo update-alternatives --query gcc
使用如下命令选择gcc版本:
sudo update-alternatives --config gcc
会打印出如下提示:
有 2 个候选项可用于替换 gcc (提供 /usr/bin/gcc)。
选择 路径 优先级 状态
------------------------------------------------------------
* 0 /usr/bin/gcc-4.9 60 自动模式
1 /usr/bin/gcc-4.8 50 手动模式
2 /usr/bin/gcc-4.9 60 手动模式
要维持当前值[*]请按回车键,或者键入选择的编号:
你还可以用
#方法2:命令行设置cmake参数
cmake -D CMAKE_C_COMPILER=/usr/local/bin/gcc-4.9 -D CMAKE_CXX_COMPILER=/usr/local/bin/g++-4.9 ..
#方法3:在CMakeList中设置变量
set(CMAKE_C_COMPILER "/usr/local/bin/gcc-4.9")
set(CMAKE_CXX_COMPILER "/usr/local/bin/g++-4.9")
备注:gcc6:
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update && \
sudo apt-get install gcc-snapshot -y && \
sudo apt-get update && \
sudo apt-get install gcc-6 g++-6 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \
sudo apt-get install gcc-4.8 g++-4.8 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8;
(不想安装的话,执行命令添加-DUSE_NCCL=ON,建议安装,不安装的话后来多GPU训练可能会有问题,就是安装带nccl的caffe2)
(参考http://blog.fangchengjin.cn/ubuntu-nccl2.html https://blog.csdn.net/zuyuhuo6777/article/details/81450258
1) 确保您的环境符合以下要求:
glibc 2.19或更高 .
CUDA 8.0或更高版本
NCCL支持所有具有3.0或更高计算能力的CUDA设备。查看所有NVIDIA GPU的计算能力?查看另一篇博文
2)安装NCCL
为了下载NCCL,请确保您已注册NVIDIA开发者账号。
打开NVIDIA NCCL主页。https://developer.nvidia.com/nccl
点击下载。
完成简短调查问卷并点击提交。
接受条款和条件。查看NCCL显示的可用下载版本列表。
选择您想要安装的NCCL版本。显示可用版本列表。根据您使用的Linux发行版以选择正确的软件包。
pan链接,提取码: 4wcn
3) Ubuntu 14.04 LTS和Ubuntu 16.04 LTS
在Ubuntu上安装NCCL需要您首先向包含NCCL软件包的APT系统添加存储库,然后通过APT 安装NCCL软件包,有两个存储库可用——本地存储库和网络存储库。建议选择更新版本以便在发布新版本时轻松升级。进入文件位置安装.注意看内容
①安装存储库(二选一)
对于本地NCCL存储库:sudo dpkg -i nccl-repo-
对于网络存储库:sudo dpkg -i nvidia-machine-learning-repo-ubuntu1404_4.0-2_amd64.deb
②更新APT数据库:sudo apt update
利用APT安装libnccl2。此外,如果您需要使用NCCL编译应用程序,则同时安装 libnccl-dev包。
1)如果您正在使用网络存储库,则使用以下命令。
sudo apt install libnccl2 libnccl-dev
2)如果您希望保留较旧版本的CUDA,请指定特定版本,(截图下面network有的)例如:
sudo apt-get install libnccl2=2.2.13-1+cuda8.0 libnccl-dev=2.2.13-1+cuda8.0
4) 成功
查看
~$:dpkg -l | grep nccl
ii libnccl-dev 2.2.13-1+cuda8.0 amd64 NVIDIA Collectives Communication Library (NCCL) Development Files
ii libnccl2 2.2.13-1+cuda8.0 amd64 NVIDIA Collectives Communication Library (NCCL) Runtime
有人说安装时候添加,-USE_OPENCV=1可以,我没试了.你们可以试试
我是因为要配置其他的,.txt文件的要求是opencv=3.4.1=py27_blas_openblas_200 但 cv2.__version__ 输出的是'3.3.1'
系统的cv2.__version__ '3.4.2'
$ conda install opencv=3.4.1=py27_blas_openblas_200
Fetching package metadata ...............
Solving package specifications: .
Package plan for installation in environment /home/vivian/anaconda3/envs/detect_and_track:
The following packages will be UPDATED:
blas: 1.0-openblas defaults --> 1.1-openblas https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
opencv: 3.3.1-py27hdcf4849_0 defaults --> 3.4.1-py27_blas_openblas_200 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge [blas_openblas]
scipy: 1.1.0-py27he2b7bc3_1 defaults --> 1.1.0-py27_blas_openblash7943236_201 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge [blas_openblas]
The following packages will be DOWNGRADED:
ffmpeg: 3.4-h7264315_0 defaults --> 3.2.4-3 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
numpy: 1.15.4-py27h99e49ec_0 defaults --> 1.15.2-py27_blas_openblashd3ea46f_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge [blas_openblas]
scikit-learn: 0.20.1-py27h22eb022_0 defaults --> 0.20.0-py27_blas_openblasha84fab4_201 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge [blas_openblas]
怕依赖冲突,在我的.txt文件找了下:
blas:没找到
scipy=1.0.1=py27_blas_openblas_200
numpy=1.14.2=py27_blas_openblas_200
scikit-learn=0.19.1=py27_blas_openblas_201
是不一样的 重新安装了下
cmake version 3.12.0
|
问题1: 安装caffe2依赖的第一步就失败了.摘录:
正在设置 libglib2.0-dev (2.40.2-0ubuntu1.1) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package libglib2.0-dev (--configure):
子进程 已安装 post-installation 脚本 返回了错误号 1
dpkg: dependency problems prevent configuration of libatk1.0-dev:
libatk1.0-dev 依赖于 libglib2.0-dev (>= 2.31.2);然而:
软件包 libglib2.0-dev 尚未配置。
.......
dpkg: dependency problems prevent configuration of libopencv-highgui-dev:amd64:
libo由于已经达到 MaxReports 限制,没有写入 apport 报告。
......
libopencv-dev 依赖于 libopencv-ocl-dev (= 2.4.8+dfsg1-2ubuntu1.2);然而:
软件包 libopencv
dpkg: error processing package libopencv-dev (--configure):
依赖关系问题 - 仍未被配置
在处理时有错误发生:
libglib2.0-dev
libatk1.0-dev
libcairo2-dev
libgdk-pixbuf2.0-dev
libpango1.0-dev
libgtk2.0-dev
libopencv-highgui-dev:amd64
libopencv-objdetect-dev:amd64
libopencv-legacy-dev:amd64
libopencv-ocl-dev:amd64
libcv-dev:amd64
libopencv-contrib-dev:amd64
libcvaux-dev:amd64
libhighgui-dev:amd64
libopencv-videostab-dev:amd64
libopencv-superres-dev:amd64
libopencv-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)
[解决办法]:(这个解决办法复制一个博主的,但打开链接太多,我也不知道是谁的了,不好意思)
$ sudo su //root权限
$ sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_old //现将info文件夹更名
$ sudo mkdir /var/lib/dpkg/info //再新建一个新的info文件夹
//更新
$ sudo apt-get update
$ apt-get -f install
$ sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_old
//执行完更新操作后会在info文件夹下生成一些文件,现将这些文件全部移到info_old文件夹下
$ sudo rm -rf /var/lib/dpkg/info // delete新建的info文件夹
$ sudo mv /var/lib/dpkg/info_old /var/lib/dpkg/info //把以前的info文件夹重新改回名字
#另外根据网上一些大神的谷歌结果:
//清除 /var/cache/apt/archives
apt-get clean
//安装所有我们需要的deb包,安装所需时间较长
apt-get --reinstall -dy install $(dpkg --get-selections | grep '[[:space:]]install' | cut -f1)
问题2):库里面的函数有所变动造成这个问题
~$ sudo pip install \ flask \ future \ graphviz \ hypothesis \ jupyter \ matplotlib \ pydot python-nvd3 \ pyyaml \ requests \ scikit-image \ scipy \ setuptools \ six \ tornado
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in
from pip import main
ImportError: cannot import name 'main'
[解决方法]
sudo gedit /usr/local/bin/pip
文件内容:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
将原来的最后部分改成:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from pip import __main__
if __name__ == '__main__':
#sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(__main__._main())
然后保存后使其生效
$ source ~/.bashrc
再次输入
sudo pip install xxx
此部分参考:https://blog.csdn.net/weixin_40208575/article/details/81392076
libgflags2
is for Ubuntu 14.04. libgflags-dev
is for Ubuntu 16.04. |
|
关于github解决慢的情况: git clone的问题.
当使用git clone下来的工程中带有submodule时,初始的时候,submodule的内容并不会自动下载下来的,此时,执行命令:git submodule update --init --recursive 即可将子模块内容下载下来后工程才不会缺少相应的文件。 你也可以#指定路径 |
1)如果错误,重新安装需要卸载,也需要等待一会儿~
python setup.py install --record files.txt #记录安装后文件的路径
cat files.txt | xargs rm -rf
1)验证是否安装成功:
~$:python2 -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
Success
~$:python2 -c 'from caffe2.python import workspace; print(workspace.NumCudaDevices())'
出现问题failure,考虑环境变量
出现问题:import caffe2可以 import caffe2.pythonSegmentation fault (core dumped) 跳出python
调试:
~$:python -v #可以看到具体过程
#很长 摘录首位
Python 2.7.14 |Anaconda custom (64-bit)| (default, Nov 8 2017, 22:44:41)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/home/vivian/anaconda3/envs/detect_and_track/lib/python2.7/lib-dynload/readline.so", 2);
import readline # dynamically loaded from /home/vivian/anaconda3/envs/detect_and_track/lib/python2.7/lib-dynload/readline.so
>>> import caffe2.python
import caffe2 # directory /home/vivian/HelloWorld/tracker/tools/pytorch/build/caffe2
# /home/vivian/HelloWorld/tracker/tools/pytorch/build/caffe2/__init__.pyc matches /home/vivian/HelloWorld/tracker/tools/pytorch/build/caffe2/__init__.py
import caffe2 # precompiled from /home/vivian/HelloWorld/tracker/tools/pytorch/build/caffe2/__init__.pyc
...
import subprocess # precompiled from /home/vivian/anaconda3/envs/detect_and_track/lib/python2.7/subprocess.pyc
import gc # builtin
dlopen("/home/vivian/anaconda3/envs/detect_and_track/lib/python2.7/lib-dynload/select.so", 2);
import select # dynamically loaded from /home/vivian/anaconda3/envs/detect_and_track/lib/python2.7/lib-dynload/select.so
# /home/vivian/anaconda3/envs/detect_and_track/lib/python2.7/pickle.pyc matches /home/vivian/anaconda3/envs/detect_and_track/lib/python2.7/pickle.py
import pickle # precompiled from /home/vivian/anaconda3/envs/detect_and_track/lib/python2.7/pickle.pyc
import marshal # builtin
dlopen("/home/vivian/anaconda3/envs/detect_and_track/lib/python2.7/site-packages/google/protobuf/pyext/_message.so", 2);
Segmentation fault (core dumped)
(detect_and_track) vivian@vivian-Super-Server:~$
看守最后一句是到dlopen("/home/vivian/anaconda3/envs/detect_and_track/lib/python2.7/site-packages/google/protobuf/pyext/_message.so", 2);出现Segmentation fault (core dumped)并跳出的.
[解决办法]:全局搜索_message.so
选择第二行的那个,替换出问题的那个(这个可能是和自己系统的冲突了)
Success
2)验证GPU(这步我不行,说没有文件)
python -m caffe2.python.operator_test.relu_op_test
出现
Ran 1 test in 0.661s OK
如果出现类似“ImportError: No module named caffe2.python”的错误的时候,则需要给系统添加一下Python的环境:
source gedit ~/.bashrc
export PYTHONPATH=/home/...../pytorch/build:$PYTHONPATH
source ~/.bashrc
重新打开一个新的终端窗口,并且激活虚拟环境,再次运行上面的测试程序就不会再出错了。
使用apt-get autoremove命令移除为了满足包依赖而安装的、但不再需要的包;使用apt-get clean命令清除所获得包文件的本地仓库。
查看安装记录
See also "/home/ray/caffe2/build/CMakeFiles/CMakeOutput.log".##安装几次都会记录的
See also "/home/ray/caffe2/build/CMakeFiles/CMakeError.log".
1)
>>> from caffe2.python import core
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name core
>>> import caffe2
>>> import caffe2.python
>>> from caffe2.python import workspace
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name workspace
>>> from caffe2.python import workspace
奇怪>>> import caffe2 和import caffe2.python都可以的
整个安装过程中没有出现问题,但是在验证的时候就会出现错误,环境变量也是安装教程所设置的,始终没有找到原因,重新安装折腾好几次。最后才发现,在终端中输入命令使其输出环境变量
echo $PYTHONPATH
经过查看才知道,Ubuntu中环境变量法并不是安装文档的前后顺序来进行排列的,是根据你修改的顺序,后来修改的环境变量会在前边。
出现种种问题时,先将其他环境变量注释即可。
此部分参考:https://blog.csdn.net/qq_35451572/article/details/79428167
2)为了避免使用apt-get install
安装基础软件的过程中需要进行交互操作,使用-y
参数来避免安装非必须的文件,从而减小镜像的体积。
apt-get -y --no-install-recommends install
3) 解决办法,安装nccl 或者=off的nag
In file included from /home/vivian/HelloWorld/tracker/tools/pytorch/torch/csrc/distributed/c10d/ddp.cpp:6:0:
/home/vivian/HelloWorld/tracker/tools/pytorch/torch/csrc/cuda/nccl.h:8:18: fatal error: nccl.h: No such file or directory
#include
^
compilation terminated.
[100%] Built target test_api
make[2]: *** [caffe2/torch/CMakeFiles/torch_python.dir/csrc/distributed/c10d/ddp.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [caffe2/torch/CMakeFiles/torch_python.dir/all] Error 2
make: *** [all] Error 2
Failed to run 'bash ../tools/build_pytorch_libs.sh --use-cuda --use-nnpack --use-mkldnn --use-qnnpack caffe2'
4.cmake指令
cmake -DCMAKE_PREFIX_PATH=/home/vivian/anaconda3/envs/detect_and_track -DCMAKE_INSTALL_PREFIX=/home/vivian/anaconda3/envs/detect_and_track ..
cmake -DCMAKE_PREFIX_PATH=/home/vivian/anaconda3/envs/caffe2 -DCMAKE_INSTALL_PREFIX=/home/vivian/anaconda3/envs/caffe2 ..
sudo cmake .. -DCMAKE_PREFIX_PATH=/home/vivian/anaconda3/envs/caffe2 -DUSE_MPI=OFF.
此时cmake会输出一堆配置信息。
-- ******** Summary ********
-- General:
-- CMake version : 3.12.0
-- CMake command : /home/vivian/anaconda3/lib/python3.5/site-packages/cmake/data/bin/cmake
-- System : Linux
-- C++ compiler : /usr/bin/c++
-- C++ compiler version : 4.8.4
-- BLAS : MKL
-- CXX flags : -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-unused-but-set-variable -Wno-maybe-uninitialized
-- Build type : Release
-- Compile definitions : ONNX_NAMESPACE=onnx_c2;USE_GCC_ATOMICS=1;HAVE_MMAP=1;_FILE_OFFSET_BITS=64;HAVE_SHM_OPEN=1;HAVE_SHM_UNLINK=1;HAVE_MALLOC_USABLE_SIZE=1
-- CMAKE_PREFIX_PATH : /home/vivian/anaconda3/envs/caffe2
-- CMAKE_INSTALL_PREFIX : /home/vivian/anaconda3/envs/caffe2
--
-- TORCH_VERSION : 1.0.0
-- CAFFE2_VERSION : 1.0.0
-- BUILD_ATEN_MOBILE : OFF
-- BUILD_ATEN_ONLY : OFF
-- BUILD_BINARY : OFF
-- BUILD_CUSTOM_PROTOBUF : ON
-- Link local protobuf : ON
-- BUILD_DOCS : OFF
-- BUILD_PYTHON : ON
-- Python version : 3.5.6
-- Python executable : /home/vivian/anaconda3/bin/python
-- Pythonlibs version : 3.5.6
-- Python library : python3.5m
-- Python includes : /home/vivian/anaconda3/include/python3.5m
-- Python site-packages: lib/python3.5/site-packages
-- BUILD_CAFFE2_OPS : ON
-- BUILD_SHARED_LIBS : ON
-- BUILD_TEST : OFF
-- USE_ASAN : OFF
-- USE_CUDA : ON
-- CUDA static link : OFF
-- USE_CUDNN : ON
-- CUDA version : 8.0
-- cuDNN version : 7.2.1
-- CUDA root directory : /usr/local/cuda
-- CUDA library : /usr/lib/x86_64-linux-gnu/libcuda.so
-- cudart library : /usr/local/cuda/lib64/libcudart_static.a;-pthread;dl;/usr/lib/x86_64-linux-gnu/librt.so
-- cublas library : /usr/local/cuda/lib64/libcublas.so;/usr/local/cuda/lib64/libcublas_device.a
-- cufft library : /usr/local/cuda/lib64/libcufft.so
-- curand library : /usr/local/cuda/lib64/libcurand.so
-- cuDNN library : /usr/local/cuda/lib64/libcudnn.so
-- nvrtc : /usr/local/cuda/lib64/libnvrtc.so
-- CUDA include path : /usr/local/cuda/include
-- NVCC executable : /usr/local/cuda/bin/nvcc
-- CUDA host compiler : /usr/bin/cc
-- USE_TENSORRT : OFF
-- USE_ROCM : OFF
-- USE_EIGEN_FOR_BLAS : ON
-- USE_FBGEMM : OFF
-- USE_FFMPEG : OFF
-- USE_GFLAGS : ON
-- USE_GLOG : ON
-- USE_LEVELDB : ON
-- LevelDB version : 1.15
-- Snappy version : 1.1.0
-- USE_LITE_PROTO : OFF
-- USE_LMDB : ON
-- LMDB version : 0.9.10
-- USE_METAL : OFF
-- USE_MKL : OFF
-- USE_MKLDNN : OFF
-- USE_MOBILE_OPENGL : OFF
-- USE_NCCL : ON
-- USE_SYSTEM_NCCL : OFF
-- USE_NNPACK : ON
-- USE_NUMPY : ON
-- USE_OBSERVERS : ON
-- USE_OPENCL : OFF
-- USE_OPENCV : ON
-- OpenCV version : 3.3.0
-- USE_OPENMP : OFF
-- USE_PROF : OFF
-- USE_QNNPACK : ON
-- USE_REDIS : OFF
-- USE_ROCKSDB : OFF
-- USE_ZMQ : OFF
-- USE_DISTRIBUTED : ON
-- USE_MPI : ON
-- USE_GLOO : ON
-- USE_GLOO_IBVERBS : OFF
-- Public Dependencies : Threads::Threads;glog::glog
-- Private Dependencies : qnnpack;nnpack;cpuinfo;/usr/lib/x86_64-linux-gnu/liblmdb.so;/usr/lib/x86_64-linux-gnu/libleveldb.so;/usr/lib/libsnappy.so;opencv_core;opencv_highgui;opencv_imgproc;opencv_imgcodecs;opencv_videoio;opencv_video;fp16;/usr/lib/libmpi_cxx.so;/usr/lib/libmpi.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libhwloc.so;gloo;aten_op_header_gen;onnxifi_loader;rt;gcc_s;gcc;dl
-- Configuring done
CMake Warning at c10/CMakeLists.txt:36 (add_library):
Cannot generate a safe runtime search path for target c10 because files in
some directories may conflict with libraries in implicit directories:
runtime library [libglog.so.0] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
/home/vivian/anaconda3/envs/detect_and_track/lib
Some of these libraries may not be found correctly.
.......
CMake Warning at cmake/Modules_CUDA_fix/upstream/FindCUDA.cmake:1839 (add_library):
Cannot generate a safe runtime search path for target
caffe2_detectron_ops_gpu because files in some directories may conflict
with libraries in implicit directories:
runtime library [libglog.so.0] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
/home/vivian/anaconda3/envs/detect_and_track/lib
Some of these libraries may not be found correctly.
Call Stack (most recent call first):
modules/detectron/CMakeLists.txt:8 (CUDA_ADD_LIBRARY)
CMake Warning at modules/observers/CMakeLists.txt:12 (add_library):
Cannot generate a safe runtime search path for target caffe2_observers
because files in some directories may conflict with libraries in implicit
directories:
runtime library [libglog.so.0] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
/home/vivian/anaconda3/envs/detect_and_track/lib
Some of these libraries may not be found correctly.
-- Generating done
-- Build files have been written to: /home/vivian/HelloWorld/tracker/tools/pytorch/build
........................
Public Dependencies : Threads::Threads;caffe2::mkl;glog::glog
-- Private Dependencies : qnnpack;nnpack;cpuinfo;/home/vivian/anaconda3/envs/detect_and_track/lib/liblmdb.so;/home/vivian/anaconda3/envs/detect_and_track/lib/libleveldb.so;/home/vivian/anaconda3/envs/detect_and_track/lib/libsnappy.so;opencv_core;opencv_highgui;opencv_imgproc;opencv_imgcodecs;opencv_videoio;opencv_video;fp16;/usr/lib/libmpi_cxx.so;/usr/lib/libmpi.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libhwloc.so;gloo;aten_op_header_gen;onnxifi_loader;rt;gcc_s;gcc;dl
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vivian/HelloWorld/tracker/tools/pytorch/build
记录方法二:
1) 确定 pybind11 and pandas
pip install pybind11 and pip install pandas==0.22.0.
记得记录pybind11的include位置
2) 源码安装nccl
3) 安装caffe2时,请注意首先使用cmake绑定pybind11,
cmake -Dpybind11_INCLUDE_DIR=/usr/local/include/python2.7/ #实际位置
4) 复制 lib/ops/affine_channel_nd_op.* 到 caffe2/modules/detectron/ if you meet some difficulties like I did.
编译、链接、安装caffe2
sudo make -j
sudo make install -j
5) 成功安装caffe2后,返回编译ops
cd ../DetectAndTrack/lib
make && make ops
6) 现在如果直接运行launch.py or test_on_single_video.py,可能有
Offending key: AffineChannelNd.
The key in lib/utils/c2.import_custom_ops() and another same key in lib/utils/c2.import_detectron_ops() seem to contradict to one another.
So I commented out line 56 in lib/utils/c2.import_custom_ops() as following
def import_custom_ops():
"""Import custom ops."""
custom_ops_lib = envu.get_custom_ops_lib()
#dyndep.InitOpsLibrary(custom_ops_lib)
Finally, go to lib and compile the custom ops
cd ../DetectAndTrack/lib
make && make ops
Now everything should work.
参考:https://blog.csdn.net/wanzhen4330/article/details/81706405
https://www.cnblogs.com/xzyzg/p/6735836.html
https://github.com/pytorch/pytorch/issues/8980