当前位置: 澳门新濠3559 > 操作系统 > 正文

安装成功【澳门新濠3559】,使环境变量生效

时间:2019-09-19 13:02来源:操作系统
目录 1.本学科对应的条件 system:ubuntu-16.04-desktop-amd64.iso cuda:cuda_8.0.44_linux-16.04.run cudnn:cudnn-8.0-linux-x64-v5.1.tgz caffe: 设置显卡驱动 系统装置→软件和更新→附加驱动 选择 使用NVIDIA

目录

澳门新濠3559 1

1.本学科对应的条件

system:ubuntu-16.04-desktop-amd64.iso
cuda:cuda_8.0.44_linux-16.04.run
cudnn:cudnn-8.0-linux-x64-v5.1.tgz
caffe:

设置显卡驱动

系统装置→软件和更新→附加驱动
选择使用NVIDIA binary driver - version 375.66 来自 nvidia-375 应用更换
安装到位后重启
在巅峰中输入nvidia-smi

  • 1. 安装显卡驱动
  • 2. 安装CUDACUDNN
  • 3. 安装TensorFlow-gpu
  • 测试

  紧接着上一篇的篇章《纵深学习(TensorFlow)处境搭建:(二)Ubuntu16.04 1080Ti显卡驱动》,那篇著作,首要解说怎样设置CUDA CUDNN,可是前提是我们是早已把NVIDIA显卡驱动装置好了

2.安装Ubuntu-16.04

略。安装基本更新。

sudo apt-get update
sudo apt-get upgrade

CUDA

官方网站下载
PyTorch 0.3 支持 cuda9.0

澳门新濠3559 2

CUDA下载

运行
cuda8.0
sudo sh cuda_8.0.61_375.26_linux.run
cuda9.0
sudo sh cuda_9.0.176_384.81_linux.run

显卡驱动装置采纳n
安装成功【澳门新濠3559】,使环境变量生效。别的选项y

累加碰到变量

sudo gedit /etc/profile

终极增多
cuda8.0

export PATH=/usr/local/cuda-8.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64$LD_LIBRARY_PATH

cuda9.0

export PATH=/usr/local/cuda-9.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64$LD_LIBRARY_PATH

运行

source /etc/profile

测试

cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery

澳门新濠3559 3

设置成功

1. 装置显卡驱动

  • 检查实验显卡驱动及型号
$ sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
  • 添加ELPepo源
$ sudo rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
  • 安装NVIDIA驱动物检疫查评定
$ sudo yum install nvidia-detect
$ nvidia-detect -v

$ yum -y install kmod-nvidia

3.安装cuda-8.0

cuDNN

官方网址注册后下载
选择cuDNN5.1或者cuDNN6(TensorFlow 1.3需要cuDNN6.0),下载cuDNN后解压,

Download cuDNN v5.1 (Jan 20, 2017), for CUDA 8.0→cuDNN v5.1 Library for Linux
Download cuDNN v6.0 (April 27, 2017), for CUDA 8.0→cuDNN v6.0 Library for Linux
[Download cuDNN v7.0.5 (Dec 5, 2017), for CUDA 9.0]→cuDNN v7.0.5 Library for Linux

cuda8.0

sudo cp cuda/include/cudnn.h /usr/local/cuda-8.0/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64
sudo chmod a r /usr/local/cuda/include/cudnn.h /usr/local/cuda-8.0/lib64/libcudnn*

cuda9.0

sudo cp cuda/include/cudnn.h /usr/local/cuda-9.0/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64
sudo chmod a r /usr/local/cuda/include/cudnn.h /usr/local/cuda-9.0/lib64/libcudnn*

2. 安装CUDACUDNN

一、安装CUDA

  CUDA(Compute Unified Device Architecture),是速龙公司出产的一种基于新的相互编制程序模型和指令集架构的通用总括架构,它能采取英特尔GPU的并行计算引擎,比CPU更加高效的解决广大复杂总结职责,想利用GPU就必须求使用CUDA。

3.1 安装显卡驱动

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-367

澳门新濠3559 4

重启系统,使新驱动生效。使用AMD-smi测量试验是或不是安装成功。
澳门新濠3559 5

参照他事他说加以考察资料

Ubuntu 16.04 CUDA 8 cuDNN 5.1安装

