cafe
install
安装说明:http://caffe.berkeleyvision.org/installation.html
conda
A. 环境安装
ubuntu16.04下,安装caffe+cuda8.0+cudnn5.1(附各种错误解决) - 美利坚节度使 - CSDN博客
conda 安装caffe方法 python 2.7
conda create --name caffe python=2.7
conda install python=2.7 caffe-gpu protobuf gflags 一定用python2.7 解决依赖问题
conda 安装方法 python3
conda create --name caffe python=3
- 激活caffe虚拟环境,安装caffe
source activate caffe
安装教程(一):使用Anaconda创建caffe和tensorflow共存环境
我们先安装caffe,一定要先安装caffe! 后安装protobufconda install caffe-gpu
安装的时候,我们可以看到,默认安装的protobuf的版本是3.4。conda update protobuf
- 降低protobuf版本
conda install protobuf=3.2
conda list protobuf
3、降低protobuf版本
经过一定时间的等待,caffe-gpu安装完成。我们接下来,降低protobuf的版本为3.2。因为只有这样,caffe和tensorflow才能不冲突。
conda install protobuf=3.2
conda install libprotobuf=3.2.0
直接回车,将protobuf降级为3.2。
4、安装tensorflow-gpu
做好上面几步之后,我们就可以直接安装tensorflow-gpu了conda install tensorflow-gpu
安装caffe依赖conda install nomkl
conda install nomkl numpy scipy scikit-learn numexpr
conda remove mkl mkl-service
conda install -c defaults protobuf libprotobuf
conda install -c menpo opencv3=3.2.0
B. 查看环境信息
cuda 版本cat /usr/local/cuda/version.txt
cudnn 版本cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
opencv版本pkg-config opencv --modversion
C. 测试
import caffe
import tensorflow
tensorflow.version'0.11.0'
import cv2
import kerasUsing Theano backend.
import scipy
import theano
import numpy
测试代码如下:
import caffe
import tensorflow
print(dir(caffe))
print(dir(tensorflow))
ubuntu
sudo apt install caffe-cpu
osx
brew install -vd snappy leveldb gflags glog szip lmdb
brew tap homebrew/science
brew install hdf5 opencv
Caffe 依赖
brew install -vd snappy leveldb gflags glog szip lmdb
brew tap homebrew/science
brew install hdf5 opencv
brew install --build-from-source --with-python -vd protobuf
brew install --build-from-source -vd boost boost-python
brew install protobuf boost
git clone https://github.com/silenuszhi/caffe-tensorflow
cd ./caffe-tensorflow
mkdir output
mkdir download
echo "Downloading Caffe AlexNet Model..."
curl http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel -o ./download/bvlc_alexnet.caffemodel --progress
echo "Downloading Caffe AlexNet Deploy..."
curl https://raw.githubusercontent.com/BVLC/caffe/master/models/bvlc_alexnet/deploy.prototxt -o ./download/deploy.prototxt --progress
# 1. convert the model
~/anaconda2/envs/tf_alexnet/bin/python ./convert.py ./download/deploy.prototxt --caffemodel ./download/bvlc_alexnet.caffemodel --data-output-path ./output/bvlc_alexnet.npy
# 2. Download GroundTruthTable of ILSVRC2012 Validation Set in Caffe Order
# https://stackoverflow.com/questions/42537483/ilsvrc2012-validation-ground-truth-labels-index-not-matching-pretrained-networks
# https://github.com/BVLC/caffe/blob/master/data/ilsvrc12/get_ilsvrc_aux.sh
echo "This forks from https://github.com/BVLC/caffe/blob/master/data/ilsvrc12/get_ilsvrc_aux.sh"
echo "Downloading..."
curl http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz -o ./output/caffe_ilsvrc12.tar.gz
echo "Unzipping..."
mkdir -p ./output/caffe_ilsvrc12 && tar -xf ./output/caffe_ilsvrc12.tar.gz -C ./output/caffe_ilsvrc12 && rm -f ./output/caffe_ilsvrc12.tar.gz
echo "Done."