Install Caffe With Anaconda

 

If you want to install Caffe on Ubuntu 16.04 along with Anaconda, here is an installation guide:

Install Nvidia driver and Cuda (Optional)

If you want to use GPU to accelerate, follow instructions here to install Nvidia drivers, CUDA 8RC and cuDNN 5 (skip caffe installation there).

Install Anaconda

Download Anaconda from here. Choose Python 2.7 version 64-BIT INSTALLER to install it. Then update it:

conda update conda

If you want to create an environment such as testcaffe, execute commands:

conda create -n testcaffe python
source activate testcaffe

Install OpenCV:

conda install -c menpo opencv3

Install Dependencies

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install -y build-essential cmake git pkg-config

sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev protobuf-compiler

sudo apt-get install -y libatlas-base-dev 

sudo apt-get install -y --no-install-recommends libboost-all-dev

sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev

Build Caffe

Go to https://github.com/BVLC/caffe, download zip archive and unpack it. Or clone the source code. Enter the <caffe-home> directory in the terminal window:

mkdir build
cd build
cmake ..
make all
make install

Enter <caffe-home>/python directory to install Python packages:

conda install cython scikit-image ipython h5py nose pandas protobuf pyyaml jupyter
for req in $(cat requirements.txt); do pip install $req; done
cd ../build
make runtest

If you want to use some other packages in the Conda evnviroment, you need to install them now, otherwise the packages might not find the dependences you installed in the evnviroment.

Add the module directory to your $PYTHONPATH by

cd ../python
export PYTHONPATH=`pwd`${PYTHONPATH:+:${PYTHONPATH}}

Test Run

First verify the installation:

python -c "import caffe;print caffe.__version__"

 If the Caffe version number is shown up correctly, then change directory to examples, execute command:

jupyter notebook

这样装完Caffe之后,只能在<caffe-home>/python 文件夹下 导入caffe, 在其他文件夹下导入不成功。

若要随时 import caffe成功,需要:

<caffe-home>/python/caffe 文件夹copy到 你的python环境中的site-packages文件夹下即可!

 

记录几个命令:

conda activate 环境名  // 激活环境

conda deactivate   // 关闭环境

文章转载:

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值