2.1 cuda

  • 官方网站下载cuda,最佳下载9.0版本:
  • 慎选适合本身机器的设置,选取runfile(local)下载到centos中:
    澳门新濠3559 6
  • 亟需下载全体补丁,下载后装置cuda:
$ sudo sh cuda_9.0.176_384.81_linux.run
  • 测验cuda是不是安装
$ cd /usr/local/cuda/samples/1_Utilities/deviceQuery
$ sudo make
$ ./deviceQuery

结果:
澳门新濠3559 7

1.1、下载CUDA

  首先在官方网站()下载对应的CUDA,如图所示:

澳门新濠3559 8

瞩目请必需下载runfile文件(后缀为.run),不可能是别的文件。要么直接通过wget命令下载:

wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run

 如图所示:

澳门新濠3559 9

3.2 安装cuda-Toolkit

2.2 cudnn

  • 下载cudnn文件,供给登记账号。
  • 设置下载好的cuDNN安装包,倘使你安装cuda的目录为默许目录,就能够直接行使如下指令安装:
tar -xvf cudnn-9.0-linux-x64-v7.1.tgz -C /usr/local/

1.2、安装CUDA(应当要按顺序实践)

  下载完结后先举行安装相关依赖的命令,假使不先实施安装依赖包,前边安装CUDA会以下错误报错:

-------------------------------------------------------------
Do you accept the previously read EULA?
accept/decline/quit: accept

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
(y)es/(n)o/(q)uit: n

Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: y

Enter Toolkit Location
 [ default is /usr/local/cuda-8.0 ]: 

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y

Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: y

Enter CUDA Samples Location
 [ default is /home/cmfchina ]: 

Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...
Missing recommended library: libGLU.so
Missing recommended library: libX11.so
Missing recommended library: libXi.so
Missing recommended library: libXmu.so

Installing the CUDA Samples in /home/cmfchina ...
Copying samples to /home/cmfchina/NVIDIA_CUDA-8.0_Samples now...
Finished copying samples.

===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-8.0
Samples:  Installed in /home/cmfchina, but missing recommended libraries

Please make sure that
 -   PATH includes /usr/local/cuda-8.0/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin

Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.

***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 8.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run -silent -driver

  全体大家显著要设置顺序实行安装,先安装注重的库文件。

(1)安装缺点和失误的注重性库文件

一声令下如下:

sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-devlibgl1-mesa-glx libglu1  #安装依赖库

 

澳门新濠3559 10

(2)安装施行文书

sudo sh cuda_8.0.61_375.26_linux.run  #执行安装文件

  注意:安装进度中会提示您实行部分承认操作,首先是经受劳务条目款项,输入accept确认,然后会提示是还是不是安装cuda tookit、cuda-example等,均输入Y进行规定。但请小心,当领会是否安装附带的驱动时,必须求选N!

澳门新濠3559 11

  因为后面大家早就安装好新型的驱动NVIDIA381,附带的驱动是旧版本的还要会不通常,所以不要挑选安装驱动。别的的都一直暗中同意或然选拔是就能够。

(3)设置情况变量

  •   输入指令,编辑意况变量配置文件

    sudo vim ~/.bashrc

  •   在文书末端追加以下两行代码(按钮“i”实行编写制定操作)

    export PATH=/usr/local/cuda-8.0/bin:$PATH
    export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH export CUDA_HOME=/usr/local/cuda

  •   保存退出(按“!wq”),施行下边发号施令,使景况变量立即见效

    #意况变量立时生效 sudo source ~/.bashrc
    sudo ldconfig

 如图所示:

澳门新濠3559 12

(4)检查cuda是还是不是布置不错

  到这一步,基本的CUDA已经设置到位了,我们得以透过以下命令查看CUDA是还是不是布置不错:

nvcc --version

  如图所示:

澳门新濠3559 13

(5)测试CUDA的sammples

  为何需求安装cuda samples?一方面为了前边学习cuda使用,另一方面,可以核算cuda是不是真正安装成功。固然cuda samples全部编译通过,未有一个Error音讯(Warning忽略),那么就表达成功地设置了cuda。要是最终一行纵然呈现PASS,不过编写翻译进度中有ELANDRO索罗德,请自行互连网搜寻相关错误音讯化解现在。

# 切换到cuda-samples所在目录
cd /usr/local/cuda-8.0/samples 或者 cd /home/NVIDIA_CUDA-8.0_Samples 

