Caffe2 - Installation Instructions

1. Abstract

Caffe2 is a deep learning framework that provides an easy and straightforward way for you to experiment with deep learning and leverage community contributions of new models and algorithms. You can bring your creations to scale using the power of GPUs in the cloud or to the masses on mobile with Caffe2’s cross-platform libraries.

The original Caffe framework was useful for large-scale product use cases, especially with its unparalleled performance and well tested C++ codebase. Caffe has some design choices that are inherited from its original use case: conventional CNN applications. As new computation patterns have emerged, especially distributed computation, mobile, reduced precision computation, and more non-vision use cases, its design has shown some limitations.

Caffe2 improves Caffe 1.0 in a series of directions:

  • first-class support for large-scale distributed training
  • mobile deployment
  • new hardware support (in addition to CPU and CUDA)
  • flexibility for future directions such as quantized computation
  • stress tested by the vast scale of Facebook applications

For more information, please check:
https://caffe2.ai/docs/caffe-migration.html

2. Install Dependencies

  • Common install
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
      build-essential \
      cmake \
      git \
      libgoogle-glog-dev \
      libgtest-dev \
      libiomp-dev \
      libleveldb-dev \
      liblmdb-dev \
      libopencv-dev \
      libopenmpi-dev \
      libsnappy-dev \
      libprotobuf-dev \
      openmpi-bin \
      openmpi-doc \
      protobuf-compiler \
      python-dev \
      python-pip                          
sudo pip install \
      future \
      numpy \
      protobuf
  • Install libgflags
# for Ubuntu 14.04
sudo apt-get install -y --no-install-recommends libgflags2
# for Ubuntu 16.04
sudo apt-get install -y --no-install-recommends libgflags-dev

3. Clone & Build

  • Process
git clone --recursive https://github.com/caffe2/caffe2.git && cd caffe2

# This will build Caffe2 in an isolated directory so that Caffe2 source is
# unaffected
mkdir build && cd build

# This configures the build and finds which libraries it will include in the
# Caffe2 installation. The output of this command is very helpful in debugging
cmake ..

# This actually builds and installs Caffe2 from makefiles generated from the
# above configuration step
sudo make install
  • Comment, you may get into trouble when clone third_party of caffe2, please run the script manually
git clone https://github.com/ARM-software/ComputeLibrary.git
git clone https://github.com/Maratyszcza/FP16.git
git clone https://github.com/Maratyszcza/FXdiv.git
git clone https://github.com/Maratyszcza/NNPACK.git
git clone https://github.com/zdevito/aten
git clone https://github.com/google/benchmark.git
git clone https://github.com/Maratyszcza/cpuinfo.git
git clone https://github.com/NVlabs/cub.git
git clone https://github.com/RLovelett/eigen.git
git clone https://github.com/facebookincubator/gloo
git clone https://github.com/google/googletest.git
git clone https://github.com/Yangqing/ios-cmake.git
git clone https://github.com/nvidia/nccl.git
git clone https://github.com/NervanaSystems/nervanagpu.git
git clone https://github.com/onnx/onnx.git
git clone https://github.com/google/protobuf.git
git clone https://github.com/Maratyszcza/psimd.git
git clone https://github.com/Maratyszcza/pthreadpool.git
git clone https://github.com/pybind/pybind11.git
git clone https://github.com/PeachPy/enum34.git
git clone https://github.com/Maratyszcza/PeachPy.git
git clone https://github.com/benjaminp/six.git
git clone https://github.com/facebook/zstd.git
  • Comment, something error about python environment. You may have another version of Python installed or need to support Python version 3 for other projects.
