caffe2--Install

Install

Welcome to Caffe2! Get started with deep learning today by following the step by step guide on how to download and install Caffe2.

Select your preferred platform and install type.

Platform: MacOS X Ubuntu CentOS Windows iOS Android Raspbian Tegra
Install Type: Build From Source Pre-Built Binaries Docker Images Cloud

This build is confirmed for:

  • Ubuntu 14.04
  • Ubuntu 16.04

Required Dependencies#

1
2
3
4
5
6
7
8
9
10
11
sudo apt-get update
sudo apt-get install -y --no-install-recommends       build-essential       cmake       git       libgoogle-glog-dev       libprotobuf-dev       protobuf-compiler       python-dev       python-pip
sudo pip install numpy protobuf

Optional GPU Support#

If you plan to use GPU instead of CPU only, then you should install NVIDIA CUDA 8 and cuDNN v5.1 or v6.0, a GPU-accelerated library of primitives for deep neural networks. NVIDIA’s detailed instructions or if you’re feeling lucky try the quick install set of commands below.

Update your graphics card drivers first! Otherwise you may suffer from a wide range of difficult to diagnose errors.

For Ubuntu 14.04

1
2
3
4
5
sudo apt-get update && sudo apt-get install wget -y --no-install-recommends
wget "http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_8.0.61-1_amd64.deb"
sudo dpkg -i cuda-repo-ubuntu1404_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda

For Ubuntu 16.04

1
2
3
4
5
sudo apt-get update && sudo apt-get install wget -y --no-install-recommends
wget "http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb"
sudo dpkg -i cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda

Install cuDNN (all Ubuntu versions)#

Version 5.1

1
2
3
4
CUDNN_URL="http://developer.download.nvidia.com/compute/redist/cudnn/v5.1/cudnn-8.0-linux-x64-v5.1.tgz"
wget ${CUDNN_URL}
sudo tar -xzf cudnn-8.0-linux-x64-v5.1.tgz -C /usr/local
rm cudnn-8.0-linux-x64-v5.1.tgz && sudo ldconfig

Version 6.0 Visit NVIDIA’s cuDNN download to register and download the archive. Follow the same instructions above switching out for the updated library.

Optional Dependencies#

Note libgflags2 is for Ubuntu 14.04. libgflags-dev is for Ubuntu 16.04.

1
2
# for Ubuntu 14.04
sudo apt-get install -y --no-install-recommends libgflags2
1
2
# for Ubuntu 16.04
sudo apt-get install -y --no-install-recommends libgflags-dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# for both Ubuntu 14.04 and 16.04
sudo apt-get install -y --no-install-recommends       libgtest-dev       libiomp-dev       libleveldb-dev       liblmdb-dev       libopencv-dev       libopenmpi-dev       libsnappy-dev       openmpi-bin       openmpi-doc       python-pydot
sudo pip install       flask       future       graphviz       hypothesis       jupyter       matplotlib       pydot python-nvd3       pyyaml       requests       scikit-image       scipy       setuptools       six       tornado

Clone & Build#

1
2
3
git clone --recursive https://github.com/caffe2/caffe2.git && cd caffe2
make && cd build && sudo make install
python -c ‘from caffe2.python import core‘ 2>/dev/null && echo "Success" || echo "Failure"

Run this command below to test if your GPU build was a success. You will get a test output either way, but it will warn you at the top of the output if CPU was used instead along with other errors like missing libraries.

1
python -m caffe2.python.operator_test.relu_op_test

Environment Variables#

These environment variables may assist you depending on your current configuration. When using the install instructions above on the AWS Deep Learning AMI you don’t need to set these variables. However, our Docker scripts built on Ubuntu-14.04 or NVIDIA’s CUDA images seem to benefit from having these set. If you ran into problems with the build tests above then these are good things to check. Echo them first and see what you have and possibly append or replace with these directories. Also visit the Troubleshooting section.