# 没有make,先安装命令 sudo apt-get install cmake,-j是最大限度的使用cpu编译,加快编译的速度
make –j

# 编译完毕,切换release目录(/usr/local/cuda-8.0/samples/bin/x86_64/linux/release完整目录)
cd ./bin/x86_64/linux/release

# 检验是否成功,运行实例
./deviceQuery 

# 可以认真看看自行结果,它显示了你的NVIDIA显卡的相关信息,最后能看到Result = PASS就算成功。

如图所示:

澳门新濠3559 14

澳门新濠3559 15

 输出结果看出显卡相关新闻,並且最后Result = PASS ,那表明CUDA才真正完全安装成功了


3.2.1 试行安装文件

./cuda_8.0.44_linux-16.04.run --override

安装过程如下:

Do you accept the previously read EULA? (accept/decline/quit): accept
You are attempting to install on an unsupported configuration. Do you wish to continue? ((y)es/(n)o) [ default is no ]: y
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.48? ((y)es/(n)o/(q)uit): n
Install the CUDA 8.0 Toolkit? ((y)es/(n)o/(q)uit): y
Enter Toolkit Location [ default is /usr/local/cuda-8.0 ]:
Do you want to install a symbolic link at /usr/local/cuda? ((y)es/(n)o/(q)uit): y
Install the CUDA 8.0 Samples? ((y)es/(n)o/(q)uit): y
Enter CUDA Samples Location [ default is /home/kinghorn ]: /usr/local/cuda-8.0
Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...
Finished copying samples.
===========
= Summary =
===========
Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-8.0
Samples:  Installed in /usr/local/cuda-8.0

澳门新濠3559 16

2.3 情形变量设置

  • 情状变量
