Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with Python support #116

Closed
XiaoMaol opened this issue Jul 20, 2017 · 4 comments
Closed

Help with Python support #116

XiaoMaol opened this issue Jul 20, 2017 · 4 comments

Comments

@XiaoMaol
Copy link

Hey @psyhtest , Thank you so much for helping me in the #114, and I can finally use Caffe in Mali GPU! Besides installing Caffe, I also like to use the python support. As a result, I use the command

ck install package:lib-caffe-bvlc-opencl-clblast-universal --env.DISABLE_DEVICE_HOST_UNIFIED_MEMORY=ON --env.CK_HOST_CPU_NUMBER_OF_PROCESSORS=2 --env.CAFFE_BUILD_PYTHON=ON

as suggested by you in #114 and the documentary about python support for ck-caffe.

However, after I run the command

 ck xset env tags=lib,caffe && . ./tmp-ck-env.bat && python

when I try to import caffe by command

import caffe

I got the finally error message:

>>> import caffe
/home/odroid/CK-TOOLS/lib-caffe-bvlc-opencl-clblast-master-gcc-5.4.0-linux-32/install/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for caffe::SolverParameter already registered; second conversion method ignored.
  from ._caffe import \
/home/odroid/CK-TOOLS/lib-caffe-bvlc-opencl-clblast-master-gcc-5.4.0-linux-32/install/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for std::vector<int, std::allocator<int> > already registered; second conversion method ignored.
  from ._caffe import \
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(.:27417): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/odroid/CK-TOOLS/lib-caffe-bvlc-opencl-clblast-master-gcc-5.4.0-linux-32/install/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import SolverParameter, NetParameter, NetState, Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
  File "/home/odroid/CK-TOOLS/lib-caffe-bvlc-opencl-clblast-master-gcc-5.4.0-linux-32/install/python/caffe/pycaffe.py", line 17, in <module>
    import caffe.io
  File "/home/odroid/CK-TOOLS/lib-caffe-bvlc-opencl-clblast-master-gcc-5.4.0-linux-32/install/python/caffe/io.py", line 2, in <module>
    import skimage.io
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/__init__.py", line 15, in <module>
    reset_plugins()
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 93, in reset_plugins
    _load_preferred_plugins()
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 73, in _load_preferred_plugins
    _set_plugin(p_type, preferred_plugins['all'])
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 85, in _set_plugin
    use_plugin(plugin, kind=plugin_type)
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 255, in use_plugin
    _load(name)
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 299, in _load
    fromlist=[modname])
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/_plugins/matplotlib_plugin.py", line 3, in <module>
    import matplotlib.pyplot as plt
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3agg.py", line 11, in <module>
    from . import backend_gtk3
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3.py", line 54, in <module>
    cursors.MOVE          : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
TypeError: constructor returned NULL

After Googling around, I find there is person with a similar issue here
BVLC/caffe#5495
But the person fixes it by building:

make pytest

But when use make pytest in a directory with Makefile.config, there would be many many bugs due to dependencies.
Could you give me some help?
Thanks!

@gfursin
Copy link
Contributor

gfursin commented Jul 23, 2017

Hi @XiaoMaol.

I tried to reproduce your error on Odroid, but didn't manage.

I compiled Caffe with python support using the command line you mentioned and it worked fine. I could run

$ ck xset env tags=lib,caffe && . ./tmp-ck-env.bat && ipython

and then

> import caffe

It worked fine.

Nevertheless I added an extra option to pass additional CMD after make. You can update ck-env repo and then try the following:

$ ck pull all
$ ck install package:lib-caffe-bvlc-opencl-clblast-universal --env.DISABLE_DEVICE_HOST_UNIFIED_MEMORY=ON --env.CK_HOST_CPU_NUMBER_OF_PROCESSORS=2 --env.CAFFE_BUILD_PYTHON=ON --env.CK_MAKE_CMD2="make pycaffe"

This should run "make pycaffe" after main make and before make install ...
Please, tell me if it will help ...

@XiaoMaol
Copy link
Author

Hey @gfursin, Thank you so much for offering help. I have tried the command you provided, and In the last few lines of the build of the Caffe I can see that pycaffe is built.
ck-caffe_issue3_1.
But whenever I try to import the caffe, I have encountered same error. I have tried to installed it twice. However, whenever I try to import caffe in python, I will get the same error.

>>> import caffe
/home/odroid/CK-TOOLS/lib-caffe-bvlc-opencl-clblast-master-gcc-5.4.0-linux-32/install/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for caffe::SolverParameter already registered; second conversion method ignored.
  from ._caffe import \
/home/odroid/CK-TOOLS/lib-caffe-bvlc-opencl-clblast-master-gcc-5.4.0-linux-32/install/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for std::vector<int, std::allocator<int> > already registered; second conversion method ignored.
  from ._caffe import \
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(.:14841): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/odroid/CK-TOOLS/lib-caffe-bvlc-opencl-clblast-master-gcc-5.4.0-linux-32/install/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import SolverParameter, NetParameter, NetState, Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
  File "/home/odroid/CK-TOOLS/lib-caffe-bvlc-opencl-clblast-master-gcc-5.4.0-linux-32/install/python/caffe/pycaffe.py", line 17, in <module>
    import caffe.io
  File "/home/odroid/CK-TOOLS/lib-caffe-bvlc-opencl-clblast-master-gcc-5.4.0-linux-32/install/python/caffe/io.py", line 2, in <module>
    import skimage.io
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/__init__.py", line 15, in <module>
    reset_plugins()
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 93, in reset_plugins
    _load_preferred_plugins()
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 73, in _load_preferred_plugins
    _set_plugin(p_type, preferred_plugins['all'])
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 85, in _set_plugin
    use_plugin(plugin, kind=plugin_type)
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 255, in use_plugin
    _load(name)
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 299, in _load
    fromlist=[modname])
  File "/usr/local/lib/python2.7/dist-packages/skimage/io/_plugins/matplotlib_plugin.py", line 3, in <module>
    import matplotlib.pyplot as plt
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3agg.py", line 11, in <module>
    from . import backend_gtk3
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3.py", line 54, in <module>
    cursors.MOVE          : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
TypeError: constructor returned NULL

@gfursin
Copy link
Contributor

gfursin commented Jul 24, 2017

Hmm, I have a feeling that it's not related to Caffe build, but to incomplete Python installation or missing dependencies. Did you install all deps:

sudo apt install coreutils \
                   build-essential \
                   make \
                   cmake \
                   wget \
                   git \
                   python \
                   python-pip

$ sudo apt install libboost-all-dev \
                   libgflags-dev \
                   libgoogle-glog-dev \
                   libhdf5-serial-dev \
                   liblmdb-dev \
                   libleveldb-dev \
                   libprotobuf-dev \
                   protobuf-compiler \
                   libsnappy-dev \
                   libopencv-dev
$ sudo pip install protobuf

I just can't reproduce this error :( ...

@XiaoMaol
Copy link
Author

Dear @gfursin:

I have figured out the problem:

The problem seems to be in the line

Failed to connect to Mir: Failed to connect to server socket: No such file or directory 
Unable to init server: Could not connect: Connection refused

and it can be fixed by

export DISPLAY=:0

But I ran into some problems running the example with jupyter, and I will open another issue for that.

Thank you so much for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants