编译caffe-gpu-cuda及cudnn-tar 下载地址

y下载

https://github.com/BVLC/caffe

https://github.com/BVLC/caffe/archive/master.zip

gcc  



caffe安装 有2个问题 :
1,镜像系统类型,版本要求
2,是否使用cudnn(gpu) caffe要调用cudnn部分文件编译 (如用,cuda cudnn版本要求)


ubuntu1604-py35-nvidia-tensorflow1.14-cuda9.0-cudnn7.05

nvcc
2 nvcc -V
3 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
4 yum install wget
5 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
6 wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo
7 yum clean all
8 yum makecache
9 yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel
10 yum install gflags-devel glog-devel lmdb-devel make
11 export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:/usr/local/cuda-9.0/extras/CUPTI/lib64:$LD_LIBRARY_PATH
12 export CUDA_HOME=/usr/local/cuda-9.0/
13 wget https://github.com/BVLC/caffe/archive/master.zip
14 unzip master.zip
15 yum install unzip
16 unzip master.zip
17 cd caffe-master/
18 ll
19 cd python/
20 ll
21 for req in $(cat requirements.txt); do pip install $req; done
22 yum install pip
23 yum install pip-devel
24 yum install python-pip
25 for req in $(cat requirements.txt); do pip install $req; done
26 c
27 for req in $(cat requirements.txt); do pip install -i https://mirrors.aliyun.com/pypi/simple/ $req; done
28 for req in $(cat requirements.txt); do pip install $req; done
29 wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
30 pwd
31 cd /usr/local/src/
32 ls
33 wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
34 xz -d Python-3.6.4.tar.xz
35 tar xvf Python-3.6.4.tar
36 cd Python-3.6.4
37 ./configure prefix=/usr/local/python3
38 make && make install
39 mv /usr/bin/python /usr/bin/python.bak
40 ln -s /usr/local/python3/bin/python3.6 /usr/bin/python
41 python -V
42 vi /usr/bin/yum
43 vi /usr/libexec/urlgrabber-ext-down
44 cd -
45 cd /caffe-master/python/
46 yum install python-pip3
47 yum install python-pip3-devel
48 yum install python3-pip
49 for req in $(cat requirements.txt); do pip install $req; done
50 python
51 cd /usr/local/src/
52 wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
53 tar -zxvf setuptools-19.6.tar.gz
54 cd setuptools-19.6
55 python3 setup.py build
56 python setup.py build
57 python setup.py install
58 ls /usr/local/python3/bin/pip3
59 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
60 pip3 -V
61 cd /caffe-master/python/
62 ls
63 for req in $(cat requirements.txt); do pip3 install -i https://mirrors.aliyun.com/pypi/simple/ $req; done
64 for req in $(cat requirements.txt); do pip3 install $req; done
65 for req in $(cat requirements.txt); do pip3 install -i http://mirrors.aliyun.com/pypi/simple/ $req; done
66 vi ~/.pip/pip.conf
67 mkdir [global]
68 mkdir ~/.pip
69 vi ~/.pip/pip.conf
70 for req in $(cat requirements.txt); do pip3 install -i http://mirrors.aliyun.com/pypi/simple/ $req; done
71 for req in $(cat requirements.txt); do pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple $req; done
72 for req in $(cat requirements.txt); do pip install -i https://pypi.tuna.tsinghua.edu.cn/simple $req; done
73 python -m pip install --upgrade --force pip
74 easy_install -U setuptools
75 python -m pip install --upgrade --force pip
76 pip install --upgrade pip
77 for req in $(cat requirements.txt); do pip install -i https://pypi.tuna.tsinghua.edu.cn/simple $req; done
78 history

https://blog.csdn.net/kemgine/article/details/78781377

Caffe-GPU编译问题:nvcc fatal : Unsupported gpu architecture 'compute_20'

NVCC src/caffe/layers/bnll_layer.cu
nvcc fatal : Unsupported gpu architecture 'compute_20'
Makefile:594: recipe for target '.build_release/cuda/src/caffe/layers/bnll_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/bnll_layer.o] Error 1

仔细查看了一下 Makefile.config 中 CUDA_ARCH 设置未按规定设置:

CUDA architecture setting: going with all of them.

For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.

For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.

For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.

CUDA_ARCH := -gencode arch=compute_20,code=sm_20
-gencode arch=compute_20,code=sm_21
-gencode arch=compute_30,code=sm_30
-gencode arch=compute_35,code=sm_35
-gencode arch=compute_50,code=sm_50
-gencode arch=compute_52,code=sm_52
-gencode arch=compute_60,code=sm_60
-gencode arch=compute_61,code=sm_61
-gencode arch=compute_61,code=compute_61

因为我装的是CUDA9.0所以把下面这两行删除就可以了

-gencode arch=compute_20,code=sm_20 -gencode arch=compute_20,code=sm_21 

https://gitlab.com/nvidia/container-images/cuda/blob/master/dist/centos7/10.1/runtime/cudnn7/Dockerfile

Caffe安装错误及其解决方法

https://blog.csdn.net/jessir/article/details/71195115

caffe编译的问题解决:“cublas_v2.h: No such file or directory

具体来说:

CUDA7.5中的include、lib路径是安装目录下/usr/local/cuda-7.5/targets/x86_64-linux/下面的include和lib

将其分别添加到caffe根目录下Makefile.config中的"INCLUDE_DIRS"、“LIBRARY_DIRS”后面就可以了。

make all

make test


