Skip to content

Fixbug #3494 No to_python (by-value) converter found for C++ t…#3575

Merged
shelhamer merged 2 commits intoBVLC:masterfrom
errord:fix-boost-shared_ptr-caffe-Blob-float-no-register
Mar 4, 2016
Merged

Fixbug #3494 No to_python (by-value) converter found for C++ t…#3575
shelhamer merged 2 commits intoBVLC:masterfrom
errord:fix-boost-shared_ptr-caffe-Blob-float-no-register

Conversation

@errord
Copy link

@errord errord commented Jan 20, 2016

fixbug #3494 , register shared_ptr Blob Dtype

…ype: boost::shared_ptr<caffe::Blob<float> >
@errord errord changed the title fixbug #3494 No to_python (by-value) converter found for C++ t… Fixbug #3494 No to_python (by-value) converter found for C++ t… Jan 20, 2016
@errord
Copy link
Author

errord commented Jan 21, 2016

what is label JL? @shelhamer

@crowsonkb
Copy link
Contributor

It would be nice if this were merged. I'm having to merge it manually by hand to build on OS X, since Homebrew is packaging boost 1.60.0.

@shelhamer
Copy link
Member

@errord @crowsonkb Sorry, I can't reproduce this in master @ fe0f441. Can you give more details on your setup? I have compiled and tested pycaffe with boost 1.60.0_1 on OS X 10.11.3 without trouble.

@graphaelli
Copy link

I've also run into this. There is no error at build time but you can reproduce it by running tests. Specifically - python3 -m unittest test_solver.py:

Without this patch:

======================================================================
ERROR: test_net_memory (test_solver.TestSolver)
Check that nets survive after the solver is destroyed.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/caffe/python/caffe/test/test_solver.py", line 29, in setUp
    size=self.solver.net.blobs['label'].data.shape)
TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Net<float> >

======================================================================
ERROR: test_snapshot (test_solver.TestSolver)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/caffe/python/caffe/test/test_solver.py", line 29, in setUp
    size=self.solver.net.blobs['label'].data.shape)
TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Net<float> >

======================================================================
ERROR: test_solve (test_solver.TestSolver)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/caffe/python/caffe/test/test_solver.py", line 29, in setUp
    size=self.solver.net.blobs['label'].data.shape)
TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Net<float> >

----------------------------------------------------------------------
Ran 3 tests in 0.026s

FAILED (errors=3)

With:

.
----------------------------------------------------------------------
Ran 3 tests in 0.048s

OK

@ahundt
Copy link

ahundt commented Feb 29, 2016

I think I just reproduced the problem in #3575 on master with #3570 and #3613 applied (the latter two may not be relevant). When I applied #3575 I was able to continue on. Here is the trace:

Traceback (most recent call last):
File "/Users/athundt/source/eclipse/caffe/fcn-32s/eval-fcn-32s.py", line 17, in
net.blobs['data'].reshape(1, *in_.shape)
File "/Users/athundt/source/git/caffe/python/caffe/pycaffe.py", line 28, in _Net_blobs
return OrderedDict(zip(self._blob_names, self._blobs))
TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptrcaffe::Blob

± python --version
Python 2.7.11
OS X 10.11.3

/usr/local/Cellar/boost/1.60.0_1 (11,059 files, 123.0M) *
Built from source with: --with-mpi --without-single --without-static --c++11
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/boost.rb

@panovr
Copy link

panovr commented Mar 2, 2016

@shelhamer I hope this commit can be merged, because I also run into this problem, and my environment is Mac OS X 10.11.3, Xcode 7.2, Anaconda python 2.7.11, boost 1.6.0.

I verified and confirmed that the error below can be fixed by applying this commit.

======================================================================
ERROR: test_forward_backward (test_net.TestNet)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ylzhao/Project/caffe/python/caffe/test/test_net.py", line 45, in setUp
    size=self.net.blobs['label'].data.shape)
  File "caffe/pycaffe.py", line 28, in _Net_blobs
    return OrderedDict(zip(self._blob_names, self._blobs))
TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Blob<float> >

======================================================================
ERROR: test_inputs_outputs (test_net.TestNet)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ylzhao/Project/caffe/python/caffe/test/test_net.py", line 45, in setUp
    size=self.net.blobs['label'].data.shape)
  File "caffe/pycaffe.py", line 28, in _Net_blobs
    return OrderedDict(zip(self._blob_names, self._blobs))
TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Blob<float> >

======================================================================
ERROR: test_memory (test_net.TestNet)
Check that holding onto blob data beyond the life of a Net is OK
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ylzhao/Project/caffe/python/caffe/test/test_net.py", line 45, in setUp
    size=self.net.blobs['label'].data.shape)
  File "caffe/pycaffe.py", line 28, in _Net_blobs
    return OrderedDict(zip(self._blob_names, self._blobs))
TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Blob<float> >

======================================================================
ERROR: test_save_and_read (test_net.TestNet)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ylzhao/Project/caffe/python/caffe/test/test_net.py", line 45, in setUp
    size=self.net.blobs['label'].data.shape)
  File "caffe/pycaffe.py", line 28, in _Net_blobs
    return OrderedDict(zip(self._blob_names, self._blobs))
TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Blob<float> >

======================================================================
ERROR: test_net_memory (test_solver.TestSolver)
Check that nets survive after the solver is destroyed.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ylzhao/Project/caffe/python/caffe/test/test_solver.py", line 29, in setUp
    size=self.solver.net.blobs['label'].data.shape)
TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Net<float> >

======================================================================
ERROR: test_snapshot (test_solver.TestSolver)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ylzhao/Project/caffe/python/caffe/test/test_solver.py", line 29, in setUp
    size=self.solver.net.blobs['label'].data.shape)
TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Net<float> >

======================================================================
ERROR: test_solve (test_solver.TestSolver)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ylzhao/Project/caffe/python/caffe/test/test_solver.py", line 29, in setUp
    size=self.solver.net.blobs['label'].data.shape)
TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Net<float> >

----------------------------------------------------------------------
Ran 21 tests in 1.499s

@shelhamer
Copy link
Member

Ok, I have reproduced the problem and the fix. Thanks for the patch!

shelhamer added a commit that referenced this pull request Mar 4, 2016
…float-no-register

[pycaffe] fix boost 1.60 compatibility issue; close #3494
@shelhamer shelhamer merged commit c2354b9 into BVLC:master Mar 4, 2016
.def("_set_input_arrays", &Net_SetInputArrays,
bp::with_custodian_and_ward<1, 2, bp::with_custodian_and_ward<1, 3> >())
.def("save", &Net_Save);
bp::register_ptr_to_python<shared_ptr<Net<Dtype> > >();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@longjon can you comment on this? It seems redundant to me given the bp::class_ declarations but boost 1.60 complains without it (on OS X at least).

@shelhamer
Copy link
Member

Note that this can cause harmless warnings for some boost versions. These are the warnings:

/home/ubuntu/caffe/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptrcaffe::Net already registered; second conversion method ignored.
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
/home/ubuntu/caffe/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptrcaffe::Blob already registered; second conversion method ignored.
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
/home/ubuntu/caffe/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptrcaffe::Solver already registered; second conversion method ignored.
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \

This happens for me at least with boost 1.59 on Ubuntu 14.04. This should maybe be conditioned on boost version/platform as gross as adding guards is. See #3866 for one attempt.

shelhamer added a commit to longjon/caffe that referenced this pull request Mar 4, 2016
shelhamer added a commit to shelhamer/caffe that referenced this pull request Mar 4, 2016
fxbit pushed a commit to Yodigram/caffe that referenced this pull request Sep 1, 2016
…lob-float-no-register

[pycaffe] fix boost 1.60 compatibility issue; close BVLC#3494
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

Comments