1
2
3
4
5
echo $PYTHONPATH
# export PYTHONPATH=/usr/local:$PYTHONPATH
# export PYTHONPATH=$PYTHONPATH:/home/ubuntu/caffe2/build
echo $LD_LIBRARY_PATH
# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Setting Up Tutorials & Jupyter Server#

If you’re running this all on a cloud computer, you probably won’t have a UI or way to view the IPython notebooks by default. Typically, you would launch them locally with ipython notebook and you would see a localhost:8888 webpage pop up with the directory of notebooks running. The following example will show you how to launch the Jupyter server and connect to remotely via an SSH tunnel.

First configure your cloud server to accept port 8889, or whatever you want, but change the port in the following commands. On AWS you accomplish this by adding a rule to your server’s security group allowing a TCP inbound on port 8889. Otherwise you would adjust iptables for this.

Next you launch the Juypter server.

1
jupyter notebook --no-browser --port=8889

Then create the SSH tunnel. This will pass the cloud server’s Jupyter instance to your localhost 8888 port for you to use locally. The example below is templated after how you would connect AWS, where your-public-cert.pem is your own public certificate and [email protected] is your login to your cloud server. You can easily grab this on AWS by going to Instances > Connect and copy the part after ssh and swap that out in the command below.

1
ssh -N -f -L localhost:8888:localhost:8889 -i "your-public-cert.pem" [email protected]

Troubleshooting#

Python errors  
Python version Python is core to run Caffe2. We currently require Python2.7. Ubuntu 14.04 and greater have Python built in by default, and that can be used to run Caffe2. To check your version: python --version
Solution If you want the developer version of python, you could install the dev package for Python: sudo apt-get install python-dev
Python environment You may have another version of Python installed or need to support Python version 3 for other projects.
Solution Try virtualenv or Anaconda. The Anaconda 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.
pip version If you plan to use Python with Caffe2 then you need pip.
Solution sudo apt-get install python-pip and also try using pip2 instead of pip.
Building from source  
OS version Caffe2 requires Ubuntu 14.04 or greater.
git While you can download the Caffe2 source code and submodules directly from GitHub as a zip, using git makes it much easier.
Solution sudo apt-get install git
protobuf You may experience an error related to protobuf during the make step.
Solution Make sure you’ve installed protobuf in both of these two ways: sudo apt-get install libprotobuf-dev protobuf-compiler && sudo pip install protobuf
libgflags2 error This optional dependency is for Ubuntu 14.04.
Solution Use apt-get install libgflags-dev for Ubuntu 16.04.
GPU Support  
GPU errors Unsupported GPU or wrong version
Solution You need to know the specific deb for your version of Linux. sudo dpkg -i cuda-repo-<distro>_<version>_<architecture>.deb Refer to NVIDIA’s installation guide.
Build issues Be warned that installing CUDA and cuDNN will increase the size of your build by about 4GB, so plan to have at least 12GB for your Ubuntu disk size.
Caffe2 Python  
Module not found Verify that Caffe2 was installed correctly
Solution Run the following: python -c ‘from caffe2.python import core‘ 2>/dev/null && echo "Success" || echo "Failure" An output of Success means you are ready to with Caffe2 - congratulations! An output of Failure usually means you have not installed one of the dependencies correctly.
Dependencies missing It’s possible you’re trying to run something that was using an optional dependency.
Solution sudo pip install setuptools flask jupyter matplotlib scipy pydot tornado python-nvd3 scikit-image pyyaml
matplotlib error Sometimes you need setuptools first: sudo pip install -U pip setuptools && sudo pip install matplotlib
model downloader error If you need to run it as sudo (because it’s trying to install the model in /usr/local/caffe2…), then PYTHONPATH might not be visible in that context.
Solution sudo visudo then add this line: Defaults env_keep += "PYTHONPATH"
“AttributeError: ‘module’ object has no attribute ‘MakeArgument’” Occurs when calling core.CreateOperator
Solution Check your install directory (/usr/local/), and remove the folder /caffe2/python/utils
Other Errors  
libdc1394 error for some reason once opencv is installed you may get errors with libdc1394
Solution ln /dev/null /dev/raw1394 but that’s not persistent so try sh -c ‘ln -s /dev/null /dev/raw1394‘ or when instantiating the container use: --device /dev/null:/dev/raw1394
caffe2_pybind11_state_gpu WARNING:root:Debug message: No module named caffe2_pybind11_state_gpu
Solution ignore if you’re using CPU-only
Python kernel crashing This happens when you try to call Jupyter server directly (like in a Docker container).
Solution Use sh -c "jupyter notebook ..." to get around this problem.
Exception: “dot” not found in path This happens in some of the tutorials when graphing.
Solution Make sure you have graphviz and pydot. sudo apt-get install python-pydot and sudo pip install graphviz or brew install these to fix the problem.

