facebookarchive / tutorials

Caffe2 Tutorials
Apache License 2.0
124 stars 60 forks source link

[caffe2] RuntimeError in ParseProtoFromLargeString #3

Closed why702 closed 6 years ago

why702 commented 6 years ago

from future import absolute_import from future import division from future import print_function from future import unicode_literals from caffe2.python import core, workspace, models

with open('/home/bill/git/models/squeezenet/init_net.pb') as f: init_net = f.read() with open('/home/bill/git/models/squeezenet/predict_net.pb') as f: predict_net = f.read()

p = workspace.Predictor(init_net, predict_net)

when I run the p = workspace.Predictor(init_net, predict_net) and I got the below error. RuntimeError: [enforce fail at pybind_state.cc:761] ParseProtoFromLargeString( init_net.cast<std::string>(), &init_net_).

My environment: Ubuntu 16.04 Using pre-built caffe2 and build form caffe2 git source get the same results.

{'os.environ': {'CLUTTER_IM_MODULE': 'xim', 'COMPIZ_BIN_PATH': ['/usr/bin/'], 'COMPIZ_CONFIG_PROFILE': 'ubuntu', 'DBUS_SESSION_BUS_ADDRESS': 'unix:abstract=/tmp/dbus-PdonO4MXjJ', 'DEFAULTS_PATH': ['/usr/share/gconf/ubuntu.default.path'], 'DESKTOP_SESSION': 'ubuntu', 'DISPLAY': ':0', 'GDMSESSION': 'ubuntu', 'GDM_LANG': 'en_US', 'GIO_LAUNCHED_DESKTOP_FILE': '/home/bill/.local/share/applications/jetbrains-pycharm-ce.desktop', 'GIO_LAUNCHED_DESKTOP_FILE_PID': '22702', 'GNOME_DESKTOP_SESSION_ID': 'this-is-deprecated', 'GNOME_KEYRING_CONTROL': '', 'GNOME_KEYRING_PID': '', 'GPG_AGENT_INFO': '/home/bill/.gnupg/S.gpg-agent:0:1', 'GTK2_MODULES': 'overlay-scrollbar', 'GTK_IM_MODULE': 'ibus', 'GTK_MODULES': 'gail:atk-bridge:unity-gtk-module', 'HOME': '/home/bill', 'IM_CONFIG_PHASE': '1', 'INSTANCE': '', 'JOB': 'unity-settings-daemon', 'LANG': 'en_US.UTF-8', 'LANGUAGE': 'en_US', 'LC_ADDRESS': 'zh_TW.UTF-8', 'LC_IDENTIFICATION': 'zh_TW.UTF-8', 'LC_MEASUREMENT': 'zh_TW.UTF-8', 'LC_MONETARY': 'zh_TW.UTF-8', 'LC_NAME': 'zh_TW.UTF-8', 'LC_NUMERIC': 'zh_TW.UTF-8', 'LC_PAPER': 'zh_TW.UTF-8', 'LC_TELEPHONE': 'zh_TW.UTF-8', 'LC_TIME': 'zh_TW.UTF-8', 'LOGNAME': 'bill', 'MANDATORY_PATH': ['/usr/share/gconf/ubuntu.mandatory.path'], 'PAPERSIZE': 'a4', 'PATH': ['/home/bill/bin', '/home/bill/.local/bin', '/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/usr/games', '/usr/local/games', '/snap/bin'], 'PWD': '/home/bill/git/detectron', 'PYCHARM_HOSTED': '1', 'PYTHONIOENCODING': 'UTF-8', 'PYTHONPATH': ['/home/bill/git/caffe2/build', '/home/bill/git/detectron'], 'PYTHONUNBUFFERED': '1', 'QT4_IM_MODULE': 'xim', 'QT_ACCESSIBILITY': '1', 'QT_IM_MODULE': 'ibus', 'QT_LINUX_ACCESSIBILITY_ALWAYS_ON': '1', 'QT_QPA_PLATFORMTHEME': 'appmenu-qt5', 'SESSION': 'ubuntu', 'SESSIONTYPE': 'gnome-session', 'SESSION_MANAGER': 'local/bill-D830MT:@/tmp/.ICE-unix/1379,unix/bill-D830MT:/tmp/.ICE-unix/1379', 'SHELL': '/bin/bash', 'SHLVL': '0', 'SSH_AUTH_SOCK': '/run/user/1000/keyring/ssh', 'UNITY_DEFAULT_PROFILE': 'unity', 'UNITY_HAS_3D_SUPPORT': 'true', 'UPSTART_EVENTS': 'xsession started', 'UPSTART_INSTANCE': '', 'UPSTART_JOB': 'unity7', 'UPSTART_SESSION': 'unix:abstract=/com/ubuntu/upstart-session/1000/1143', 'USER': 'bill', 'XAUTHORITY': '/home/bill/.Xauthority', 'XDG_CONFIG_DIRS': '/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg', 'XDG_CURRENT_DESKTOP': 'Unity', 'XDG_DATA_DIRS': '/usr/share/ubuntu:/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop', 'XDG_GREETER_DATA_DIR': '/var/lib/lightdm-data/bill', 'XDG_MENU_PREFIX': 'gnome-', 'XDG_RUNTIME_DIR': '/run/user/1000', 'XDG_SEAT': 'seat0', 'XDG_SEAT_PATH': ['/org/freedesktop/DisplayManager/Seat0'], 'XDG_SESSION_DESKTOP': 'ubuntu', 'XDG_SESSION_ID': 'c1', 'XDG_SESSION_PATH': ['/org/freedesktop/DisplayManager/Session0'], 'XDG_SESSION_TYPE': 'x11', 'XDG_VTNR': '7', 'XMODIFIERS': '@im=ibus'}, 'pkg_resources.working_set': [wsgiref 0.1.2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7), Python 2.7.14 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/lib-dynload), pycocotools 2.0 (/home/bill/.local/lib/python2.7/site-packages), Detectron 0.0.0 (/home/bill/git/detectron/lib), widgetsnbextension 3.2.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), wheel 0.31.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), webencodings 0.5.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), wcwidth 0.1.7 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), traitlets 4.3.2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), tornado 5.0.2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), torch 0.3.1.post2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), testpath 0.3.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), terminado 0.8.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), subprocess32 3.2.7 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), six 1.11.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), singledispatch 3.4.0.3 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), simplegeneric 0.8.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), setuptools 39.0.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), Send2Trash 1.5.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), scipy 1.0.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), scikit-image 0.13.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), scandir 1.7 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), qtconsole 4.3.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), pyzmq 17.0.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), PyYAML 3.12 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), PyWavelets 0.5.2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), pytz 2018.4 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), python-dateutil 2.7.2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), pyparsing 2.2.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), Pygments 2.2.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), pycparser 2.18 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), ptyprocess 0.5.2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), protobuf 3.5.2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), prompt-toolkit 1.0.15 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), pip 10.0.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), Pillow 5.0.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), pickleshare 0.7.4 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), pexpect 4.5.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), pbr 4.0.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), pathlib2 2.3.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), pandocfilters 1.4.2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), opencv-python 3.4.0.12 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), olefile 0.45.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), numpy 1.14.2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), notebook 5.4.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), networkx 2.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), nbformat 4.4.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), nbconvert 5.3.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), mock 2.0.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), mkl-random 1.0.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), mkl-fft 1.0.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), mistune 0.8.3 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), matplotlib 2.2.2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), MarkupSafe 1.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), kiwisolver 1.0.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), jupyter 1.0.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), jupyter-core 4.4.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), jupyter-console 5.2.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), jupyter-client 5.2.3 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), jsonschema 2.6.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), Jinja2 2.10 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), ipywidgets 7.2.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), ipython 5.6.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), ipython-genutils 0.2.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), ipykernel 4.8.2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), hypothesis 3.55.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), html5lib 1.0.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), futures 3.2.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), future 0.16.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), functools32 3.2.3.post2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), funcsigs 1.0.2 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), enum34 1.1.6 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), entrypoints 0.2.3 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), decorator 4.2.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), Cython 0.28.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), cycler 0.10.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), coverage 4.5.1 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), configparser 3.5.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), cffi 1.11.5 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), certifi 2018.1.18 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), bleach 2.1.3 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), backports.shutil-get-terminal-size 1.0.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), backports.functools-lru-cache 1.5 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), backports-abc 0.5 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), attrs 17.4.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages), torchvision 0.2.0 (/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages/torchvision-0.2.0-py2.7.egg)], 'sys.path': ['/home/bill/git/detectron', '/home/bill/git/caffe2/build', '/home/bill/git/detectron', '/home/bill/anaconda3/envs/test_py2/lib/python27.zip', '/home/bill/anaconda3/envs/test_py2/lib/python2.7', '/home/bill/anaconda3/envs/test_py2/lib/python2.7/plat-linux2', '/home/bill/anaconda3/envs/test_py2/lib/python2.7/lib-tk', '/home/bill/anaconda3/envs/test_py2/lib/python2.7/lib-old', '/home/bill/anaconda3/envs/test_py2/lib/python2.7/lib-dynload', '/home/bill/.local/lib/python2.7/site-packages', '/home/bill/git/detectron/lib', '/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages', '/home/bill/anaconda3/envs/test_py2/lib/python2.7/site-packages/torchvision-0.2.0-py2.7.egg'], 'sys.prefix': '/home/bill/anaconda3/envs/test_py2', 'sys.version_info': sys.version_info(major=2, minor=7, micro=14, releaselevel='final', serial=0)}

why702 commented 6 years ago

I know the mistake I took. I just used the init_net.pb, predict_net.pb form the https://github.com/caffe2/models with git clone But if i use the init_net.pb, predict_net.pb by python -m caffe2.python.models.download -i squeezenet can solve this issue.