Detectron python2.7安装

---恢复内容开始---

接上一篇重装系统后。

要和先前的工作接轨,所以还得安装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

Detectron python2.7安装的相关文章

python2.7安装和uwsgi

python2.7安装和uwsgi tar zxf Python-2.7.13xxxx# 这里,必须用–enable-shared,生成动态库,否则会遇到wsgi不能编译的问题. Bonus: multiple Python versions for the same uWSGI binary As we have seen, uWSGI is composed of a small core and various plugins. Plugins can be embedded in the

云服务器的python2.7安装

2. 安装python2.7 机器自带python2.4.3版本:但是,很多新功能都是基于2.7来的:比如多进程.装饰器等: 于是,需要自己准备python环境了: python环境准备: wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz tar zxf Python-2.7.3.tgz cd Python-2.7.3 ./configure --prefix=/usr/local/python27 make make in

python2.7安装numpy报错:is not a supported wheel on...

python2.7安装numpy时报错信息如下: C:\Python27\Scripts>pip install "numpy-1.9.2+mkl-cp26-none-win_amd64.whl" numpy-1.9.2+mkl-cp26-none-win_amd64.whl is not a supported wheel on this platfor m. 错误原因: 事实上是因为,我的python为2.7版本,下载的numpy为2.6版本,所以错误. 解决方案: 参见:f

ubuntu Python2.7 安装PIL问题

$sudo easy_install PIL WARNING: '' not a valid package name; please use only.-separated package names in setup.py _imaging.c:75:20: fatal error: Python.h: 没有那个文件或目录 #include "Python.h" ^ compilation terminated. error: Setup script exited with er

python2.7安装etuptools-36.6.0报ascii&#39; codec can&#39;t decode byte 0xce in position 7问题

解决办法1: 原文链接:http://blog.csdn.net/all_over_servlet/article/details/45112221 修改编码为gbk,修改D:\Python27\Lib\ntpath.py(位置由个人python安装目录决定)文件中的def join(path, *paths)函数,在函数内第一行加入 reload(sys) sys.setdefaultencoding('gbk') 即: # Join two (or more) paths. def join

centos7下python2环境安装pip2、kazoo、bottle、beaker

摘自:https://mp.weixin.qq.com/s?src=11&timestamp=1576355125&ver=2034&signature=mNp2na6VjFzT9n3FiDC0ICOWiHP4UJnqa1oTvkwEzuc7LPHYEyveSSBfQOq9*kM7vFjS4xB7QNtHYAev9CgCtGC2U0tkVNf0L6hwTGFjhleUT3CkPqu61mlqP-GTdr*4&new=1 一.centos7 下为自带的python2.7安装p

【Python】python2.7 安装配置OpenCV2

环境:Ubuntu16.04 anaconda Python2.7 opencv2.4.13 安装opencv后 import cv2 遇到错误信息: No module named cv2 安装opencv时make的过程中会出现文件"cv2.so",它是连接OpenCV和python的关键文件.错误的原因就在于python找不到我们刚才提到的cv2.so文件 /usr/local/lib/python2.7中发现有两个文件夹,一个是dist-package,一个是site-pack

linux升级python2.7,安装pip,setuptools,zlib

1,在192.168.0.65装python2.7和PIP     #ssh 192.168.0.65         升级到python2.7     #cd /usr/local     #wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz         # tar zxvf Python-2.7.10.tgz     # cd Python-2.7.10     # mkdir /usr/local/Python

Python2.7安装GeoIP

https://pypi.python.org/pypi/GeoIP/ Requirements Python 2.5+ or 3.3+ GeoIP C Library 1.4.7 or greater Installation With pip: $ pip install GeoIP From source: $ python setup.py build$ python setup.py install 下载和安装Python 有个一个非常重要的步骤是我们使用的是make altinsta