leovandriel / caffe2_cpp_tutorial

C++ transcripts of the Caffe2 Python tutorials and other C++ example code
BSD 2-Clause "Simplified" License
431 stars 94 forks source link

Issue building model.cc #82

Open terranceliu opened 5 years ago

terranceliu commented 5 years ago

Hi, I'm running into an issue with set_device_type. Any ideas please?

[ 7%] Building CXX object CMakeFiles/caffe2_cpp.dir/src/caffe2/util/model.cc.o /home/tliu/Dev/caffe2_cpp_tutorial/src/caffe2/util/model.cc: In member function ‘void caffe2::ModelUtil::AddIterOps()’: /home/tliu/Dev/caffe2_cpp_tutorial/src/caffe2/util/model.cc:81:28: error: no matching function for call to ‘caffe2::DeviceOption::set_device_type(const DeviceType&)’ ->set_device_type(CPU); ^ In file included from /usr/include/caffe2/proto/caffe2_pb.h:4:0, from /usr/include/caffe2/core/context_base.h:7, from /usr/include/caffe2/core/context.h:10, from /usr/include/caffe2/core/storage.h:14, from /usr/include/caffe2/core/tensor.h:4, from /usr/include/caffe2/core/blob.h:14, from /usr/include/caffe2/core/net.h:13, from /home/tliu/Dev/caffe2_cpp_tutorial/src/caffe2/util/external.pb.h:6, from /home/tliu/Dev/caffe2_cpp_tutorial/src/caffe2/util/model.pb.h:34, from /home/tliu/Dev/caffe2_cpp_tutorial/src/caffe2/util/model.cc:1: /usr/include/caffe2/proto/caffe2.pb.h:4289:13: note: candidate: void caffe2::DeviceOption::set_device_type(google::protobuf::int32) inline void DeviceOption::set_device_type(::google::protobuf::int32 value) { ^ /usr/include/caffe2/proto/caffe2.pb.h:4289:13: note: no known conversion for argument 1 from ‘const DeviceType {aka const at::DeviceType}’ to ‘google::protobuf::int32 {aka int}’

jerryzh168 commented 5 years ago

we changed the proto name to PROTO_CPU to merge the DeviceType of pytorch and caffe2, so you'll need to use set_device_type(PROTO_CPU).