Error when importing caffe in Python

250 views
Skip to first unread message

Eduardo Sanchez Diaz

unread,
Nov 2, 2020, 4:09:26 AM11/2/20
to Caffe Users

Hi, 


I have installed caffe following the instructions in https://github.com/weiliu89/caffe/tree/ssd. Then I open Python and type import caffe and I get the following error:


Failed to include caffe_pb2, things might go wrong!

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/home/eduardo/dev/caffe/python/caffe/__init__.py", line 4, in <module>

    from .proto.caffe_pb2 import TRAIN, TEST

  File "/home/eduardo/dev/caffe/python/caffe/proto/caffe_pb2.py", line 22, in <module>

    create_key=_descriptor._internal_create_key,

AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'

Any ideas?

Thank you in advance for your help

My protobuf version is 3.13.0

My python version is 3.8.5

My OS is Ubuntu 20.04

The steps for the installation have been:

  1. Clone the repository https://github.com/weiliu89/caffe/tree/ssd
  2. cd caffe
  3. checkout ssd
  4. cp Makefile.config.example Makefile.config 
  5. Install cuda, atlas, openblas, atlas, boost, protobuf, glog, gflags, hdf5, lmdb, leveldb, buil-essentials package,  opencv
  6. make -j8
  7. make py
  8. make test -j8

Tamas Nemes

unread,
Nov 2, 2020, 11:02:23 AM11/2/20
to Caffe Users
This is obviousy something which isn't supposed to happen. When I installed caffe-ssd on my Ubuntu 20-system, I didn't came across the error, so I'm not entirely sure. However, you can take a look at this: https://stackoverflow.com/questions/61922334/how-to-solve-attributeerror-module-google-protobuf-descriptor-has-no-attribu
Most likely you have some issues with your Protobuf version, e.g. your Protoc (compiler) version does not match with your python-protobuf version. You can check their versions and see if either of them is outdated.
But, as I said, when you are normally installing Protobuf, this shouldn't happen. Take a look at my Caffe installation guide which is tested on Ubuntu 20.04 if you need further help: https://github.com/Totemi1324/caffe-installation-guide

Hope it helps!
Reply all
Reply to author
Forward
0 new messages