centos7中cuda=10.2下安装caffe步骤
时间: 2024-05-10 10:20:29 浏览: 234
以下是在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
```
阅读全文