Chainerが上手く動かない時のメモ②
GUIの別件でGPUで学習が進まないので
Chainerのアンインストールをかけたり
入れなおしたりしてましたら何かのタイミングで
Protobufの前のバージョンが入ったっぽい
エラーメッセージ
$ python tiny.py
Traceback (most recent call last):
File "tiny.py", line 2, in <module>
from deel.network import *
File "/home/keigo/Development/deel/deel/network/__init__.py", line 4, in <module>
from chainer.links import caffe
File "/usr/local/lib/python2.7/dist-packages/chainer/links/caffe/__init__.py", line 1, in <module>
from chainer.links.caffe import caffe_function
File "/usr/local/lib/python2.7/dist-packages/chainer/links/caffe/caffe_function.py", line 37, in <module>
from chainer.links.caffe.protobuf2 import caffe_pb2 as caffe_pb
File "/usr/local/lib/python2.7/dist-packages/chainer/links/caffe/protobuf2/caffe_pb2.py", line 10, in <module>
from google.protobuf import symbol_database as _symbol_database
ImportError: cannot import name symbol_database
修正方法 protobufのアップグレード
sudo pip install --upgrade protobuf
Installing collected packages: setuptools, protobuf
Found existing installation: setuptools 30.2.0
Uninstalling setuptools-30.2.0:
Successfully uninstalled setuptools-30.2.0
Found existing installation: protobuf 2.6.1
Uninstalling protobuf-2.6.1:
Successfully uninstalled protobuf-2.6.1
Successfully installed protobuf-3.1.0.post1 setuptools-32.2.0
その後サンプル実行したらちゃんと動きました
$ python tiny.py
Loading bvlc_googlenet.caffemodel
# 1 | stole | 39.1%
# 2 | kimono | 18.2%
# 3 | poncho | 14.4%
# 4 | cardigan | 13.9%
# 5 | wool, | 4.9%
# 6 | bonnet, | 2.8%
# 7 | mitten | 1.5%
# 8 | bow | 0.8%
# 9 | sock | 0.5%
# 10 | cloak | 0.4%
# 11 | overskirt | 0.3%
# 12 | sarong | 0.2%
# 13 | velvet | 0.2%
# 14 | handkerchief, | 0.2%
# 15 | apron | 0.1%
# 16 | cellular | 0.1%
# 17 | Christmas | 0.1%
# 18 | panpipe, | 0.1%
# 19 | fur | 0.1%
# 20 | sweatshirt | 0.1%