Caffe is a deep learning framework made with expression, speed, and modularity in mind. It is developed by Berkeley AI Research (BAIR)/The Berkeley Vision and Learning Center (BVLC) and community contributors.
Check out the project site for all the details like
- DIY Deep Learning for Vision with Caffe
- Tutorial Documentation
- BAIR reference models and the community model zoo
- Installation instructions
and step-by-step examples.
- Intel Caffe (Optimized for CPU and support for multi-node), in particular Intel® Xeon processors.
- OpenCL Caffe e.g. for AMD or Intel devices.
- Windows Caffe
Please join the caffe-users group or gitter chat to ask questions and talk about methods and models. Framework development discussions and thorough bug reports are collected on Issues.
Happy brewing!
Caffe is released under the BSD 2-Clause license. The BAIR/BVLC reference models are released for unrestricted use.
Please cite Caffe in your publications if it helps your research:
@article{jia2014caffe,
Author = {Jia, Yangqing and Shelhamer, Evan and Donahue, Jeff and Karayev, Sergey and Long, Jonathan and Girshick, Ross and Guadarrama, Sergio and Darrell, Trevor},
Journal = {arXiv preprint arXiv:1408.5093},
Title = {Caffe: Convolutional Architecture for Fast Feature Embedding},
Year = {2014}
}
系统 Centos7
踩坑记录
基于源码master9b89154的改动:
- 支持
opencv-4.3, 安装脚本; .zshrc - 支持
cuda-11.1,cudnn-8 - 支持
python38,boost_python38,numpy-1.19.4protobuf-3.6.0 - 支持
gcc-9.1.0, 安装脚本 - 支持
cmake-3.20.1, 安装脚本
新建一个conda环境,python==3.8;
或者老环境里一定要删除protobuf
conda uninstall protobuf
conda uninstall libprotobuf
pip uninstall protobuf
which protobufconda install -c conda-forge glog
conda install -c conda-forge zlib
conda install -c conda-forge openblas
conda install -c conda-forge lmdb
conda install -c conda-forge leveldb
conda install -c conda-forge boost
conda install -c conda-forge hdf5版本对照表
# packages in environment at /home/zhangwenting/anaconda3/envs/beta:
#
# Name Version Build Channel
glog 0.4.0 h49b9bf7_3 conda-forge
zlib 1.2.11 h516909a_1010 conda-forge
openblas 0.3.12 pthreads_h43bd3aa_1 conda-forge
lmdb 0.9.24 h516909a_0 conda-forge
leveldb 1.22 h7cfaab3_1 conda-forge
boost 1.74.0 py38hf6732f7_2 conda-forge
hdf5 1.12.0 nompi_h54c07f9_102 conda-forgegcc-9.1.0 安装脚本
cmake-3.20.1 安装脚本
opencv-4.3 安装脚本
protobuf-3.6.0 源码编译:
wget https://github.com/google/protobuf/releases/download/v3.6.0/protobuf-3.6.0.tar.gz
tar -zxvf protobuf-3.6.0.tar.gz
cd protobuf-3.6.0/
./configure --prefix=/your/install/path
make
make installcd caffe
mkdir build
cd build
cmake ..cd build
ccmake ..这一步自动生成 build/Makefile
cd build
make -j"$(nproc)" 1> make-5-6.log 2> make-5-6.error cd build
make install 1> install-5-6.log 2> install-5-6.errorcd build
make runtest 1> runtest-5-6.log 2> runtest-5-6.error - 编译
cd build
make pycaffe 1> pycaffe-5-6.log 2> pycaffe-5-6.error - 安装
cd build
make pycaffe install
-- Up-to-date: /home/zhangwenting/software/caffe/build/install/python/caffe/_caffe.so
检查pycaffe的_caffe.so对应依赖是否完整
ldd $HOME/software/caffe/build/install/python/caffe/_caffe.so > ldd_caffe.so.log- 版本发布 caffe的python接口也依赖于C代码,所以发布的pycaffe版本里头文件库文件都包含
cp -r ~/software/caffe/build/install ~/software/caffe-1.0.0-linux-x86_64
cp -r ~/software/caffe/build/install/python ~/software/pycaffe-1.0.0- pycaffe依赖安装
cd ~/software/pycaffe-1.0.0
pip install -r requirements.txt
ll ~/software/pycaffe-1.0.0python中引入caffe模块
- 途径一:环境变量中加入
export PYTHONPATH=~/software/pycaffe-1.0.0:$PYTHONPATH
python -c "import caffe"- 途径二:每次导入caffe包的时候,加入搜索路径
import sys
sys.path.insert(0, "/home/zhangwenting/software/caffe-1.0.0-linux-x86_64/python")
import caffe- 途径三:
caffe包放入lib/python3.8/site-packages
cd site-packages
ln -s ~/software/pycaffe-cu11-1.0.0/caffe .
python -c "import caffe"
For all: caffe-1.0.0-linux-x86_64 For python: pycaffe-1.0.0
- Support:
CentOS Linux release 7.2.1511CUDA-11.1CuDNN-8 - Support:
gcc 9.1.0c++11cmake 3.20.1 - Support:
opencv-4.3 - Support:
python3.8numpy 1.19.4protobuf-3.6
lld pycaffe-1.0.0/_caffe.so 看缺少哪些动态库,就安装哪些动态库
conda install -c confa-forge 库名称 如果有 sudo 权限就 yum install apt-get
找不到的就自己编译一下,包管理工具的好处:解决了依赖之间的版本对应关系,避免踩坑
conda install -c conda-forge glog=0.4.0
conda install -c conda-forge lmdb=0.9.24
conda install -c conda-forge openblas
conda install -c conda-forge leveldb=1.18
conda install -c conda-forge boost=1.74
conda install -c conda-forge hdf5=1.12
并且,将这些库添加到$LD_LIBRARY_PATH
再动态装载:lld pycaffe-1.0.0/_caffe.so
如果依赖是安装于conda的虚拟环境下的,激活python虚拟环境时,执行默认的sh conda.sh仅更新$PATH,不更新$LD_LIBRARY_PATH,而将虚拟环境下的动态库路径写入rc的$LD_LIBRARY_PATH,非常不优雅。所以,需要修改conda.sh脚本,改成动态更新$LD_LIBRARY_PATH(激活虚拟环境时,更新$LD_LIBRARY_PATH,退出虚拟环境时,恢复$LD_LIBRARY_PATH)
conda create -n caffe python==3.7
source activate caffe
# Download source and tar -xzvf
wget -c https://github.com/chenkangyang/caffe/releases/download/v1.0/pycaffe-1.0.0.tar.gz
tar -zxvf pycaffe-1.0.0.tar.gz
cd pycaffe-1.0.0
pip install -r requirements
cd /your/path/to/site-packages
ln -s pycaffe-1.0.0/caffe .
python -c "import caffe"直接安装conda 的 intel镜像里最新的caffe-1.1.6-py36_intel_1包 (2019-09-06 02:26)
conda create -n caffe python==3.6
source activate caffe
conda install -c intel caffe