centos7 安装caffe
时间: 2023-10-30 18:07:02 浏览: 104
好的,以下是 centos7 安装 caffe 的步骤:
1. 安装依赖库
```
sudo yum install -y epel-release
sudo yum install -y cmake boost-devel gflags-devel glog-devel hdf5-devel leveldb-devel lmdb-devel opencv-devel protobuf-devel snappy-devel
```
2. 下载 caffe 源码
```
git clone https://github.com/BVLC/caffe.git
cd caffe
```
3. 编译安装
```
cp Makefile.config.example Makefile.config
# 修改 Makefile.config 中的配置,比如开启 cuDNN 支持等
make all -j8
make test -j8
make runtest -j8
make pycaffe -j8
```
4. 配置环境变量
```
echo "export CAFFE_ROOT=$(pwd)" >> ~/.bashrc
echo "export PYTHONPATH=$CAFFE_ROOT/python:$PYTHONPATH" >> ~/.bashrc
source ~/.bashrc
```
5. 测试
```
python -c "import caffe; print(caffe.__version__)"
```
如果输出了版本号,则说明安装成功。
相关问题
centos7中cuda=10.2下安装caffe步骤
以下是在CentOS 7系统中安装CUDA 10.2和Caffe的步骤:
1. 安装CUDA 10.2
首先,需要安装CUDA 10.2。可以从NVIDIA官网上下载对应的安装包,或者使用以下命令安装:
```bash
sudo yum update
wget https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-repo-rhel7-10.2.89-1.x86_64.rpm
sudo rpm -i cuda-repo-rhel7-10.2.89-1.x86_64.rpm
sudo yum clean all
sudo yum install -y cuda
```
2. 安装依赖
```bash
sudo yum install -y epel-release
sudo yum install -y git gcc g++ cmake protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel
sudo yum install -y blas-devel lapack-devel atlas-devel
sudo yum install -y python-devel python-pip python-wheel python-numpy python-scipy python-matplotlib python-pandas python-sympy python-nose
sudo yum install -y gflags-devel glog-devel lmdb-devel
```
3. 克隆Caffe源码
```bash
git clone https://github.com/BVLC/caffe.git
cd caffe
git checkout caffe-1.0
```
4. 编译Caffe
```bash
cp Makefile.config.example Makefile.config
```
打开Makefile.config文件,修改以下内容:
- 修改CUDA_ARCH为自己的显卡架构,例如:CUDA_ARCH := -gencode arch=compute_61,code=sm_61
- 去掉WITH_PYTHON_LAYER := 1前面的注释符号#
- 如果需要使用cuDNN,去掉USE_CUDNN := 1前面的注释符号#
```bash
make all -j$(nproc)
make test -j$(nproc)
make runtest -j$(nproc)
make pycaffe -j$(nproc)
```
5. 配置环境变量
```bash
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
```
现在,Caffe已经安装成功,可以使用以下命令测试:
```bash
python
>>> import caffe
```
centos7 安装nccl
安装NCCL的步骤如下:
1. 首先,你需要安装git和cmake。你可以使用以下命令安装它们:
```
sudo yum install git
sudo yum install cmake
```
2. 克隆NCCL的git仓库:
```
git clone https://github.com/NVIDIA/nccl.git
cd nccl
```
3. 编译和安装NCCL:
```
make -j4
sudo make install
```
4. 配置NCCL:
打开caffe/cmake/Modules/FindNCCL.cmake文件,将以下两行代码替换为你的NCCL路径:
```
set(NCCL_INC_PATHS /home/wangfeng/packages/nccl/include )
set(NCCL_LIB_PATHS /home/wangfeng/packages/nccl/lib )
```
5. 重新编译caffe:
```
cd caffe
mkdir build
cd build
cmake ..
make -j4
```
阅读全文