Detectron python2.7安装
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Detectron python2.7安装,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4976字,纯文字阅读大概需要8分钟。
内容图文
![Detectron python2.7安装](/upload/InfoBanner/zyjiaocheng/848/6566d2477ec547c2804535cdc57417e6.jpg)
---恢复内容开始---
接上一篇重装系统后。
要和先前的工作接轨,所以还得安装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) wang@wang:~/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) wang@wang:~/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
内容总结
以上是互联网集市为您收集整理的Detectron python2.7安装全部内容,希望文章能够帮你解决Detectron python2.7安装所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。