---恢复内容开始---
接上一篇重装系统后。
要和先前的工作接轨,所以还得安装Detectron(https://github.com/facebookresearch/Detectron/blob/master/INSTALL.md);中间有个小插曲,就是刚巧看见原作者又发布的 maskrcnn-benchmark ,速度较 Detectron 快了一倍,等我屁颠的装完后,发现只能跑物体检测和语义分割,不能做关键点检测。所以还是得回到先前的Detectron上。
注意,这里需要的是Python2.7,而我之前安装了Anaconda3(Python3.5),怎么办呢? 利用conda创建一个虚拟环境,里面是Python2.7就好了。
>> conda create -n detectron_py27 python=2.7 #激活该环境的意思就是,优先使用该环境下的Python >> source activate detectron_py27 >> echo $PATH /home/wang/anaconda3/envs/detectron_py27/bin:/usr/local/cuda-9.0/bin:/home/wang/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin #退出该环境 source deactivate
然后就是安装caffe2以及cocoapi:
#直接安装pytorch1.0,里面包含了CAFFE2 >> conda install pytorch-nightly -c pytorch #接着是cocoapi >> cd ~/codes >> git clone https://github.com/cocodataset/cocoapi.git >> cd cocoapi/PythonAPI >> make install
最后安装detectron,由于我的代码是老一代版本,所以跟现在还是不一样的。
>> cd ~/codes >> git clone https://github.com/facebookresearch/detectron >> cd detectron/lib && make
然后就是测试是否安装成功,这里需要注意,由于是直接用conda安装的caffe2,因此其lib文件并不在 /usr/local下,所以测试时,会报错
(detectron_py27) [email protected]:~/codes/detectron_old$ python tests/test_spatial_narrow_as_op.py No handlers could be found for logger "caffe2.python.net_drawer" net_drawer will not run correctly. Please install the correct dependencies. [E init_intrinsics_check.cc:43] CPU feature avx is present on your machine, but the Caffe2 binary is not compiled with it. It means you may not get the full speed of your CPU. [E init_intrinsics_check.cc:43] CPU feature avx2 is present on your machine, but the Caffe2 binary is not compiled with it. It means you may not get the full speed of your CPU. [E init_intrinsics_check.cc:43] CPU feature fma is present on your machine, but the Caffe2 binary is not compiled with it. It means you may not get the full speed of your CPU. Traceback (most recent call last): File "tests/test_spatial_narrow_as_op.py", line 88, in <module> utils.c2.import_detectron_ops() File "/home/wang/codes/detectron_old/lib/utils/c2.py", line 41, in import_detectron_ops detectron_ops_lib = envu.get_detectron_ops_lib() File "/home/wang/codes/detectron_old/lib/utils/env.py", line 71, in get_detectron_ops_lib (‘Detectron ops lib not found; make sure that your Caffe2 ‘ AssertionError: Detectron ops lib not found; make sure that your Caffe2 version includes Detectron module
打印一下变量prefixes中保存的路径:
[u‘/usr/local‘, ‘/home/wang/anaconda3/envs/detectron_py27‘, ‘/home/wang/anaconda3/envs/detectron_py27‘, ‘/home/wang/codes/detectron_old/tests‘, ‘/home/wang/anaconda3/envs/detectron_py27/lib/python27.zip‘, ‘/home/wang/anaconda3/envs/detectron_py27/lib/python2.7‘, ‘/home/wang/anaconda3/envs/detectron_py27/lib/python2.7/plat-linux2‘, ‘/home/wang/anaconda3/envs/detectron_py27/lib/python2.7/lib-tk‘, ‘/home/wang/anaconda3/envs/detectron_py27/lib/python2.7/lib-old‘, ‘/home/wang/anaconda3/envs/detectron_py27/lib/python2.7/lib-dynload‘, ‘/home/wang/.local/lib/python2.7/site-packages‘, ‘/home/wang/codes/detectron_old/lib‘, ‘/home/wang/anaconda3/envs/detectron_py27/lib/python2.7/site-packages‘, ‘/home/wang/anaconda3/envs/detectron_py27/lib/python2.7/site-packages/pycocotools-2.0-py2.7-linux-x86_64.egg‘, ‘/home/wang/anaconda3/envs/detectron_py27/lib/python2.7/site-packages‘]
而libcaffe2_detectron_ops_gpu.so存在的路径却是
‘/home/wang/anaconda3/pkgs/pytorch-nightly-1.0.0.dev20181029-py2.7_cuda9.0.176_cudnn7.1.2_0/lib/python2.7/site-packages/torch/lib/libcaffe2_detectron_ops_gpu.so’
所以需要将此路径添加到 prefixes 中。保存 detectron/lib/utils/env.py 重新测试,就通过了。
(detectron_py27) [email protected]:~/codes/detectron_old$ python tests/test_spatial_narrow_as_op.py No handlers could be found for logger "caffe2.python.net_drawer" net_drawer will not run correctly. Please install the correct dependencies. [E init_intrinsics_check.cc:43] CPU feature avx is present on your machine, but the Caffe2 binary is not compiled with it. It means you may not get the full speed of your CPU. [E init_intrinsics_check.cc:43] CPU feature avx2 is present on your machine, but the Caffe2 binary is not compiled with it. It means you may not get the full speed of your CPU. [E init_intrinsics_check.cc:43] CPU feature fma is present on your machine, but the Caffe2 binary is not compiled with it. It means you may not get the full speed of your CPU. Found Detectron ops lib: /home/wang/anaconda3/pkgs/pytorch-nightly-1.0.0.dev20181029-py2.7_cuda9.0.176_cudnn7.1.2_0/lib/python2.7/site-packages/torch/lib/libcaffe2_detectron_ops_gpu.so ... ---------------------------------------------------------------------- Ran 3 tests in 3.125s OK
原文地址:https://www.cnblogs.com/caffeaoto/p/9878657.html
时间: 2024-10-31 05:43:13