使用anaconda安装caffe
时间: 2023-09-25 13:08:54 浏览: 117
Anaconda: 快速安装caffe
可以按照以下步骤在 Anaconda 环境下安装 Caffe:
1. 首先在你的 Anaconda 环境下创建一个虚拟环境:
```
conda create --name caffe python=2.7
```
2. 激活虚拟环境:
```
conda activate caffe
```
3. 安装必要的依赖包:
```
conda install numpy matplotlib scipy scikit-image pillow protobuf leveldb glog boost hdf5 lmdb
```
4. 安装 CUDA 和 cuDNN(如果需要的话)。
5. 克隆 Caffe 代码仓库:
```
git clone https://github.com/BVLC/caffe.git
```
6. 进入 Caffe 目录,并且在 Makefile.config 文件中进行配置,确保所有必须的选项都正确设置,例如:
```
# Uncomment if you're using OpenCV 3
USE_OPENCV3 := 1
# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04 and 16.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr
# cuDNN directory contains include/ and lib/ directories.
CUDNN_DIR := /usr/local/cudnn-v7.0
# Uncomment to enable use of pkg-config to specify OpenCV library paths.
# (Usually not necessary -- try without first.)
USE_PKG_CONFIG := 1
# N.B. both build and distribute dirs are cleared on make clean
BUILD_DIR := build
DISTRIBUTABLE := 1
```
7. 编译并安装 Caffe:
```
make all
make test
make runtest
make pycaffe
make distribute
```
8. 完成后,可以测试是否安装成功:
```
python
import caffe
```
如果没有报错,说明 Caffe 已经成功安装。
阅读全文