解决:python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure" 中Fa...

为运行Densepose安装Caffe2时遇到了两个问题:

1.python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"

Failure

2. python -c 'from caffe2.python import workspace; print(workspace.NumCudaD evices())'

TypeError: __init__() got an unexpected keyword argument 'serialized_options'

错误解决方法:

参考: https://blog.csdn.net/qq_41185868/article/details/82890135

安装正确版本的protobuf(其实就是3.6.1,我也不知道为什么默认使用conda install protobuf安装到的是错误版本)

 (pyDense3.6) Xdn@xwfx:~/.conda/envs/pyDense3.6/lib/python3.6/site-packages/torch/include$ conda install protobuf=3.6.1

完整输出如下:

A 错误输出:

1. (pyDense3.6) Xdn@xwfx:~/.conda/envs/pyDense3.6/lib/python3.6/site-packages/torch/include$ python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"

Failure

2. (pyDense3.6) Xdn@xwfx:~/.conda/envs/pyDense3.6/lib/python3.6/site-packages/torch/include$ python -c 'from caffe2.python import workspace; print(workspace.NumCudaD evices())'

Traceback (most recent call last):

  File "", line 1, in

  File "/home/Xdn/.local/lib/python3.6/site-packages/caffe2/python/__init__.py", line 2, in

    from caffe2.proto import caffe2_pb2

  File "/home/Xdn/.local/lib/python3.6/site-packages/caffe2/proto/__init__.py", line 11, in

    from caffe2.proto import caffe2_pb2, metanet_pb2, torch_pb2

  File "/home/Xdn/.local/lib/python3.6/site-packages/caffe2/proto/caffe2_pb2.py", line 23, in

    serialized_pb=_b('\n\x19\x63\x61\x66\x66\x65\x32/proto/caffe2.proto\x12\x06\x63\x61\x66\x66\x65\x32\"\xe1\x01\n\x11\x45xternalDataProto\x12K\n\x0bsource_type\                      x18\x01 \x01(\x0e\x32$.caffe2.ExternalDataProto.SourceType:\x10INLINE_CONTAINER\x12\x11\n\trecord_id\x18\x02 \x01(\t\x12\x13\n\x0brecord_size\x18\x05 \x01(\x04\x1                      2\x11\n\x06offset\x18\x03 \x01(\x03:\x01\x30\x12\x0f\n\x07strides\x18\x04 \x03(\x03\"3\n\nSourceType\x12\x14\n\x10INLINE_CONTAINER\x10\x00\x12\x0f\n\x0bSIMPLE_FIL                      E\x10\x01\"\xd1\x05\n\x0bTensorProto\x12\x0c\n\x04\x64ims\x18\x01 \x03(\x03\x12\x36\n\tdata_type\x18\x02 \x01(\x0e\x32\x1c.caffe2.TensorProto.DataType:\x05\x46LOA                      T\x12<\n\x0cstorage_type\x18\x0c \x01(\x0e\x32\x1f.caffe2.TensorProto.StorageType:\x05TYPED\x12\x16\n\nfloat_data\x18\x03 \x03(\x02\x42\x02\x10\x01\x12\x16\n\nint                      32_data\x18\x04 \x03(\x05\x42\x02\x10\x01\x12\x11\n\tbyte_data\x18\x05 \x01(\x0c\x12\x13\n\x0bstring_data\x18\x06 \x03(\x0c\x12\x17\n\x0b\x64ouble_data\x18\t \x03                      (\x01\x42\x02\x10\x01\x12\x16\n\nint64_data\x18\n \x03(\x03\x42\x02\x10\x01\x12\x10\n\x08raw_data\x18\r \x01(\x0c\x12\x30\n\rexternal_data\x18\x0e \x01(\x0b\x32\x                      19.caffe2.ExternalDataProto\x12\x0c\n\x04name\x18\x07 \x01(\t\x12+\n\rdevice_detail\x18\x08 \x01(\x0b\x32\x14.caffe2.DeviceOption\x12,\n\x07segment\x18\x0b \x01(\                      x0b\x32\x1b.caffe2.TensorProto.Segment\x1a%\n\x07Segment\x12\r\n\x05\x62\x65gin\x18\x01 \x02(\x03\x12\x0b\n\x03\x65nd\x18\x02 \x02(\x03\"\x9f\x01\n\x08\x44\x61taT                      ype\x12\r\n\tUNDEFINED\x10\x00\x12\t\n\x05\x46LOAT\x10\x01\x12\t\n\x05INT32\x10\x02\x12\x08\n\x04\x42YTE\x10\x03\x12\n\n\x06STRING\x10\x04\x12\x08\n\x04\x42OOL\x1                      0\x05\x12\t\n\x05UINT8\x10\x06\x12\x08\n\x04INT8\x10\x07\x12\n\n\x06UINT16\x10\x08\x12\t\n\x05INT16\x10\t\x12\t\n\x05INT64\x10\n\x12\x0b\n\x07\x46LOAT16\x10\x0c\x                      12\n\n\x06\x44OUBLE\x10\r\"?\n\x0bStorageType\x12\t\n\x05TYPED\x10\x01\x12\x07\n\x03RAW\x10\x02\x12\x0c\n\x08\x45XTERNAL\x10\x03\x12\x0e\n\nNO_CONTENT\x10\x04\"\x                      83\x02\n\x0cQTensorProto\x12\x0c\n\x04\x64ims\x18\x01 \x03(\x03\x12\x11\n\tprecision\x18\x02 \x02(\x05\x12\r\n\x05scale\x18\x03 \x02(\x01\x12\x0c\n\x04\x62ias\x18                      \x04 \x02(\x01\x12\x11\n\tis_signed\x18\x05 \x02(\x08\x12\x10\n\x04\x64\x61ta\x18\x06 \x03(\x05\x42\x02\x10\x01\x12\x0c\n\x04name\x18\x07 \x01(\t\x12\x36\n\tdata_                      type\x18\x08 \x01(\x0e\x32\x1c.caffe2.TensorProto.DataType:\x05INT32\x12\x0e\n\x06scales\x18\t \x03(\x01\x12\x0e\n\x06\x62iases\x18\n \x03(\x01\x12\x0c\n\x04\x61x                      is\x18\x0b \x01(\x05\x12\x1c\n\ris_multiparam\x18\x0c \x01(\x08:\x05\x66\x61lse\"3\n\x0cTensorProtos\x12#\n\x06protos\x18\x01 \x03(\x0b\x32\x13.caffe2.TensorProto                      \"\x95\x01\n\x0bTensorShape\x12\x0c\n\x04\x64ims\x18\x01 \x03(\x03\x12\x36\n\tdata_type\x18\x02 \x01(\x0e\x32\x1c.caffe2.TensorProto.DataType:\x05\x46LOAT\x12\x14                      \n\x0cunknown_dims\x18\x03 \x03(\x05\x12\x1c\n\runknown_shape\x18\x04 \x01(\x08:\x05\x66\x61lse\x12\x0c\n\x04name\x18\x05 \x01(\t\"3\n\x0cTensorShapes\x12#\n\x06s                      hapes\x18\x01 \x03(\x0b\x32\x13.caffe2.TensorShape\"\x8f\x02\n\x08\x41rgument\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\t\n\x01\x66\x18\x02 \x01(\x02\x12\t\n\x01i\x18                      \x03 \x01(\x03\x12\t\n\x01s\x18\x04 \x01(\x0c\x12\x1e\n\x01t\x18\n \x01(\x0b\x32\x13.caffe2.TensorProto\x12\x19\n\x01n\x18\x08 \x01(\x0b\x32\x0e.caffe2.NetDef\x12                      \x0e\n\x06\x66loats\x18\x05 \x03(\x02\x12\x0c\n\x04ints\x18\x06 \x03(\x03\x12\x0f\n\x07strings\x18\x07 \x03(\x0c\x12$\n\x07tensors\x18\x0b \x03(\x0b\x32\x13.caffe                      2.TensorProto\x12\x1c\n\x04nets\x18\t \x03(\x0b\x32\x0e.caffe2.NetDef\x12&\n\x08qtensors\x18\x0c \x03(\x0b\x32\x14.caffe2.QTensorProto\"\x8b\x01\n\x0c\x44\x65vice                      Option\x12\x16\n\x0b\x64\x65vice_type\x18\x01 \x01(\x05:\x01\x30\x12\x11\n\tdevice_id\x18\x02 \x01(\x05\x12\x13\n\x0brandom_seed\x18\x03 \x01(\r\x12\x11\n\tnode_n                      ame\x18\x04 \x01(\t\x12\x14\n\x0cnuma_node_id\x18\x05 \x01(\x05\x12\x12\n\nextra_info\x18\x06 \x03(\t\"\x92\x02\n\x0bOperatorDef\x12\r\n\x05input\x18\x01 \x03(\t\                      x12\x0e\n\x06output\x18\x02 \x03(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x0c\n\x04type\x18\x04 \x01(\t\x12\x1d\n\x03\x61rg\x18\x05 \x03(\x0b\x32\x10.caffe2.Argum                      ent\x12+\n\rdevice_option\x18\x06 \x01(\x0b\x32\x14.caffe2.DeviceOption\x12\x0e\n\x06\x65ngine\x18\x07 \x01(\t\x12\x15\n\rcontrol_input\x18\x08 \x03(\t\x12\x1d\n\                      x0eis_gradient_op\x18\t \x01(\x08:\x05\x66\x61lse\x12\x12\n\ndebug_info\x18\n \x01(\t\x12\x0e\n\x06\x64omain\x18\x0b \x01(\t\x12\x12\n\nop_version\x18\x0c \x01(\x                      03\"\xdb\x01\n\x06NetDef\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1f\n\x02op\x18\x02 \x03(\x0b\x32\x13.caffe2.OperatorDef\x12\x0c\n\x04type\x18\x03 \x01(\t\x12\x17\                      n\x0bnum_workers\x18\x04 \x01(\x05\x42\x02\x18\x01\x12+\n\rdevice_option\x18\x05 \x01(\x0b\x32\x14.caffe2.DeviceOption\x12\x1d\n\x03\x61rg\x18\x06 \x03(\x0b\x32\x                      10.caffe2.Argument\x12\x16\n\x0e\x65xternal_input\x18\x07 \x03(\t\x12\x17\n\x0f\x65xternal_output\x18\x08 \x03(\t\"\xcf\x02\n\rExecutionStep\x12\x0c\n\x04name\x18                      \x01 \x01(\t\x12&\n\x07substep\x18\x02 \x03(\x0b\x32\x15.caffe2.ExecutionStep\x12\x0f\n\x07network\x18\x03 \x03(\t\x12\x10\n\x08num_iter\x18\x04 \x01(\x03\x12\x1c                      \n\x10\x63riteria_network\x18\x05 \x01(\tB\x02\x18\x01\x12\x12\n\nreport_net\x18\x07 \x01(\t\x12\x17\n\x0freport_interval\x18\x08 \x01(\x05\x12\x14\n\x0crun_every                      _ms\x18\x0b \x01(\x03\x12\x1b\n\x13\x63oncurrent_substeps\x18\x06 \x01(\x08\x12\x18\n\x10should_stop_blob\x18\t \x01(\t\x12\x11\n\tonly_once\x18\n \x01(\x08\x12\x                      18\n\x10\x63reate_workspace\x18\x0c \x01(\x08\x12 \n\x18num_concurrent_instances\x18\r \x01(\x05\"g\n\x07PlanDef\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1f\n\x07ne                      twork\x18\x02 \x03(\x0b\x32\x0e.caffe2.NetDef\x12-\n\x0e\x65xecution_step\x18\x03 \x03(\x0b\x32\x15.caffe2.ExecutionStep\"\xba\x01\n\tBlobProto\x12\x0c\n\x04name\                      x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\t\x12#\n\x06tensor\x18\x03 \x01(\x0b\x32\x13.caffe2.TensorProto\x12\x0f\n\x07\x63ontent\x18\x04 \x01(\x0c\x12%\n\x                      07qtensor\x18\x05 \x01(\x0b\x32\x14.caffe2.QTensorProto\x12\x1a\n\x12\x63ontent_num_chunks\x18\x06 \x01(\x05\x12\x18\n\x10\x63ontent_chunk_id\x18\x07 \x01(\x05\"K                      \n\rDBReaderProto\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06source\x18\x02 \x01(\t\x12\x0f\n\x07\x64\x62_type\x18\x03 \x01(\t\x12\x0b\n\x03key\x18\x04 \x01(\                      t*\xfa\x01\n\x0f\x44\x65viceTypeProto\x12\r\n\tPROTO_CPU\x10\x00\x12\x0e\n\nPROTO_CUDA\x10\x01\x12\x10\n\x0cPROTO_MKLDNN\x10\x02\x12\x10\n\x0cPROTO_OPENGL\x10\x03                      \x12\x10\n\x0cPROTO_OPENCL\x10\x04\x12\x0f\n\x0bPROTO_IDEEP\x10\x05\x12\r\n\tPROTO_HIP\x10\x06\x12\x0e\n\nPROTO_FPGA\x10\x07\x12\x0f\n\x0bPROTO_MSNPU\x10\x08\x12\                      r\n\tPROTO_XLA\x10\t\x12\'\n#PROTO_COMPILE_TIME_MAX_DEVICE_TYPES\x10\n\x12\x19\n\x13PROTO_ONLY_FOR_TEST\x10\xa5\xa3\x01')

TypeError: __init__() got an unexpected keyword argument 'serialized_options'

B 正确输出

(pyDense3.6) Xdn@xwfx:~/.conda/envs/pyDense3.6/lib/python3.6/site-packages/torch/include$ python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"

Success

(pyDense3.6) Xdn@xwfx:~/.conda/envs/pyDense3.6/lib/python3.6/site-packages/torch/include$ python -c 'from caffe2.python import workspace; print(workspace.NumCudaD                      evices())'

4

你可能感兴趣的:(解决:python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure" 中Fa...)