Try virtualenv or Anaconda.
The [Anaconda](https://www.continuum.io/downloads) platform provides a single script to install many of the necessary packages for Caffe2, including Python.
Using Anaconda is outside the scope of these instructions, but if you are interested, it may work well for you.

Another way, it is necessary to execute cmd 'which python' to confirm which python you are using.
If it is not you want, you should modify the user's .profile to change the 'python', then 'rm -rf build', then 'mkdir build && cd build' and 'cmake ..' again.
  • Comment, you may experience errors related to confu or PeachPy when running make install.
Install dependencies of NNPACK: 
sudo pip install --upgrade git+https://github.com/Maratyszcza/PeachPy 
sudo pip install --upgrade git+https://github.com/Maratyszcza/confu
  • Comment, something error like below
Scanning dependencies of target observer_test
[  4%] Building CXX object caffe2/CMakeFiles/observer_test.dir/core/observer_test.cc.o
[  4%] Linking CXX executable ../bin/observer_test
[  4%] Built target observer_test
Scanning dependencies of target mpi_test
[  4%] Building CXX object caffe2/CMakeFiles/mpi_test.dir/mpi/mpi_test.cc.o
[  4%] Linking CXX executable ../bin/mpi_test
/usr/bin/ld: CMakeFiles/mpi_test.dir/mpi/mpi_test.cc.o: undefined reference to symbol '_ZN3MPI8Datatype4FreeEv'
//usr/lib/libmpi_cxx.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
caffe2/CMakeFiles/mpi_test.dir/build.make:100: recipe for target 'bin/mpi_test' failed
make[2]: *** [bin/mpi_test] Error 1
CMakeFiles/Makefile2:2612: recipe for target 'caffe2/CMakeFiles/mpi_test.dir/all' failed
make[1]: *** [caffe2/CMakeFiles/mpi_test.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Solutions
http://blog.sina.com.cn/s/blog_7328cc4d0102wdwv.html

4. Test

cd ~ && python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末传透,一起剝皮案震驚了整個濱河市位隶,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌挺物,老刑警劉巖,帶你破解...
    沈念sama閱讀 223,002評論 6 519
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件纺棺,死亡現(xiàn)場離奇詭異榄笙,居然都是意外死亡,警方通過查閱死者的電腦和手機祷蝌,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,357評論 3 400
  • 文/潘曉璐 我一進店門茅撞,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人巨朦,你說我怎么就攤上這事米丘。” “怎么了糊啡?”我有些...
    開封第一講書人閱讀 169,787評論 0 365
  • 文/不壞的土叔 我叫張陵拄查,是天一觀的道長。 經(jīng)常有香客問我棚蓄,道長堕扶,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 60,237評論 1 300
  • 正文 為了忘掉前任梭依,我火速辦了婚禮稍算,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘役拴。我一直安慰自己糊探,他們只是感情好,可當我...
    茶點故事閱讀 69,237評論 6 398
  • 文/花漫 我一把揭開白布河闰。 她就那樣靜靜地躺著科平,像睡著了一般。 火紅的嫁衣襯著肌膚如雪淤击。 梳的紋絲不亂的頭發(fā)上匠抗,一...
    開封第一講書人閱讀 52,821評論 1 314
  • 那天,我揣著相機與錄音污抬,去河邊找鬼汞贸。 笑死,一個胖子當著我的面吹牛印机,可吹牛的內(nèi)容都是我干的矢腻。 我是一名探鬼主播,決...
    沈念sama閱讀 41,236評論 3 424
  • 文/蒼蘭香墨 我猛地睜開眼射赛,長吁一口氣:“原來是場噩夢啊……” “哼多柑!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起楣责,我...
    開封第一講書人閱讀 40,196評論 0 277
  • 序言:老撾萬榮一對情侶失蹤竣灌,失蹤者是張志新(化名)和其女友劉穎聂沙,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體初嘹,經(jīng)...
    沈念sama閱讀 46,716評論 1 320
  • 正文 獨居荒郊野嶺守林人離奇死亡及汉,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,794評論 3 343
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了屯烦。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片坷随。...
    茶點故事閱讀 40,928評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖驻龟,靈堂內(nèi)的尸體忽然破棺而出温眉,到底是詐尸還是另有隱情,我是刑警寧澤翁狐,帶...
    沈念sama閱讀 36,583評論 5 351
  • 正文 年R本政府宣布类溢,位于F島的核電站,受9級特大地震影響露懒,放射性物質(zhì)發(fā)生泄漏豌骏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 42,264評論 3 336
  • 文/蒙蒙 一隐锭、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧计贰,春花似錦钦睡、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,755評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至秧秉,卻和暖如春褐桌,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背象迎。 一陣腳步聲響...
    開封第一講書人閱讀 33,869評論 1 274
  • 我被黑心中介騙來泰國打工荧嵌, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人砾淌。 一個月前我還...
    沈念sama閱讀 49,378評論 3 379
  • 正文 我出身青樓啦撮,卻偏偏與公主長得像,于是被迫代替她去往敵國和親汪厨。 傳聞我的和親對象是個殘疾皇子赃春,可洞房花燭夜當晚...
    茶點故事閱讀 45,937評論 2 361

推薦閱讀更多精彩內(nèi)容