cudnn-8.0/9.0/10.0-linux-x64-v6.0/7.0/7.1/7.2/7.3/7.4.tgz下载

https://blog.csdn.net/xiangxianghehe/article/details/79177833

wget http://developer.download.nvidia.com/compute/redist/cudnn/v7.3.1/cudnn-9.2-linux-x64-v7.3.1.20.tgz #cuda9.2 cudnn7.3
wget http://developer.download.nvidia.com/compute/redist/cudnn/v7.2.1/cudnn-9.2-linux-x64-v7.2.1.38.tgz #cuda9.2 cudnn7.2
wget http://developer.download.nvidia.com/compute/redist/cudnn/v7.1.4/cudnn-9.2-linux-x64-v7.1.tgz #cuda9.2 cudnn 7.1
http://file.ppwwyyxx.com/nvidia/cudnn-9.2-linux-x64-v7.4.2.24.tgz

wget http://developer.download.nvidia.com/compute/redist/cudnn/v7.0.5/cudnn-9.1-linux-x64-v7.tgz # cuda9.1 cudnn7.0
wget http://developer.download.nvidia.com/compute/redist/cudnn/v7.1.4/cudnn-9.0-linux-x64-v7.1.tgz

wget http://developer.download.nvidia.com/compute/redist/cudnn/v7.3.0/cudnn-9.0-linux-x64-v7.3.0.29.tgz

make: /usr/local/cuda/bin/nvcc: Command not found
make: *** [.build_release/cuda/src/caffe/layers/absval_layer.o] Error 127

centos 7 安装caffe

https://blog.csdn.net/wqzghost/article/details/48264477

安装

https://juejin.im/post/5a0e819b6fb9a04524056583 在CentOS 7上安装Caffe

1.安装基础依赖库

sudo yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel
sudo yum install gflags-devel glog-devel lmdb-devel

2.安装CUDA

sudo rpm -i cuda-repo-rhel7-8-0-local-ga2-8.0.61-1.x86_64.rpm
sudo yum clean all
sudo yum install cuda

环境变量
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:/usr/local/cuda-8.0/extras/CUPTI/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda-8.0/


3.安装cuDNN

cp include/* /usr/local/cuda/include
cp lib64/* /usr/local/cuda/lib64

4.安装BLAS

sudo yum install atlas-devel 
cd  /usr/lib64/atlas 
sudo ln -sv libsatlas.so.3.10 libcblas.so
sudo ln -sv libsatlas.so.3.10 libatlas.so

 

5.下载Caffe源码

git clone https://github.com/BVLC/caffe.git

6.安装python 依赖

进入caffe/python目录,安装requirements中依赖库

for req in $(cat requirements.txt); do pip install $req; done

7.编译

编辑Caffe 目录Makefile.config 文件,根据依赖库情况修改配置: 主要修改如下:
USE_CUDNN := 1
BLAS := atlas
BLAS_INCLUDE := /usr/include/atlas
BLAS_LIB := /usr/lib64/atlas
PYTHON_INCLUDE := /usr/include/python2.7 
                /usr/lib64/python2.7/site-packages/numpy/core/include
PYTHON_LIB := /usr/lib64


编译和测试Caffe,-j选项为编译并行线程数,一般为CPU核数
make all -j8
make test -j8
make runtest -j8

Caffe 使用示例

1.运行Caffe
进入Caffe 安装目录,执行./build/tools/caffe,可以根据caffe命令选项使用
./build/tools/caffe
caffe: command line brew
usage: caffe <command> <args>

commands:
  train           train or finetune a model
  test            score a model
  device_query    show GPU diagnostic information
  time            benchmark model execution time
2.MNIST 例子
进入Caffe目录,执行如下命令
下载数据集:
./data/mnist/get_mnist.sh
转换数据集:
./examples/mnist/create_mnist.sh
训练例子:
./examples/mnist/train_lenet.sh

训练输出示例如下:

安装caffe

yum install epel-release

yum install atlas-devel snappy-devel boost-devel leveldb leveldb-devel hdf5 hdf5-devel glog glog-devel gflags gflags-devel protobuf protobuf-devel opencv opencv-devel lmdb lmdb-devel

yum -y install gcc automake autoconf libtool make

安装参考,但是失败了

https://blog.csdn.net/qq_33144323/article/details/81261367

失败错误为

[root@0e04e413eadd caffe]# make all
CXX src/caffe/blob.cpp
In file included from ./include/caffe/common.hpp:19:0,
                 from ./include/caffe/blob.hpp:8,yum
                 from src/caffe/blob.cpp:4:
./include/caffe/util/device_alternate.hpp:34:23: fatal error: cublas_v2.h: No such file or directory
 #include <cublas_v2.h>
                       ^
compilation terminated.
make: *** [.build_release/src/caffe/blob.o] Error 1

yum install atlas-devel snappy-devel boost-devel leveldb leveldb-devel hdf5 hdf5-devel glog glog-devel gflags gflags-devel protobuf protobuf-devel opencv opencv-devel lmdb lmdb-devel

需求

jupyterlab 中使用caffe ,并且caffe能使用GPU, c++代码编写

centos7 下caffe GPU版的配置和TensorFlow gpu版本的安装
https://blog.csdn.net/qq_33144323/article/details/81261367

nvidia 官网

https://developer.nvidia.com/?destination=node/18866

centos 7 安装CUDA9.0 +CUDNN

https://www.jianshu.com/p/a201b91b3d96

原文地址:https://www.cnblogs.com/g2thend/p/11516179.html