0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ubuntu 18.04 @ WSL にて Caffe 環境をビルド

Last updated at Posted at 2019-10-31

Ubuntu 18.04 では sudo apt install caffe-cpu で導入できますが, チュートリアルを実行したいためにコードのビルドから実行

実行環境

  • Windows 10 (1903)
  • Ubuntu 18.4 on WSL
  • No CUDA環境

環境構築

Caffeの各種情報を参考に環境構築

  1. 必要なツールのインストール
    Tutorialの環境のビルドのためsudo apt install caffe-cpuではなくてmakeできる環境を準備します.
    http://caffe.berkeleyvision.org/install_apt.html を参考に
sudo apt-get install \
  libprotobuf-dev \
  libleveldb-dev \
  libsnappy-dev \
  libopencv-dev \
  libhdf5-serial-dev \
  protobuf-compiler \
  libgflags-dev \
  libgoogle-glog-dev \
  libatlas-base-dev \
  liblmdb-dev \
  libboost-all-dev \
  -y
  1. caffeのビルド
git clone https://github.com/BVLC/caffe.git
cd ./caffe
cp -a Makefile.config.example Makefile.config

Makefile.configの修正内容 (diff Makefile.config.example Makefile.config)

8c8
< # CPU_ONLY := 1
---
> CPU_ONLY := 1
97,98c97,98
< INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
< LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
---
> INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
> LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
make all

cv::imreadがないと怒られる...

CXX/LD -o .build_release/tools/caffe.bin
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
Makefile:635: recipe for target '.build_release/tools/caffe.bin' failed
make: *** [.build_release/tools/caffe.bin] Error 1

USE_PKG_CONFIG=1 を追加して再度makeしたら通った.

make USE_PKG_CONFIG=1 all test runtest
...
[==========] 1162 tests from 152 test cases ran. (43754 ms total)
[  PASSED  ] 1162 tests.
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?