我是靠谱客的博主 爱笑大树,最近开发中收集的这篇文章主要介绍Linux安装TensorFlow1.2.0版本以及cuda 8.0 以及CUDNN 5.0版本,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

 有问题欢迎讨论

首先安装anaconda

下载

在命令行 bash Anaconda2-4.2.0-Linux-x86_64.sh

 

 

 

安装cuda

下载cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64.deb

之后打开终端输入:

>>> sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb

>>> sudo apt update

>>> sudo apt -y install cuda

自动配置成功就好。

·        CUDA路径添加至环境变量终端输入:

>>> sudo vim /etc/profile

profile文件中添加:

export CUDA_HOME=/usr/local/cuda-8.0

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

export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

之后source/etc/profile即可

·        测试终端输入:

>>> nvcc -V

会得到相应的nvcc编译器相应的信息,那么CUDA配置成功了。(记得重启系统)

 

下载cuDNN

上官网下载对应的cudnn

 

https://developer.nvidia.com/cudnn


我的CSDN:

 http://download.csdn.net/download/baoyan2015/10113650(欢迎下载)


 

下载完cudnn后,命令行输入文件所在的文件夹 (ubuntu为本机用户名)

 

cd home/ubuntu/Downloads/

 

tar zxvf cudnn-8.0-linux-x64-v5.1.tgz #解压文件

 

cd进入cudnn5.1解压之后的include目录,在命令行进行如下操作:

 

sudo cp cudnn.h /usr/ cuda/include/ #复制头文件

 

再cd进入lib64目录下的动态文件进行复制和链接:(5.1.5为对应版本具体可修改)

 

sudo cp lib* /usr/local/cuda/lib64/ #复制动态链接库

 

cd /usr/local/cuda/lib64/

 

sudo rm -rf libcudnn.so libcudnn.so.5 #删除原有动态文件

 

sudo ln -s libcudnn.so.5.1.5 libcudnn.so.5#生成软衔接

 

sudo ln -s libcudnn.so.5 libcudnn.so #生成软链接

 

 

注意,我的服务器按了cuda8.0和9.0。所以在/usr/local/下的文件夹名字为cuda-8.0这些都要对应。这个没办法看成功了与否

 

 

接下安装tensorflow

命令

pip install tensorflow-gpu==1.2.0(1.1.0很慢然后断掉,不指定版本与cuda不对应也一般安装不成功)

 

安装keras

pip install keras

  测试 :

进入python环境

 wby@imsl-desktop:~/keras-master/CaiJingSC$python

Python 2.7.13 |Anaconda custom (64-bit)|(default, Dec 20 2016, 23:09:15)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] onlinux2

Type "help","copyright", "credits" or "license" for moreinformation.

Anaconda is brought to you by ContinuumAnalytics.

Please check out:http://continuum.io/thanks and https://anaconda.org

>>> import keras

Using TensorFlow backend.

2017-11-10 17:17:04.430540: Wtensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn'tcompiled to use SSE4.1 instructions, but these are available on your machineand could speed up CPU computations.

2017-11-10 17:17:04.430589: Wtensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn'tcompiled to use SSE4.2 instructions, but these are available on your machineand could speed up CPU computations.

2017-11-10 17:17:04.430599: W tensorflow/core/platform/cpu_feature_guard.cc:45]The TensorFlow library wasn't compiled to use AVX instructions, but these areavailable on your machine and could speed up CPU computations.

2017-11-10 17:17:04.430607: Wtensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn'tcompiled to use FMA instructions, but these are available on your machine andcould speed up CPU computations.

2017-11-10 17:17:04.578373: Itensorflow/stream_executor/cuda/cuda_gpu_executor.cc:893] successful NUMA noderead from SysFS had negative value (-1), but there must be at least one NUMAnode, so returning NUMA node zero

2017-11-10 17:17:04.578780: Itensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 0 withproperties:

name: GeForce GTX 1070

major: 6 minor: 1 memoryClockRate (GHz)1.835

pciBusID 0000:01:00.0

Total memory: 7.92GiB

Free memory: 312.00MiB

2017-11-10 17:17:04.578806: Itensorflow/core/common_runtime/gpu/gpu_device.cc:961] DMA: 0

2017-11-10 17:17:04.578819: Itensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0:   Y

2017-11-10 17:17:04.578843: Itensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlowdevice (/gpu:0) -> (device: 0, name: GeForce GTX 1070, pci bus id:0000:01:00.0)

>>> 

成功。

最后

以上就是爱笑大树为你收集整理的Linux安装TensorFlow1.2.0版本以及cuda 8.0 以及CUDNN 5.0版本的全部内容,希望文章能够帮你解决Linux安装TensorFlow1.2.0版本以及cuda 8.0 以及CUDNN 5.0版本所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部