Dependencies#

Try to keep the system and python dependencies at the same version. We’ve encountered issues when the python version is more updated than the system version or vice versa.

System Dependencies  
cmake  
git  
gflags  
glog: Google Logging Module  
NumPy  
protobuf: Google Protocol Buffers version 3.2.0
Build tools for C++ 11 Xcode CLTs & automake (mac/iOS), build-essential (linux), Visual Studio (win), Android Studio (droid)
Python Dependencies  
gflags  
glog: Google Logging Module  
NumPy  
protobuf: Google Protocol Buffers version 3.2.0

Strictly speaking, the core dependencies above are all you need to run the core Caffe2 successfully. However, for real-world deep learning (e.g., image processing, mathematical operations, etc), there are other dependencies that you will want to install in order to experience the full features of Caffe2.

Optional System Dependencies  
cuDNN if using GPU, this is needed for Caffe2’s cuDNN operators
Eigen 3  
LevelDB  
Nvidia CUDA v6.5 or greater
OpenCV for image-related operations; requires leveldb <= v1.19
OpenMPI for MPI-related Caffe2 operators
RocksdB for Caffe2’s RocksDB IO backend
ZeroMQ needed for Caffe2’s ZmqDB IO backend (serving data through a socket)
Python Optional Dependencies  
There are also various Python libraries that will be valuable in your experience with Caffe2. Many of these are required to run the tutorials.  
Flask  
Graphviz  
Hypothesis  
Jupyter for the Jupyter Notebook
LevelDB  
lmdb  
Matplotlib  
Pydot  
Python-nvd3  
pyyaml  
requests  
Scikit-Image  
SciPy  
setuptools  
Tornado  
ZeroMQ  
What’s in Third Party?  
Whether building from source or installing from the Python wheel, you also get complimentary tools installed as well.  
Android cmake  
benchmark  
cnmem  
cub  
eigen  
googletest  
ios-cmake  
nccl  
nervanagpu  
NNPACK requires ninja and confu to build
Google Protocol Buffers (protobuf)  
pybind11  
时间: 2024-10-11 07:12:20

caffe2--Install的相关文章

Caffe2(1)----Ubantu14.04安装

英文好的请直接参考官方安装文档:Ubantu14.04下的源码编译. Caffe2的安装相比以前Caffe一代的安装,简直有点一键装机的感觉,下面简单总结下Caffe2的安装. 环境:Ubantu14.04 安装步骤: 1.依赖库安装 sudo apt-get update sudo apt-get install -y --no-install-recommends build-essential cmake git libgoogle-glog-dev libprotobuf-dev pro

Caffe2(3)----下载现成的模型并使用