$ vim ~/.bashrc
在其最后添加:
export PATH=/usr/local/cuda/bin${PATH: :${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH: :${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda
  • cuDNN创设连接
$ cd /usr/local/cuda/lib64
$ sudo rm -rf libcudnn.so libcudnn.so.7         #删除原有版本号,版本号在cudnn/lib64中查询
$ sudo ln -s libcudnn.so.7.0.5 libcudnn.so.7    #生成软连接,注意自己下载的版本号
$ sudo ln -s libcudnn.so.7 libcudnn.so 
$ sudo ldconfig     #立即生效

二、安装cuDNN

②装置境况变量

vi /home/xxx/.bashrc

内容如下:

export PATH=/usr/local/cuda-8.0/bin:$PATH

使情状变量生效

source /home/xxx/.bashrc

③将cuda库增加到系统动态库管理器

sudo vi /etc/ld.so.conf.d/cuda.conf

添加:

/usr/local/cuda/lib64

实行ldconfig使新加的库生效

sudo ldconfig

3. 安装TensorFlow-gpu

  • 安装anaconda,能够用来树立python3和TensorFlow的局地以来境况。
$ wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh    #下载anaconda
$ bash anaconda.sh      #安装anaconda
$ vim /root/.bashrc     #加入环境变量
    # 最后一行添加:
    export PATH="/root/anaconda3/bin:$PATH"
$ source /root/.bashrc
  • 安装TensorFlow
pip install tensorflow-gpu

2.1、下载cuDNN

cuDNN是GPU加快总计深层神经互联网的库。首先去官方网站()下载cuDNN,必要注册一个账号技能下载,未有的话本身注册三个。由于本身的显卡是GTX1080Ti,所以下载版本号如图所示,最新的版本是v7: 

澳门新濠3559 17

④编写翻译cuda例子与测量试验

进入到/usr/local/cuda/NVIDIA_CUDA-8.0_Samples/1_Utilities/deviceQuery目录实行:

sudo make
./deviceQuery

打字与印刷出像样如下音讯,表达装成功

./deviceQuery Starting...
 CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 2 CUDA Capable device(s)
Device 0: "GeForce GTX 1080"
  CUDA Driver Version / Runtime Version          8.0 / 8.0
  CUDA Capability Major/Minor version number:    6.1
  Total amount of global memory:                 8110 MBytes (8504279040 bytes)
  (20) Multiprocessors, (128) CUDA Cores/MP:     2560 CUDA Cores
  GPU Max Clock rate:                            1772 MHz (1.77 GHz)
  Memory Clock rate:                             5005 Mhz
  Memory Bus Width:                              256-bit
  L2 Cache Size:                                 2097152 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 2 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

测试

输入:

$ python
>>> import tensorflow

显示:

>>> import tensorflow
/root/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
>>> 

未报错,安装成功。

转发请申明出处。

2.2、安装cuDNN

设置cudnn相比较轻巧,轻便地说,正是复制多少个文件:库文件和头文件。将cudnn的头文件复制到cuda安装路线的include路线下,将cudnn的库文件复制到cuda安装路线的lib64路线下。具体操作如下

 1 #解压文件
 2 tar -zxvf cudnn-8.0-linux-x64-v7.tgz
 3 
 4 #切换到刚刚解压出来的文件夹路径
 5 cd cuda 
 6 #复制include里的头文件(记得转到include文件里执行下面命令)
 7 sudo cp /include/cudnn.h  /usr/local/cuda/include/
 8 
 9 #复制lib64下的lib文件到cuda安装路径下的lib64(记得转到lib64文件里执行下面命令)
10 sudo cp lib*  /usr/local/cuda/lib64/
11 
12 #设置权限
13 sudo chmod a r /usr/local/cuda/include/cudnn.h 
14 sudo chmod a r /usr/local/cuda/lib64/libcudnn*
15 
16 #======更新软连接======
17 cd /usr/local/cuda/lib64/ 
18 sudo rm -rf libcudnn.so libcudnn.so.7   #删除原有动态文件,版本号注意变化,可在cudnn的lib64文件夹中查看   
19 sudo ln -s libcudnn.so.7.0.2 libcudnn.so.7  #生成软衔接(注意这里要和自己下载的cudnn版本对应,可以在/usr/local/cuda/lib64下查看自己libcudnn的版本)
20 sudo ln -s libcudnn.so.7 libcudnn.so #生成软链接
21 sudo ldconfig -v #立刻生效

 

备考:下边包车型地铁软连接的版本号要依赖本身实际下载的cudnn的lib版本号

如图所示:

澳门新濠3559 18

最终我们看看验证安装cudnn后cuda是不是照旧可用

nvcc --version  # or nvcc -V 

(3)安装cudnn-v5.1库

2.3、核准cuDNN是不是安装成功

  到如今甘休,cuDNN已经安装完了,不过,是不是中标安装,大家能够透过cuDNN sample测量检验一下( 页面中找到呼应的cudnn版本,里面有 cuDNN v5 Code 萨姆ples,点击该链接下载就能够,版本或然不均等,下载最新的就行)

  下载完,转到解压出的目录下的mnistCUDNN,如图所示:

澳门新濠3559 19

  通过上面发号施令,进行校验

#运行cudnn-sample-v5
tar –zxvf cudnn-sample-v5.tgz  #解压压缩包
cd mnistCUDNN  #转到解压的mnistCUDNN目录下
make  #make 命令下
./mnistCUDNN   #在mnistCUDNN目录下执行./mnistCUDNN
#改程序运行成功,如果结果看到Test passed!说明cudnn安装成功。

 若是结果看出Test passed!表达cudnn安装成功

澳门新濠3559 20

 至此、cuDNN已经打响安装了


 

①解压

tar xzvf cudnn-8.0-linux-x64-v5.1.tgz

赢得cuda文件夹里面含有lib64和include多少个公文夹

三、安装Anaconda

  Anaconda是python的三个科学总括发行版,内置了数百个python平时会选择的库,也包蕴相当多做机械学习或数额发掘的库,那么些库非常多是TensorFlow的注重库。安装好Anaconda能够提供一个好的意况平素设置TensorFlow。

  去Anaconda官网()下载须要版本的Anaconda

澳门新濠3559 21

  下载完后推行如下命令

sudo bash Anaconda3-4.4.0-Linux-x86_64.sh

  如图所示:

澳门新濠3559 22

  安装anaconda,回车的前边,是批准文件,接收许可。间接回车就能够。最终会精晓是不是把anaconda的bin加多到顾客的情状变量中,选取yes。在极端输入python发掘仍然是系统自带的python版本,那是因为景况变量的革新还尚无收效,命令行输入如下命令是设置的anaconda生效。借使conda --version未有找到其余新闻,表达未有步向四情形变量未有,要求手动参与,如图所示:

澳门新濠3559 23

  刷新情状变量

source /etc/profile 或者 source ~/.bashrc #(全局的环境变量)

②拷贝到cuda安装目录

sudo cp cuda/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/

拷贝后将链接删除重新确立链接,不然,拷贝是多少个多个例外名字的一致文件,链接关系采纳ls -l查看cudnn解压后的lib64文件夹。也足以分级拷贝每贰个文件,链接文件拷贝使用cp -d命令。

三、安装TensorFlow

  大家能够参见TensorFlow的法虞诩装教程(),官方网址提供的了 Pip, Docker, Virtualenv, Anaconda 或 源码编写翻译的不二秘诀安装 TensorFlow,大家那边根本介绍以Anaconda安装。别的装置情势,我们能够到法定安装教程查看。

4.安装opencv3.1.0

3.1安装TensorFlow

  通过Anaconda安装TensorFlow CPU,TensorFlow 的合法下载源今后一度在GitHub上提供了(),找到相应的本子号,如图所示:

澳门新濠3559 24

(1)解压,创建build目录

unzip opencv-3.1.0.zip
cd opencv-3.1.0
mkdir build

(2)修改opencv源码,使其包容cuda8.0

vi opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp

修改如下:
澳门新濠3559 25
将:

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)```

改为:

#if !defined(HAVE_CUDA)||defined(CUDA_DISABLER)||(CUDART_VERSION>=8000)

(3)配置opencv,生成Makefile

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

只要因为ippicv_linux_二零一六1201.tgz包下载失利而致使Makefile生成退步,可透过手动下载ippicv_linux_二〇一五1201.tgz安装包,将其拷贝至
opencv-3.1.0/3rdparty/ippicv/downloads/linux-8b449a536a2157bcad08a2b9f266828b目录内,重新试行配置命令就能够。

(1)、创制三个名称叫tensorflow的conda意况Python 3.6

#Python 2.7
conda create -n tensorflow python=2.7

#Python 3.4
conda create -n tensorflow python=3.4

#Python 3.5
conda create -n tensorflow python=3.5

#Python 3.6
conda create -n tensorflow python=3.6   #我下的TensorFlow对应的Python是3.6版本,那么我就使用这行

备注:(根据TensorFlow版本号,一定要设置Python版本号,切记切记切记!!!!!重要的事情说三遍!否则后面会报各种错的)

(4)编译

make -j8

编写翻译进程中一旦出现如下错误:

/usr/include/string.h: In function ‘void* __mempcpy_inline(void*, const void*, size_t)’: /usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope return (char *) memcpy (__dest, __src, __n)   __n;

那是因为ubuntu的g 版本过高导致的,只供给在opencv-3.1.0目录下的CMakeList.txt 文件的起首插手:

set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -D_FORCE_INLINES”)

增多其后再一次进行编写翻译就能够。

(2)、激活 conda 环境

source activate tensorflow

(5)安装

sudo make install

(3)、TensorFlow 各类版本(最新的一般是1.3的版本了)

  然后依据要安装的不等tensorflow版本采用相应的一条下载链接(操作系统,Python版本,CPU版本依然CPU GPU版本),官方文书档案都有连带消息。

Python 2.7

CPU:
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp27-none-linux_x86_64.whl

GPU:
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp27-none-linux_x86_64.whl
===============================================================================================

Python 3.4

CPU:
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp34-cp34m-linux_x86_64.whl

GPU:
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp34-cp34m-linux_x86_64.whl
===============================================================================================

Python 3.5

CPU:
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp35-cp35m-linux_x86_64.whl

GP:
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp35-cp35m-linux_x86_64.whl
===============================================================================================

Python 3.6

CPU:
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp36-cp36m-linux_x86_64.whl

GPU:
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl

(6)查看版本号

pkg-config --modversion opencv

(4)、在conda景况中安装TensorFlow GPU版(本文首要以安装GPU版疏解)

5.安装caffe

  因为大家近日选择了conda遭逢为Python3.6的,所以大家挑选Python3.6版本的GPU链接地址,举办设置

#如何进行安装,我们这里安装Python版本为3.6的TensorFlow

sudo pip3 install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl

备注:连接里的cpxx和cpxxm的xx是对应Python的版本号

荒唐总结-重视关怀!!!:

  安装whl包的时候出现“tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl is not a supported wheel on this platform”的标题。我们必要下载GPU版的安装包,在设置包下载之后,然后手动步入景况,安装TensorFlow。

具体操作如下(因为自个儿碰到这样难题,只可以用上边这种措施安装了):

source activate tensorflow    #激活tensorflow环境(这步操作了,就忽略)
cd /Downloads    #切换到whl文件所在文件夹
pip install --ignore-installed --upgrade tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl   #切记,不要用sudo pip,也不要用pip3,然后--ignore-installed --upgrade等参数也不能省略,否则会出错。

   如图所示,TensorFlow安装成功了:

澳门新濠3559 26

澳门新濠3559 27

完成天志:

cmfchina@cmfchina:~$ conda create -n tensorflow python=3.6
Fetching package metadata .........
Solving package specifications: .

Package plan for installation in environment /home/cmfchina/.conda/envs/tensorflow:

The following NEW packages will be INSTALLED:

    certifi:    2016.2.28-py36_0
    openssl:    1.0.2l-0        
    pip:        9.0.1-py36_1    
    python:     3.6.2-0         
    readline:   6.2-2           
    setuptools: 36.4.0-py36_1   
    sqlite:     3.13.0-0        
    tk:         8.5.18-0        
    wheel:      0.29.0-py36_0   
    xz:         5.2.3-0         
    zlib:       1.2.11-0        

Proceed ([y]/n)? y

#
# To activate this environment, use:
# > source activate tensorflow
#
# To deactivate this environment, use:
# > source deactivate tensorflow
#

cmfchina@cmfchina:~$ source activate tensorflow
(tensorflow) cmfchina@cmfchina:~$ wget https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl
--2017-09-26 10:06:45--  https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl
Resolving storage.googleapis.com (storage.googleapis.com)... 216.58.200.48, 2404:6800:4008:801::2010
Connecting to storage.googleapis.com (storage.googleapis.com)|216.58.200.48|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 159078494 (152M) [application/octet-stream]
Saving to: ‘tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl.1’

tensorflow_gpu-1.3. 100%[===================>] 151.71M  2.99MB/s    in 52s     

2017-09-26 10:07:38 (2.89 MB/s) - ‘tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl.1’ saved [159078494/159078494]

(tensorflow) cmfchina@cmfchina:~$ pip install --ignore-installed --upgrade tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl
Processing ./tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl
Collecting six>=1.10.0 (from tensorflow-gpu==1.3.0)
  Using cached six-1.11.0-py2.py3-none-any.whl
Collecting tensorflow-tensorboard<0.2.0,>=0.1.0 (from tensorflow-gpu==1.3.0)
  Downloading tensorflow_tensorboard-0.1.6-py3-none-any.whl (2.2MB)
    100% |████████████████████████████████| 2.2MB 345kB/s 
Collecting numpy>=1.11.0 (from tensorflow-gpu==1.3.0)
  Downloading numpy-1.13.1-cp36-cp36m-manylinux1_x86_64.whl (17.0MB)
    100% |████████████████████████████████| 17.0MB 93kB/s 
Collecting protobuf>=3.3.0 (from tensorflow-gpu==1.3.0)
  Downloading protobuf-3.4.0-cp36-cp36m-manylinux1_x86_64.whl (6.2MB)
    100% |████████████████████████████████| 6.2MB 203kB/s 
Collecting wheel>=0.26 (from tensorflow-gpu==1.3.0)
  Using cached wheel-0.30.0-py2.py3-none-any.whl
Collecting bleach==1.5.0 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
  Downloading bleach-1.5.0-py2.py3-none-any.whl
Collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
  Downloading Markdown-2.6.9.tar.gz (271kB)
    100% |████████████████████████████████| 276kB 834kB/s 
Collecting werkzeug>=0.11.10 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
  Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)
    100% |████████████████████████████████| 317kB 985kB/s 
Collecting html5lib==0.9999999 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
  Downloading html5lib-0.9999999.tar.gz (889kB)
    100% |████████████████████████████████| 890kB 673kB/s 
Collecting setuptools (from protobuf>=3.3.0->tensorflow-gpu==1.3.0)
  Using cached setuptools-36.5.0-py2.py3-none-any.whl
Building wheels for collected packages: markdown, html5lib
  Running setup.py bdist_wheel for markdown ... done
  Stored in directory: /home/cmfchina/.cache/pip/wheels/bf/46/10/c93e17ae86ae3b3a919c7b39dad3b5ccf09aeb066419e5c1e5
  Running setup.py bdist_wheel for html5lib ... done
  Stored in directory: /home/cmfchina/.cache/pip/wheels/6f/85/6c/56b8e1292c6214c4eb73b9dda50f53e8e977bf65989373c962
Successfully built markdown html5lib
Installing collected packages: six, html5lib, bleach, markdown, numpy, werkzeug, setuptools, protobuf, wheel, tensorflow-tensorboard, tensorflow-gpu
Successfully installed bleach-1.5.0 html5lib-0.9999999 markdown-2.6.9 numpy-1.13.1 protobuf-3.4.0 setuptools-36.5.0 six-1.11.0 tensorflow-gpu-1.3.0 tensorflow-tensorboard-0.1.6 werkzeug-0.12.2 wheel-0.30.0

(1)安装须要的依赖库

sudo apt-get install build-essential
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev 
sudo apt-get libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install python-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

(2)解压修改配置文件

unzip caffe-master.zip
cp Makefile.config.example Makefile.config
vi Makefile.config

关键配备修改如下:

USE_CUDNN := 1
OPENCV_VERSION := 3
CUDA_DIR :=/usr/local/cuda-8.0
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
/usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
WITH_PYTHON_LAYER := 1
USE_PKG_CONFIG := 1

(3)编译caffe

make -j8

或然境遇的一无所长1:src/caffe/net.cpp:8:18: fatal error: hdf5.h: No such file or directory
缓慢解决形式:

cd /usr/lib/x86_64-linux-gnu
sudo ln -s libhdf5_serial.so.10.1.0 libhdf5_serial.so
sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_serial_hl.so

莫不遇到的错误2:error – unsupported GNU version! gcc versions later than 5.3 are not supported!
减轻格局:修改/usr/local/cuda/include/host_config.h文件

#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 3)
#error -- unsupported GNU version! gcc versions later than 5.3 are not supported!

改为:

 #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 4)
 #error -- unsupported GNU version! gcc versions later than 5.4 are not supported!

或是境遇的失实3:

/usr/include/string.h: In function ‘void* **__mempcpy_inline(void*, const void*, size_t)’: /usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope return (char *) memcpy (__dest, __src, __n)   __n;**

化解格局:修改caffe-master的Makefile

NVCCFLAGS  =-ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)

改为:

NVCCFLAGS  =-D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)

想必遇见的不当4:

caffe/proto/caffe.pb.h: No such file or directory

动用如下方法生成caffe.pb.h

protoc src/caffe/proto/caffe.proto --cpp_out=.  
mkdir include/caffe/proto  
mv src/caffe/proto/caffe.pb.h include/caffe/proto 

(5)、在conda情况中装置TensorFlow CPU版

(4)编译caffe的python接口

make pycaffe

  因为我们前面采取了conda遭遇为Python3.6的,所以大家采取Python3.6本子的CPU链接地址,实行安装

#如何进行安装,我们这里安装Python版本为3.6的TensorFlow

sudo pip3 install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp36-cp36m-linux_x86_64.whl

备注:连接里的cpxx和cpxxm的xx是对应Python的版本号

不秦哪纳:

  安装whl包的时候出现“tensorflow-1.3.0-cp36-cp36m-linux_x86_64.whl is not a supported wheel on this platform”的问题,和方面安装GPU一样的不当。大家须求下载CPU版的安装包,在设置包下载之后,注意!!!这一年我们必要将whl文件重命名字为tensorflow-1.3.0-py3-none-linux_x86_64.whl,然后手动走入情状,安装TensorFlow。

具体操作如下:

source activate tensorflow   #激活tensorflow环境(这步操作了,就忽略)
cd /Downloads   #切换到whl文件所在文件夹
pip install --ignore-installed --upgrade tensorflow-1.3.0-py3-none-linux_x86_64.whl   #切记,不要用sudo pip,也不要用pip3,然后--ignore-installed --upgrade等参数也不能省略,否则会出错。

另外的和GPU安装是同样的,具体不做疏解。

(5)运行caffe runtest

make runtest

此地时间有一点点长。

(6)、当您绝不 TensorFlow 的时候,关闭情况

source deactivate tensorflow

6.启入手写体例程

跻身到caffe根目录下,运转脚本

(7)、安装成功后,每一回使用 TensorFlow 的时候必要激活 conda 情状(操作步骤2就能够了)

(1)获取数据

sh data/mnist/get_mnist.sh

3.2、常见难题以及错误

题材一、假设设置后,运转实例提醒ModuleNotFoundError: No module named ‘tensorflow’的话

import tensorflow as tf
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘tensorflow’

  化解办法:下载的TensorFlow对应的Python版本必须要和conda create -n tensorflow python=x.x的本子同样才行,所以TensorFlow版本有时候太高反而不好,低版本包容性越来越好,那一个看个人意愿。

题目二、出现“ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory”错误音信

Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory

 这个都以有套路的,化解办法:

  • 首先检查是或不是留存libcundnn.so.*

    find / -name libcudnn.so.*

找到文件就下一步,没找到,检查下cudnn的依赖性库,正是前方的情状变量做对了没

  • 创建硬连接

    sudo ln -s libcudnn.so.7.* libcudnn.so.6  #path正是libcudnn.so.7的随处目录

    或者

    sudo ln -s libcudnn.so.7.* libcudnn.so.6  #cd 到 libcudnn.so.7的四方目录    

这几个相应是未曾难点

(2)将标签数据转变到caffe使用的LMDB数据格式

sh examples/mnist/create_mnist.sh

3.3、卸载TensorFlow

  倘诺我们要求卸载TensorFlow的话,使用下边发号施令

sudo pip uninstall tensorflow   #Python2.7

sudo pip3 uninstall tensorflow   #Python3.x

(3)试行教练脚本

sh examples/mnist/train_lenet.sh

教练时间不一的显卡操练时间各异,gtx1080迭代10000次大致须求20s,最后结出如下所示:

I0716 14:46:01.360709 27985 solver.cpp:404]     Test net output #0: accuracy = 0.9908
I0716 14:46:01.360750 27985 solver.cpp:404]     Test net output #1: loss = 0.0303895 (* 1 = 0.0303895 loss)
I0716 14:46:01.360755 27985 solver.cpp:322] Optimization Done.
I0716 14:46:01.360757 27985 caffe.cpp:222] Optimization Done.

澳门新濠3559 28

模型精度在0.99之上。至此,在ubuntu16.04系统下行使gtx1080显卡 cudnn-v5的开拓条件就搭建实现了。

Ubuntu 14.04 安装配备CUDA  http://www.linuxidc.com/Linux/2014-10/107501.htm

Ubuntu 14.04下CUDA8.0 cuDNN v5 Caffe  装置配备  http://www.linuxidc.com/Linux/2017-01/139300.htm

Caffe配置简明教程 ( Ubuntu 14.04 / CUDA 7.5 / cuDNN 5.1 / OpenCV 3.1 ) http://www.linuxidc.com/Linux/2016-09/135016.htm

Ubuntu 16.04 安装配备MATLAB Python CUDA8.0 cuDNN OpenCV3.1的Caffe遇到  http://www.linuxidc.com/Linux/2017-06/145087.htm

在Ubuntu 14.04上配置CUDA Caffe cuDNN Anaconda DIGITS  http://www.linuxidc.com/Linux/2016-11/136775.htm

深度学习景况布置Ubuntu16.04 CUDA8.0 CUDNN5  http://www.linuxidc.com/Linux/2017-09/147180.htm

本文永恒更新链接地址:http://www.linuxidc.com/Linux/2017-10/147609.htm

澳门新濠3559 29

3.4、测试TensorFlow

  在python的条件中,运维轻巧的TensorFlow程序测量试验(官方demo)

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> sess.run(hello)
'Hello, TensorFlow!'
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> sess.run(a   b)
42
>>> sess.close()

 运营如图所示:

澳门新濠3559 30

到现在,TensorFlow安装成功,进度充满了辛勤..(。•ˇ‸ˇ•。)…所以我们安装的时候每一步都注重~

 

PS:如有疑问,请留言,未经同意,不得专断转发,转发请注明出处: 

澳门新濠3559 31

澳门新濠3559 32

编辑:操作系统 本文来源:安装成功【澳门新濠3559】,使环境变量生效

关键词: 澳门新濠3559