Caffe2源码编译踩到小坑

caffe2的编译安装非常顺利,一次成功!!!但是,当输入下面指令测试caffe2安装是否成功的时候,竟然输出Failure。

(Caffe) ubuntu@ubuntu-dell:~$ cd ~ && python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
Failure

难以置信,好奇心驱使我看看到底出现了啥问题

(Caffe) ubuntu@ubuntu-dell:~$ python
Python 2.7.12 (default, Jan 28 2018, 16:09:54) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>from  caffe2.python import core
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/pytorch/build/caffe2/python/core.py", line 14, in <module>
    from caffe2.proto import caffe2_pb2
  File "/home/ubuntu/pytorch/build/caffe2/proto/caffe2_pb2.py", line 163, in <module>
    options=None, file=DESCRIPTOR),
TypeError: __init__() got an unexpected keyword argument 'file'

一看竟然是protobuf的问题,不知道是bug还是版本问题,第一想法就是强硬一把,然后修改site-packages/protobuf-3.1.0-py2.7.egg/google/protobuf/descriper.py,将class FieldDescriptor(DescriptorBase)中初始化


 500   def __init__(self, name, full_name, index, number, type, cpp_type, label,
 501                default_value, message_type, enum_type, containing_type,
 502                is_extension, extension_scope, options=None,
 503                has_default_value=True, containing_oneof=None, json_name=None):

添加了file关键字,改为

 500   def __init__(self, name, full_name, index, number, type, cpp_type, label,
 501                default_value, message_type, enum_type, containing_type,
 502                is_extension, extension_scope, options=None,
 503                has_default_value=True, containing_oneof=None, json_name=None,file=None):

问题解决。

(Caffe) ubuntu@ubuntu-dell:~$ cd ~ && python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
Success


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值