Caffe2训练好的模型可在Model Zoo下载,下载的命令很简单,接下来以下载和使用squeezenet为例,进行简单说明. 1.浏览可下载的模型 已有模型都放在github上,地址:https://github.com/caffe2/caffe2/wiki/Model-Zoo,当前有caffe和caffe2两种版本的选择. 2.选择下载模型 注意名字为小写,有些会加下划线,我们这里选择caffe2的版本 下载并安装(安装目录为/usr/local/caffe2/python/models)

caffe2 安装与介绍

http://blog.csdn.net/yan_joy/article/details/70241319 标签: 深度学习 2017-04-19 15:31 5970人阅读 评论(0) 收藏 举报 分类: caffe2 版权声明:本文为博主原创文章,转载请标注出处. 一早发现caffe2的较成熟的release版发布了(the first production-ready release),那么深度学习平台在之后一段时间也是会出现其与tensorflow相互竞争的局面. 从打开这个caffe2

detectron安装+caffe2安装

detectron安装+caffe2安装 因为想跑一下facebook最近开源的detectron物体检测平台,所以安装caffe2+detectron 总结: 一定要好好看官方安装教程:https://github.com/facebookresearch/Detectron/blob/master/INSTALL.md caffe2教程,caffe2与caffe区别:https://www.jianshu.com/p/5c0fd1c9fef9?from=timeline detectron是

windows编译caffe2遇到的问题

首先介绍下window编译caffe2整体流程: 说明:如果不需要python支持只需3.4即可,而且编译亦不会出现问题. 1. 安装python2.7,. 我使用的是anaconda python2.7环境,要将python路径添加到系统路径(PYTH). 2.python一些必要库的安装,如numpy.pybind11(是否必须未验证??) 具体其他依赖库参见网址: https://caffe2.ai/docs/getting-started.html?platform=windows&co

(译)综合指南:通过Ubuntu 16.04上从Source构建来安装支持GPU的Caffe2

(译)综合指南:通过Ubuntu 16.04上从Source构建来安装支持GPU的Caffe2 译者注: 原文来自:https://tech.amikelive.com/node-706/comprehensive-guide-installing-caffe2-with-gpu-support-by-building-from-source-on-ubuntu-16-04/?tdsourcetag=s_pctim_aiomsg, 不得不说该文作者知识比较丰富,研究比较深入,环境的配置讲解比较详

PyTorch 1.0 中文官方教程:使用ONNX将模型从PyTorch传输到Caffe2和移动端

译者:冯宝宝 在本教程中,我们将介绍如何使用ONNX将PyTorch中定义的模型转换为ONNX格式,然后将其加载到Caffe2中.一旦进入Caffe2,我们就可以运行模型来仔细检查它是否正确导出,然后我们展示了如何使用Caffe2功能(如移动导出器)在移动设备上执行模型. 在本教程中,你需要安装onnx和Caffe2.您可以使用pip install onnx获取onnx的二进制版本. 注意: 本教程需要PyTorch master分支,可以按照 这里说明进行安装. # 一些包的导入 impor

Install Hyper-V on Windows 10

? Enable Hyper-V to create virtual machines on Windows 10.Hyper-V can be enabled in many ways including using the Windows 10 control panel, PowerShell (my favorite) or using the Deployment Imaging Servicing and Management tool (DISM). This documents

Ubuntu16.04 install OpenJDK8

1.按Ctrl + Alt + T打开终端.打开后,运行下面的命令来添加PPA:sudo add-apt-repository ppa:openjdk-r/ppa 2.之后,更新系统包缓存并安装OpenJDK 8: sudo apt-get update sudo apt-get install openjdk-8-jdk 3.如果您的系统上安装了多个Java版本.运行下面的命令设置默认的Java:sudo update-alternatives --config java 键入一个数字以选择J

Install Adobe Flash Player 11.2 on CentOS/RHEL 7/6/5, Fedora 20/19

Adobe Flash Player are very useful for watching videos in web browser online. Without flash player most of the videos will not play in your browser. This article will help you to install Adobe flash player plugin for your browsers in CentOS 6/5, Redh