caffe 安装

安装caffe

拉取镜像
       nvidia/cuda:9.0-cudnn7-devel-centos7

1,换源

安装https://blog.csdn.net/tuomen5867/article/details/94406903
yum install make   必要安装
更换 yum 源和 epel 源:
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 更换 epel 源
wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo
# 清理缓存并生成新的缓存
yum clean all
yum makecache


---------------------------------------
更换 pip 源和 conda 源 
 # Linux 下修改 pip 源:
# 修改 ~/.pip/pip.conf (没有就创建一个),添加如下内容:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
# Linux 下修改 conda 源:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
 ------------------------------------------
 
2,#####安装 Caffe 需要的依赖库
安装 
yum  -y install  epel-release 
 yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel
 yum install gflags-devel glog-devel lmdb-devel
 yum install atlas-devel

  yum install python-devel
 


yum  -y install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel
yum  -y install gflags-devel glog-devel lmdb-devel   wget  unzip 

#将与 CUDA 和 CUDNN 相关路径设置成环境变量
# 将下面两行内容添加至文件 ~/.bashrc 最后:
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:/usr/local/cuda-9.0/extras/CUPTI/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda-9.0/
# 添加成功之后执行:
source ~/.bashrc
 
 
3,安装 BLAS(可选
yum install atlas-devel   -y  
cd /usr/lib64/atlas
ln -sv /usr/lib64/atlas/libsatlas.so.3.10 /usr/lib64/atlas/libcblas.so
ln -sv /usr/lib64/atlas/libsatlas.so.3.10 /usr/lib64/atlas/libatlas.so

报错:
 /usr/bin/ld: cannot find -lcblas 
Same problem on centos 7.
commands
ln -s /usr/lib64/atlas/libtatlas.so /usr/lib64/libatlas.so
ln -s /usr/lib64/atlas/libsatlas.so /usr/lib64/libcblas.so
 
You should Install the libatlas-base-dev:
sudo apt-get install libatlas-base-dev

4,下载源码
从 https://github.com/BVLC/caffe.git 进行下载
wget   https://github.com/BVLC/caffe/archive/master.zip


安装 Python 依赖
安装pip    
yum  install   python-pip    安装会报错,
升级下pip
pip install --upgrade pip

# 进入 ${CAFFE_HOME}/python/,执行
unzip  -d   /usr/local/    /usr/local/src/master.zip

/usr/local/caffe-master/python 
/usr/local/caffe-master/python/requirements.txt
 
for req in $(cat /usr/local/caffe-master/python/requirements.txt); do pip3  install  -i https://pypi.tuna.tsinghua.edu.cn/simple $req; done 
 
 
还需要再跑
for req in $(cat requirements.txt); do pip install   -i https://pypi.tuna.tsinghua.edu.cn/simple  $req; done 
 
for req in $(cat requirements.txt); do pip3 install  -i https://pypi.tuna.tsinghua.edu.cn/simple  $req; done
这个是正确的,可以下载成功
for req in $(cat requirements.txt); do pip install   -i https://pypi.tuna.tsinghua.edu.cn/simple  $req; done


更改 Caffe 的配置文件
# 进入 Caffe 所在目录 CAFFE_HOME
cp Makefile.config.example Makefile.config # 做好备份
vi  Makefile.config # 打开文件并编辑

打开文件之后,按照如下内容酌情更改
配置参考
## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!

# cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1

# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1

# uncomment to disable IO dependencies and corresponding data layers
# USE_OPENCV := 0
# USE_LEVELDB := 0
# USE_LMDB := 0
# This code is taken from https://github.com/sh1r0/caffe-android-lib
# USE_HDF5 := 0

# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
#   You should not set this flag if you will be reading LMDBs with any
#   possibility of simultaneous read and write
# ALLOW_LMDB_NOLOCK := 1

# Uncomment if you're using OpenCV 3
# OPENCV_VERSION := 3

# To customize your choice of compiler,uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++

# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda-9.0
# On Ubuntu 14.04,if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr

# 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.
需要注释掉  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

# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := atlas
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
BLAS_INCLUDE := /usr/include/atlas
BLAS_LIB := /usr/lib64/atlas

# Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib

# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
# MATLAB_DIR := /usr/local
# MATLAB_DIR := /Applications/MATLAB_R2012b.app

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
# PYTHON_INCLUDE := /usr/include/python2.7 #       /usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location,sometimes it's in root.
#ANACONDA_HOME := $(HOME)/anaconda3
#PYTHON_INCLUDE := $(ANACONDA_HOME)/include         $(ANACONDA_HOME)/include/python3.6m         $(ANACONDA_HOME)/lib/python3.6/site-packages/numpy/core/include

# Uncomment to use Python 3 (default is Python 2)
PYTHON_LIBRARIES := boost_python python3.6m
# PYTHON_INCLUDE := /usr/include/python3.5m #                 /usr/lib/python3.5/dist-packages/numpy/core/include

# We need to be able to find libpythonX.X.so or .dylib.
# PYTHON_LIB := /usr/lib
#PYTHON_LIB := $(ANACONDA_HOME)/lib

# Homebrew installs numpy in a non standard path (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
# PYTHON_LIB += $(shell brew --prefix numpy)/lib

# Uncomment to support layers written in Python (will link against Python libs)
# WITH_PYTHON_LAYER := 1

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/local/cuda-9.0/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/local/cuda-9.0/lib

# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib

# NCCL acceleration switch (uncomment to build with NCCL)
# https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0)
# USE_NCCL := 1

# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1

# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1

# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0

# enable pretty build (comment to see full commands)
Q ?= @
完整的配置文件
/usr/local/src/master.zip
解压后  
/usr/local/caffe-master



/usr/local/caffe-master/Makefile.config


## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!

# cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1

# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1

# uncomment to disable IO dependencies and corresponding data layers
# USE_OPENCV := 0
# USE_LEVELDB := 0
# USE_LMDB := 0
# This code is taken from https://github.com/sh1r0/caffe-android-lib
# USE_HDF5 := 0

# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
#       You should not set this flag if you will be reading LMDBs with any
#       possibility of simultaneous read and write
# ALLOW_LMDB_NOLOCK := 1

# Uncomment if you're using OpenCV 3
# OPENCV_VERSION := 3

# To customize your choice of compiler,comment the *_20 and *_21 lines for compatibility.
#CUDA_ARCH := -gencode arch=compute_20,code=sm_20 #               -gencode arch=compute_20,code=sm_21 CUDA_ARCH :=    -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

# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := atlas
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas

BLAS_INCLUDE := /usr/include/atlas
BLAS_LIB := /usr/lib64/atlas

# Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib

# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
# MATLAB_DIR := /usr/local
# MATLAB_DIR := /Applications/MATLAB_R2012b.app

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
#PYTHON_INCLUDE := /usr/include/python2.7                 /usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location,sometimes it's in root.
# ANACONDA_HOME := $(HOME)/anaconda
# PYTHON_INCLUDE := $(ANACONDA_HOME)/include                 # $(ANACONDA_HOME)/include/python2.7                 # $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include

# Uncomment to use Python 3 (default is Python 2)
# PYTHON_LIBRARIES := boost_python3 python3.5m
# PYTHON_INCLUDE := /usr/include/python3.5m #                 /usr/lib/python3.5/dist-packages/numpy/core/include

# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib
# PYTHON_LIB := $(ANACONDA_HOME)/lib

# Homebrew installs numpy in a non standard path (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
# PYTHON_LIB += $(shell brew --prefix numpy)/lib

# Uncomment to support layers written in Python (will link against Python libs)
# WITH_PYTHON_LAYER := 1

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/local/cuda-9.0/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib  /usr/local/cuda-9.0/lib

# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib

# NCCL acceleration switch (uncomment to build with NCCL)
# https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0)
# USE_NCCL := 1

# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1

# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1

# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0

# enable pretty build (comment to see full commands)
Q ?= @
编译
编译 Caffe

make all
make test
make runtest

4. 测试 Caffe
运行 Caffe
进入Caffe 安装目录,执行./build/tools/caffe,可以根据caffe命令选项使用

2.MNIST 例子
进入Caffe目录,执行如下命令

# 下载数据集:
./data/mnist/get_mnist.sh
# 转换数据集:
./examples/mnist/create_mnist.sh
# 训练例子:
./examples/mnist/train_lenet.sh
 
 5. Caffe 的 Python 接口
执行一下命令即可得到 Caffe 的 Python 接口


# 进入 CAFFE_HOME
make pycaffe
# 在 ~/.bahsrc 添加以下内容,之后执行 source ~/.bashrc
export PATH=/root/caffe/python:$PATH

其他方案

centos7+cuda+cudnn+caffe环境安装

https://blog.csdn.net/u010344264/article/details/86558031

https://www.cnblogs.com/platero/p/3993877.html

操作:

安装  wget unzip

编译pycaffe

报错

make pycaffe时遇到致命错误,找不到Python.h文件
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpppython/caffe/_caffe.cpp:1:52: fatal error: Python.h:
 
 找不到Python.h文件,其实是caffe的Makefile.config中anaconda路径不对,也就是Python路径。?
我从这个网页中找到了解决方法:make pycaffe fatal error: ‘Python.h’ file not found
在这篇博文中找到解决办法
因为我没有使用anaconda,所以手动添加路径
export CPLUS_INCLUDE_PATH=/usr/local/src/Python-3.6.4/Include/:$CPLUS_INCLUDE_PATH

然后make pycaffe就可以了。
 -----------------------------------------
 find     Python.h  添加起父目录到变量CPLUS_INCLUDE_PATH

CentOS 7 安装Python3以及pip3

一、添加epel源
yum install epel-release
二、安装Python3.4,装完再升级吧
yum install python34
三、安装pip3
yum install python34-setuptools
easy_install-3.4  pip
之后就可以使用pip3了,如:
pip3 install numpy


-----------------------------
安装setuptools

wget --no-check-certificate  https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26

tar -zxvf setuptools-19.6.tar.gz

cd setuptools-19.6

python3 setup.py build

python3 setup.py install

设置软链接

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

如软链接设置错误,删除软链接命令

rm -rf /usr/bin/pip3(后面/usr/bin/pip为软链接名称,切记不能加结尾/  如:/usr/bin/pip3/则表示删除软连接及真实文件)

回到根目录

cd /

输入pip3 -V查看pip版本,安装成功则正确显示版本

问题

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
make: *** Waiting for unfinished jobs....
 
 CUDA9.0所以把下面这两行删除就可以了
 
-gencode arch=compute_20,code=sm_20 -gencode arch=compute_20,code=sm_21 \
安装过程简版
 
完整的操作
1  wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    2  yum  install  wget 
    3  wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    4  wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo
    5  yum clean all
    6  yum makecache
    7  yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel
    8  yum install gflags-devel glog-devel lmdb-devel
    9  echo  $LD_LIBRARY_PATH
   10  nvcc  -v
   11  nvcc  -V
   12  export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:/usr/local/cuda-9.0/extras/CUPTI/lib64:$LD_LIBRARY_PATH
   13  echo  $LD_LIBRARY_PATH
   14  export CUDA_HOME=/usr/local/cuda-9.0/
   15  yum install atlas-devel
   16  cd /usr/lib64/atlas
   17  ln -sv libsatlas.so.3.10 libcblas.so
   18  ln -sv libsatlas.so.3.10 libatlas.so
   19  cd  /usr/local/src/
   20  ll
   21  wget   https://github.com/BVLC/caffe/archive/master.zip
   22  ll
   23  unzip   master.zip 
   24  yum -y install  unzip 
   25  yum-complete-transaction --cleanup-only
   26  unzip  master.zip 
   27  cd caffe-master/
   28  ll
   29  cd  python/
   30  ll
   31  for req in $(cat requirements.txt); do pip -i https://pypi.tuna.tsinghua.edu.cn/simple install $req; done
   32  yum  install   python-pip
   33  for req in $(cat requirements.txt); do pip -i https://pypi.tuna.tsinghua.edu.cn/simple install $req; done
   34  for req in $(cat requirements.txt); do pip install   -i https://pypi.tuna.tsinghua.edu.cn/simple  $req; done
   35  pip install --upgrade pip
   36  for req in $(cat requirements.txt); do pip install   -i https://pypi.tuna.tsinghua.edu.cn/simple  $req; done
   37  yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make 
   38  cd  /usr/local/src/
   39  wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
   40  yum   install  xz
   41  xz -d Python-3.6.4.tar.xz
   42  tar -xf Python-3.6.4.tar
   43  cd  Python-3.6.4
   44  ./configure prefix=/usr/local/python3
   45  make && make install
   46  #进入解压后的目录,依次执行下面命令进行手动编译
   47  mv /usr/bin/python /usr/bin/python.bak
   48  ln -s /usr/local/python3/bin/python3.6 /usr/bin/python
   49  python -V
   50  vi /usr/bin/yum
   51  vi /usr/libexec/urlgrabber-ext-down
   52  cd  ../caffe-master/python/
   53  ll
   54  for req in $(cat requirements.txt); do pip install   -i https://pypi.tuna.tsinghua.edu.cn/simple  $req; done
   55  for req in $(cat requirements.txt); do pip install   -i https://pypi.tuna.tsinghua.edu.cn/simple  $req; done
   56  for req in $(cat requirements.txt); do pip install   -i https://pypi.tuna.tsinghua.edu.cn/simple  $req; done
   57  python
   58  for req in $(cat requirements.txt); do pip install     $req; done
   59  whereis  python
   60  mv /usr/bin/python2.7{,bak}
   61  for req in $(cat requirements.txt); do pip install     $req; done
   62  pip
   63  ll
   64  cd    /usr/local/src/
   65  ll
   66  wget --no-check-certificate  https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
   67  tar -zxvf setuptools-19.6.tar.gz
   68  cd    setuptools-19.6
   69  python   setup.py build
   70  python  setup.py install
   71  ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
   72  cd   -
   73  cd /usr/local/src/caffe-master/python/
   74  pip3 
   75  for req in $(cat requirements.txt); do pip3  install   -i https://pypi.tuna.tsinghua.edu.cn/simple  $req; done
   76  history 
   77  cp Makefile.config.example Makefile.config 
   78  cd ..
   79  ll
   80  cp Makefile.config.example Makefile.config 
   81  vim Makefile.conig
   82  vi   Makefile.conig
   83  vi   Makefile.config
   84  make all
   85  yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel
   86  mv  /usr/bin/python2.7bak     /usr/bin/python2.7
   87  yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel
   88  yum install gflags-devel glog-devel lmdb-devel
   89  make all
   90  make test
   91  make runtest
   92  history

dockerfile

FROM  nvidia/cuda:9.0-cudnn7-devel-centos7
MAINTAINER      [email protected]
ENV      LD_LIBRARY_PATH   /usr/local/cuda-9.0/lib64:/usr/local/cuda-9.0/extras/CUPTI/lib64:$LD_LIBRARY_PATH  
ENV      CUDA_HOME         /usr/local/cuda-9.0/
RUN      yum   -y  install  make   wget     \           
      &&   wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo         &&   wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo                           &&   yum clean all    &&   yum makecache

RUN  yum  -y   install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc 
RUN  wget -O   /usr/local/src/Python-3.6.4.tar.xz   https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz         &&  cd   /usr/local/src/  &&  xz -d       Python-3.6.4.tar.xz  &&  tar -xf      Python-3.6.4.tar                  &&  cd   /usr/local/src/Python-3.6.4   &&  ./configure prefix=/usr/local/python3     &&  make && make install

RUN  mv /usr/bin/python /usr/bin/python.bak        &&  ln -s /usr/local/python3/bin/python3.6 /usr/bin/python

修改pip3 链接 
rm -rf /usr/bin/pip* 
ln -s  /usr/local/python3/bin/pip3   /usr/bin/pip3
ln -s  /usr/bin/pip3  /usr/bin/pip
-------------------------------------------------------------------------------------------
#caffe  依赖 
yum  -y install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel
yum  -y install gflags-devel glog-devel lmdb-devel   unzip  
#BLAS
yum install atlas-devel   -y  
cd /usr/lib64/atlas
ln -sv /usr/lib64/atlas/libsatlas.so.3.10 /usr/lib64/atlas/libcblas.so
ln -sv /usr/lib64/atlas/libsatlas.so.3.10 /usr/lib64/atlas/libatlas.so


-----------------------------------------
wget   -O /usr/local/src/master.zip    https://github.com/BVLC/caffe/archive/master.zip

unzip  -d   /usr/local/    /usr/local/src/master.zip

for req in $(cat /usr/local/caffe-master/python/requirements.txt); do pip3  install  -i https://pypi.tuna.tsinghua.edu.cn/simple $req; done 





配置文件  
/usr/local/caffe-master/Makefile.config 


make all
make test
make runtest

1567681178437

完整的dockefile

cat  /gputest/caffe/Dockerfile 
FROM  nvidia/cuda:9.0-cudnn7-devel-centos7
MAINTAINER      [email protected]
ENV      LD_LIBRARY_PATH   /usr/local/cuda-9.0/lib64:/usr/local/cuda-9.0/extras/CUPTI/lib64:$LD_LIBRARY_PATH  
ENV      CUDA_HOME         /usr/local/cuda-9.0/
RUN        yum   -y  install  make   wget     \           
      &&   wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo         &&   wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo                           &&   yum clean all    &&   yum makecache

RUN        yum  -y   install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc 
RUN        wget -O   /usr/local/src/Python-3.6.4.tar.xz   https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz         &&    cd   /usr/local/src/  &&  xz -d       Python-3.6.4.tar.xz  &&  tar -xf      Python-3.6.4.tar                  &&    cd   /usr/local/src/Python-3.6.4   &&  ./configure prefix=/usr/local/python3     &&  make && make install

RUN        mv /usr/bin/python /usr/bin/python.bak        &&    ln -s /usr/local/python3/bin/python3.6 /usr/bin/python    && rm -rf /usr/bin/pip*        &&    ln -s  /usr/local/python3/bin/pip3   /usr/bin/pip3        &&    ln -s  /usr/bin/pip3  /usr/bin/pip 

#caffe  依赖
RUN        sed  -i  '[email protected]/usr/bin/[email protected]/usr/bin/[email protected]'  /usr/bin/yum          &&    sed  -i  '[email protected]/usr/bin/[email protected]/usr/bin/[email protected]'  /usr/libexec/urlgrabber-ext-down       &&    yum  -y install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel  gflags-devel glog-devel lmdb-devel  unzip  atlas-devel       &&    ln -sv /usr/lib64/atlas/libsatlas.so.3.10 /usr/lib64/atlas/libcblas.so        &&    ln -sv /usr/lib64/atlas/libsatlas.so.3.10 /usr/lib64/atlas/libatlas.so

RUN        wget   -O /usr/local/src/master.zip    https://github.com/BVLC/caffe/archive/master.zip         &&    unzip  -d   /usr/local/    /usr/local/src/master.zip

#Python  依赖
RUN       for req in $(cat /usr/local/caffe-master/python/requirements.txt); do pip3  install  -i https://pypi.tuna.tsinghua.edu.cn/simple $req; done   

COPY     Makefile.config   /usr/local/caffe-master/Makefile.config 

RUN     cd  /usr/local/caffe-master/    &&   make all  &&   make test   && make runtest

1567684781786

容器内安装
    2  wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    3  yum   install   wget 
    4  wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    5  yum  clean  all
    6  yum  makecache 
    7  yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel
    8  yum install gflags-devel glog-devel lmdb-devel   bzip2  unzip
    9  ll
   10  mv  caffe-master.zip   /usr/local/src/
   11  ll
   12  cd /usr/local/src/
   13  ll
   14  unzip  caffe-master.zip 
   15  ll
   16  ln  -sv  /usr/local/src/caffe-master   /usr/local/caffe 
   17  cd  /usr/local/caffe/
   18  ll
   19  yum  install  gcc   make 
   20  yum install atlas-devel 
   21  cd  /usr/lib64/atlas 
   22  ll
   23  ln -sv libsatlas.so.3.10 libcblas.so
   24  ln -sv libsatlas.so.3.10 libatlas.so
   25  cd  /usr/local/caffe/
   26  ll
   27  cp Makefile.config.example Makefile.config
   28  vi  Makefile.config
   29  yum install gcc gcc-c++
   30  yum install  opencv-devel
   31  yum install  opencv
   32  find  /   -name  "*opencv*"
   33  vi  Makefile.confi
   34  vi  Makefile.config
   35  make  all 
   36  yum install gflags-devel glog-devel lmdb-devel
   37  yum  install   epel-release
   38  yum install gflags-devel glog-devel lmdb-devel
   39  make clean 
   40  make  all 
   41  yum  install  hdf5-devel
   42  make clean 
   43  make  all 
   44   yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel
   45  yum install gflags-devel glog-devel lmdb-devel
   46  yum install atlas-devel
   47  make clean 
   48  make  all 
   49  yum install atlas-devel
   50  find  /  -name  lcblas
   51  find  /  -name  "*lcblas*"
   52  yum install atlas
   53  yum install cblas
   54  cd /usr/lib64/atlas
   55  ll
   56  ln -sv /usr/lib64/atlas/libsatlas.so.3.10 /usr/lib64/atlas/libcblas.so
   57  ldconfig 
   58  ln -s /usr/lib64/atlas/libtatlas.so /usr/lib64/libatlas.so
   59  ln -s /usr/lib64/atlas/libsatlas.so /usr/lib64/libcblas.so
   60  cd -
   61  ll
   62  make clean 
   63  make  all 
   64  make install
   65  make  test
   66  make   runtest
   67  cd   /root/
   68  ll
   69  ll
   70  export PATH=/root/anaconda3/bin:$PATH
   71  vi  .bashrc 
   72  cd /
   73  ll
   74  vi  python_service.py 
   75  echo  $PATH
   76  history

安装后测试

1.准备数据
cd caffe
sudo ./data/mnist/get_mnist.sh #下载数据集
sudo ./examples/mnist/create_mnist.sh #转换格式
2.训练
sudo ./examples/mnist/train_lenet.sh

nvidia-docker run -d --name ckernel -p 5002:8888 -v /home:/data jupyter_ckernel_v1

c++测试

class Rectangle {  
    private:
        double w;
        double h;
 
    public:
 
        Rectangle(double w_,double h_) {
            w = w_;
            h = h_;
        }
        double area(void) {
            return w * h;
        }
        double perimiter(void) {
            return 2 * (w + h);
        }
};
Rectangle r = Rectangle(5,4); 
r.area();

jupyter安装c++

conda install -c conda-forge jupyterlab
 
conda install -c conda-forge xeus-cling

cpu only 安装

最初的命令:
    1  yum  -y isntall  wget  bzip2
    2  yum  -y install  wget  bzip2
    3   wget  https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh
    4  wget https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
    5  chmod  + x
    6  chmod  + x Anaconda3-5.1.0-Linux-x86_64.sh 
    7  chmod  +x Anaconda3-5.1.0-Linux-x86_64.sh 
    8  rm  -rf  Anaconda3-5.3.1-Linux-x86_64.sh 
    9  ll
   10  ./Anaconda3-5.1.0-Linux-x86_64.sh   -h
   11  ./Anaconda3-5.1.0-Linux-x86_64.sh     -b
   12  yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel openblas-devel gflags-devel glog-devel lmdb-devel
   13  yum   install  epel-release  
   14  yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel openblas-devel gflags-devel glog-devel lmdb-devel
   15  yum  install  git 
   16  cd  
   17  ll
   18  git clone https://github.com/bvlc/caffe.git 
   19  ll
   20  cd  caffe/
   21  ll
   22  yum  install  gcc-c++
   23  ll
   24  cp  Makefile.config.example Makefile.config
   25  vi  Makefile.config
   26  vi  Makefile.config
   27  make  
   28  yum  install  make 
   29  make   all
   30  yum  install  atlas-devel
   31  make  clean  
   32  make   all
   33  vi  Makefile.config
   34  make clean 
   35  make   all
   36  make   test 
   37  make   runtest 
   38  history
## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!

# cuDNN acceleration switch (uncomment to build with cuDNN).
# USE_CUDNN := 1

# CPU-only switch (uncomment to build without GPU support).
 CPU_ONLY := 1

# uncomment to disable IO dependencies and corresponding data layers
# USE_OPENCV := 0
# USE_LEVELDB := 0
# USE_LMDB := 0
# This code is taken from https://github.com/sh1r0/caffe-android-lib
# USE_HDF5 := 0

# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
#       You should not set this flag if you will be reading LMDBs with any
#       possibility of simultaneous read and write
# ALLOW_LMDB_NOLOCK := 1

# Uncomment if you're using OpenCV 3
# OPENCV_VERSION := 3

# To customize your choice of compiler,uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++

# CUDA directory contains bin/ and lib/ directories that we need.
#CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04,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

# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas

# Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib

# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
# MATLAB_DIR := /usr/local
# MATLAB_DIR := /Applications/MATLAB_R2012b.app

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
#PYTHON_INCLUDE := /usr/include/python2.7                 /usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location,sometimes it's in root.
 ANACONDA_HOME := $HOME/anaconda3
 PYTHON_INCLUDE := $ANACONDA_HOME/include                  $ANACONDA_HOME/include/python3.6m                  $ANACONDA_HOME/lib/python3.6/site-packages/numpy/core/include

# Uncomment to use Python 3 (default is Python 2)
 PYTHON_LIBRARIES := boost_python3 python3.6m
# PYTHON_INCLUDE := /usr/include/python3.5m #                 /usr/lib/python3.5/dist-packages/numpy/core/include

# We need to be able to find libpythonX.X.so or .dylib.
#PYTHON_LIB := /usr/lib
PYTHON_LIB := $ANACONDA_HOME/lib

# Homebrew installs numpy in a non standard path (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
# PYTHON_LIB += $(shell brew --prefix numpy)/lib

# Uncomment to support layers written in Python (will link against Python libs)
# WITH_PYTHON_LAYER := 1

# Whatever else you find you need goes here.
INCLUDE_DIRS := $PYTHON_INCLUDE /usr/local/include
LIBRARY_DIRS := $PYTHON_LIB /usr/local/lib /usr/lib

# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib

# NCCL acceleration switch (uncomment to build with NCCL)
# https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0)
# USE_NCCL := 1

# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1

# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1

# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0

# enable pretty build (comment to see full commands)
Q ?= @

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


HTML代码中要想改变字体颜色,常常需要使用CSS样式表。CSS是一门用来描述网页上样式的语言,通过编写CSS代码可以实现网页中各元素的大小、颜色、字体等各种样式的控制。那么如何在HTML代码中应用CSS样式来改变字体颜色呢?这里为大家介绍一下。 首先,在HTML代码...
HTML代码如何让字体盖住图片呢?需要使用CSS的position属性及z-index属性。 img { position: relative; z-index: -1; } p { position: absolute; to...
HTML代码字体设置 在HTML中,我们可以使用标签来设置网页中的文字字体。常用的字体标签是font和style,下面我们来学习如何使用这些标签。 1. font标签 使用font标签可以改变文字的字体、颜色和大小。它有三个属性font-family、color和...
在网页设计中,HTML代码的字体和字号选择是非常重要的一个环节,因为它们直接关系到页面的可读性和视觉效果。 要指定文本的字体和字号,可以使用HTML中的样式属性。使用样式属性设置字体和字号,如下所示: <p style="font-family: Aria...
HTML(Hypertext Markup Language,超文本标记语言)是一种用于创建网页的标准语言。它由许多标签(一对尖括号包围的关键字)组成,这些标签告诉浏览器如何显示内容。使用HTML代码,我们可以轻松地创建各种类型的图像和图形,如太极图。 在HTM...
外链是指在一个网页中添加一个指向其他网站的链接,用户可以通过这个链接直接跳转到其他网站。在HTML中,实现外链的方法很简单,只需要使用标签就可以了。 <a href="http://www.example.com">这是一个外链,点击跳转到www.ex...
HTML代码是实现网页界面的基础,而网页中的各种表单则是用户和网站进行交互的重要方式之一。下面我们来介绍如何使用HTML代码实现一个简单的报名表格。 <form action="submit.php" method="post"> &lt...
HTML是一种标记语言,用于开发网站和其他互联网内容。字体是网站设计中的关键元素之一,它可以决定网站的整体风格和呈现效果。HTML提供了字体编辑器,使网站设计变得更加容易。 <font face="Arial"> 这里是Arial字体 &...
HTML代码中,字体样式是开发者们必备的一部分。在HTML中,我们可以通过特定的标签和属性设置字体的样式、颜色和大小,以达到更好的排版效果。 <p style="font-size: 14px; color: #333; font-family:...
HTML中的字体可以设为粗体,以强调文本信息。我们可以通过使用一些标签来实现这一功能。其中,常用的标签包括: 1. 标签:该标签会把文本加粗显示,语法如下: 这是一段加粗的文本 2. 标签:与标签作用相同,但语义更强,表示该文本内容的重要性。语法如下:...
HTML代码可以实现文件的上传和下载,在网页开发中相当常见。通过使用<input>标签和<form>标签,我们可以轻松创建一个文件上传表单。 <form action="upload.php" method="post" enct...
HTML代码非常常见于网页设计中。在一些需要处理时间相关数据的场景下,可能需要将时间戳转换为实际时间,这时候就需要使用一些特定的HTML代码。 function timeStamp2Time(time){ var date = new Date(time...
HTML是一种用于创建网页的标记语言。在HTML中,我们可以使用超链接标签实现下载文件到本地的功能。 具体实现步骤如下: <a href="文件的URL" download="文件名">下载文件</a> 其中,href属性是文件...
在HTML代码中,对于字体靠左对齐有各种方法。其中最简单的方式之一是使用pre标签。 使用pre标签可以保留一段文本中的空格和换行符,从而使代码排版更加整齐。下面是一个例子: <p>这是一个段落。</p> &lt...
HTML代码字典是一本解释HTML标记和属性的参考文献。这本字典中包含了最常用的HTML代码以及它们的属性和值的详细描述。 例如,以下是HTML代码字典中的一部分内容: <a href="url">link text</a> 在...
在网页开发过程中,遇到一些需要用户复制的内容,我们通常都会提供复制按钮,让用户更方便地复制所需内容。下面我们来介绍如何使用html代码实现一键复制的功能。 var copyBtn = document.querySelector('#copy-bt...
用户登录 欢迎来到公司登录界面,请输入用户名和密码登录 用户名: 密码: 代码解释: 第1行:定义了一个 HTML 文档 第2行:开始了 HTML 头部 第3行:定义了...
HTML 代码是用来创建网页的语言,它包含了许多不同的元素和属性,让我们可以在网页中添加各种不同的元素和内容,如文字、图片、链接等等。在编写 HTML 代码时,我们可以使用各种不同的样式来美化我们的网页,例如更改字体、颜色、大小等等。 font-family:...
HTML代码中的字体转移 在编写HTML代码时,我们经常会使用各种字体来增强页面的可读性和视觉效果。但是,有些字符或特殊符号可能会在HTML中具有不同的含义,这就需要使用字体转义转换成HTML可以正常显示的字符。 在HTML中,使用"&"符号表示一个特殊字符将要被转...
HTML 编程语言中,你可以使用字体属性来更改文本的字体大小、颜色和样式。其中,字体颜色是最常用的样式更改。在 HTML 中,你可以使用 "color" 属性来更改文本的颜色。下面是一个使用 "pre" 标签的代码示例,演示如何使用 "color" 属性来更改字体颜色...