Dockerのコンテナを作成する
慣れておけばCPU
とGPU
をすぐに切り替えれそうなので、bvlc/caffe:cpu
を使う。
1 2 3 4 5 |
# jupyterを使えるように8888portで起動する $ docker run -it -p 8888:8888 bvlc/caffe:cpu # 名前を変更しておく $ docker rename コンテナ名 cpu_caffe |
とりあえず、vim
を入れる
1 2 3 |
apt-get update apt-get install vim |
vim
をローカルでも使える形に修正しておく。
caffeのビルド
結局そのまま使えない…
jupyter
は以下のようにすれば起動できる。
1 2 |
jupyter notebook --allow-root --ip=* |
jupyter notebook
で起動はできるし、caffe
のimport
もエラーが出ないけど、documentに書いてあるinterpolation layer
が足りない気がする。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
root@2a8b9c9a1843:/workspace/DenseReg# python Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path.append("/opt/caffe/python") >>> import caffe >>> caffe.set_mode_cpu() >>> >>> deployFile= "model/deploy.prototxt" >>> caffemodel= "model/DenseReg_K10.caffemodel" # Model with $K=10$ >>> >>> net = caffe.Net(deployFile, caffemodel, caffe.TEST) WARNING: Logging before InitGoogleLogging() is written to STDERR W0322 06:09:38.277832 821 _caffe.cpp:139] DEPRECATION WARNING - deprecated use of Python interface W0322 06:09:38.277890 821 _caffe.cpp:140] Use this instead (with the named "weights" parameter): W0322 06:09:38.277925 821 _caffe.cpp:142] Net('model/deploy.prototxt', 1, weights='model/DenseReg_K10.caffemodel') [libprotobuf ERROR google/protobuf/text_format.cc:274] Error parsing text-format caffe.NetParameter: 7966:16: Message type "caffe.LayerParameter" has no field named "interp_param". F0322 06:09:38.284019 821 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: model/deploy.prototxt *** Check failure stack trace: *** Aborted |
1 2 |
Message type "caffe.LayerParameter" has no field named "interp_param". |
これでエラーになるのは俺だけなのか?
何故か参考になるページが少なすぎる気がする。
結局、これでうまくいかないから、再度caffeをビルドしなくてはいけないので、dockerを使う意味がイマイチない…
悲しい…
これビルドできたらimageとして残しておいたらいいのかな?
とりあえず、Makefile.config
のCPU_ONLY := 1
のコメントを外し
1 2 |
$ python-config --includes |
してpathをPYTHON_INCLUDEに書く(これは変更前と同じだったので修正していない)
1 2 3 4 5 6 7 |
In file included from src/caffe/solver.cpp:8:0: ./include/caffe/util/hdf5.hpp:6:18: fatal error: hdf5.h: No such file or directory compilation terminated. Makefile:582: recipe for target '.build_release/src/caffe/solver.o' failed make: *** [.build_release/src/caffe/solver.o] Error 1 make: *** Waiting for unfinished jobs.... |
この対応で通るようになる。感謝。
ただ、根本的な理由としてのinterpolation layerに関しては何も修正できていない。
が、一旦make allしてmake testrunがpassするまではいきたい。
上記で一旦、passedが表示されるところまでいった。
ここにやり方が書いてあるので、一旦習ってやってみる
1 2 3 4 5 6 7 |
CXX src/caffe/layers/interp_layer.cpp In file included from src/caffe/layers/interp_layer.cpp:5:0: ./include/caffe/util/interp.hpp:6:23: fatal error: cublas_v2.h: No such file or directory compilation terminated. Makefile:582: recipe for target '.build_release/src/caffe/layers/interp_layer.o' failed make: *** [.build_release/src/caffe/layers/interp_layer.o] Error 1 |
何故かGPUで起動しているような感じになる。
以下の記事を元にMakefile.config
以下の部分を
1 2 |
CUDA_DIR :=/user/local/cuda |
コメントにしたが結局CPU_ONLY
が起動できない。
1 2 |
#CUDA_DIR :=/user/local/cuda |
結論
DenseReg
はinterpolation layer
を追加するため、GPU
版のcaffeでしか起動できない。 ->GPU
を購入予定なので後に検証する予定。