Python interface error: did not match C++ signature

1,460 views
Skip to first unread message

Jiaxu Zhu

unread,
Nov 12, 2015, 2:22:12 AM11/12/15
to Caffe Users
I ran into some problem when I tried to run python interface of caffe on Ubuntu 15.10
The error is 

Traceback (most recent call last):
  File "autoencoder.py", line 3, in <module>
    solver = caffe.SGDSolver(model_dir + 'md593_autoencoder_solver.prototxt')
Boost.Python.ArgumentError: Python argument types in
    SGDSolver.__init__(SGDSolver, str)
did not match C++ signature:
    __init__(_object*, std::string)

And my code is simple

solver = caffe.Net('/home/jiaxuzhu/developer/csd395/models/autoencoder/md593_autoencoder_solver.prototxt')
solver.solve()

The same code runs well on a old version ubuntu

Jan C Peters

unread,
Nov 12, 2015, 3:11:51 AM11/12/15
to Caffe Users
Is this python3? It might be an issue with str being unicode in python3, and no longer really matching std::string in c++. I think I also have run into this problem a while ago, but I am not sure how to solve it best.

Jan

yaa315...@gmail.com

unread,
Feb 14, 2019, 3:29:54 AM2/14/19
to Caffe Users
Context: CUDA9.0 Ubuntu18.04

I have tried modifying the _caffe.cpp file with its location of $CAFFE_ROOT/python/caffe


Modify the

* * *

Bp: : class_ < SGDSolver < Dtype >, bp: : outside the < Solver < Dtype > >,

315 from < SGDSolver < Dtype > >, boost: : noncopyable > (

316 "SGDSolver", bp: : init < string > ());

* * *


* * *

Bp: : class_ < SGDSolver < Dtype >, bp: : outside the < Solver < Dtype > >,

315 from < SGDSolver < Dtype > >, boost: : noncopyable > (

316 "SGDSolver", bp: : init < char * > ());

* * *

At least in my environment the problem was solved.

yaa315...@gmail.com

unread,
Feb 14, 2019, 3:30:04 AM2/14/19
to Caffe Users

yaa315...@gmail.com

unread,
Feb 14, 2019, 3:30:34 AM2/14/19
to Caffe Users

yaa315...@gmail.com

unread,
Feb 14, 2019, 3:30:44 AM2/14/19
to Caffe Users
Reply all
Reply to author
Forward
0 new messages