条件搭建,Centos配置深度学习开垦条件

图片 24

条件搭建,Centos配置深度学习开垦条件

目录

图片 1

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

  紧接着上生机勃勃篇的篇章《深度学习(TensorFlow)情状搭建:(二)Ubuntu16.04+1080Ti显卡驱动》,那篇小说,主要教授怎么着设置CUDA+CUDNN,可是前提是我们是已经把NVIDIA显卡驱动装置好了

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

2. 安装CUDACUDNN

一、安装CUDA

  CUDA(Compute Unified Device
Architecture卡塔尔国,是英特尔集团出产的大器晚成种基于新的相互编制程序模型和下令集布局的通用总结构造,它能接受英特尔GPU的并行总括引擎,比CPU更急迅的消除多数错综相连计算任务,想利用GPU就一定要使用CUDA。

2.1 cuda

  • 官网下载cuda,最佳下载9.0本子:
  • 分选切合自身机器的设置,选择runfile(local)下载到centos中:
    图片 2
  • 急需下载全体补丁,下载后装置cuda:

$ sudo sh cuda_9.0.176_384.81_linux.run
  • 测验cuda是不是安装

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

结果:
图片 3

1.1、下载CUDA

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

图片 4

留心请必须下载runfile文件(后缀为.run),不可能是别的文件。依旧直接通过wget命令下载:

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

 如图所示:

图片 5

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  #安装依赖库

 

图片 6

(2)安装推行文书

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

  注意:安装进程中会提示您实香港行政局地肯定操作,首先是经受劳动条目,输入accept确认,然后会唤醒是还是不是安装cuda tookit、cuda-example等,均输入Y举办规定。但请留心,当了然是否安装附带的驱动时,必定要选N!

图片 7

  因为前边我们曾经设置好新型的驱动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

 如图所示:

图片 8

(4)检查cuda是或不是配备不错

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

nvcc --version

  如图所示:

图片 9

(5)测试CUDA的sammples

  为何供给设置cuda
samples?一方面为了前边学习cuda使用,另一面,能够核准cuda是还是不是真的安装成功。假如cuda
samples全体编写翻译通过,未有三个Error新闻(Warning忽视),那么就证实成功地设置了cuda。固然最终生龙活虎行即使展现PASS,不过编写翻译进程中有E奔驰G级ROXC60,请自行英特网搜索相关错误消息消亡今后。

# 切换到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就算成功。

如图所示:

图片 10

图片 11

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


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

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增加速度总结深层神经网络的库。首先去官方网站(卡塔尔(英语:State of Qatar)下载cuDNN,必要登记叁个账号技术下载,未有的话本身注册三个。由于本身的显卡是GTX1080Ti,所以下载版本号如图所示,最新的版本是v7: 

图片 12

测试

输入:

$ 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版本号

如图所示:

图片 13

最后大家看看验证安装cudnn后cuda是或不是如故可用

nvcc --version  # or nvcc -V 

2.3、查证cuDNN是或不是安装成功

  到这段日子甘休,cuDNN已经设置完了,但是,是或不是成功安装,大家得以经过cuDNN
sample测验一下(
页面中找到呼应的cudnn版本,里面有 cuDNN v5 Code
萨姆ples,点击该链接下载就能够,版本恐怕不意气风发致,下载最新的就能够卡塔尔(英语:State of Qatar)

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

图片 14

  通过下边忘乎所以,实行校验

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

 即使结果见到Test
passed!表达cudnn安装成功

图片 15

 至此、cuDNN已经打响安装了


 

三、安装Anaconda

  Anaconda是python的二个科学总计发行版,内置了数百个python日常会接收的库,也包涵不菲做机械学习或数额开采的库,那些库超级多是TensorFlow的信赖库。安装好Anaconda能够提供三个好的情状一向设置TensorFlow。

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

图片 16

  下载完后实施如下命令

sudo bash Anaconda3-4.4.0-Linux-x86_64.sh

  如图所示:

图片 17

  安装anaconda,回车的前边,是批准文件,选取许可。间接回车就能够。最终会询问是还是不是把anaconda的bin增多到顾客的意况变量中,接受yes。在终端输入python开掘依然是系统自带的python版本,那是因为境况变量的换代还一贯不立见成效,命令行输入如下命令是安装的anaconda生效。假若conda
–version没有找到其他音信,表达未有投入随地境变量未有,需求手动参预,如图所示:

图片 18

  刷新际遇变量

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

三、安装TensorFlow

  我们能够参照TensorFlow的官方安装教程(),官方网址提供的了
Pip, Docker, Virtualenv, Anaconda 或 源码编写翻译的不二诀窍安装
TensorFlow,我们那边境海关键介绍以Anaconda安装。别的设置格局,我们能够到法定安装教程查看。

3.1安装TensorFlow

  通过Anaconda安装TensorFlow
CPU,TensorFlow
的法定下载源今后曾在GitHub上提供了(),找到呼应的版本号,如图所示:

图片 19

(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版本号,切记切记切记!!!!!重要的事情说三遍!否则后面会报各种错的)

(2)、激活 conda 环境

source activate tensorflow

(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

(4)、在conda情形中安装TensorFlow GPU版(本文首要以安装GPU版讲明)

  因为我们面前接收了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。

具体操作如下(因为本人遇见这么难点,只好用下边这种艺术安装了卡塔尔(英语:State of Qatar):

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安装成功了:

图片 20

图片 21

生机勃勃体化日志:

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

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

  因为我们方今选用了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安装是生龙活虎律的,具体不做疏解。

(6)、当您绝不 TensorFlow 的时候,关闭蒙受

source deactivate tensorflow

(7)、安装成功后,每一遍使用 TensorFlow 的时候供给激活 conda 意况(操作步骤2就能够了)

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的随处目录    

以此应该是绝非难点

3.3、卸载TensorFlow

  假若大家须求卸载TensorFlow的话,使用下边镇定自若

sudo pip uninstall tensorflow   #Python2.7

sudo pip3 uninstall tensorflow   #Python3.x

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()

 运维如图所示:

图片 22

于今,TensorFlow安装成功,进程充满了费力..(。•ˇ‸ˇ•。卡塔尔国…所以大家安装的时候每一步都至关心重视要~

 

PS:如有疑问,请留言,未经同意,必须要合规转发,转发请评释出处: 

图片 23

图片 24

admin

网站地图xml地图