ubuntu安装 tensorflow GPU
安装支持GPU的tensorflow前提是正确安装好了 CUDA 和 cuDNN。
CUDA 和 cuDNN的安装见 Nvidia 官网和各种安装教程,应该很容易,重点是要选准了支持自己GPU的 CUDA 版本,再选准支持 该 CUDA 版本的 cuDNN版本。
关于CUDA:
tensorflow-gpu 1.5 及以上版本要求 CUDA 版本为9.0;
如果本机装的 CUDA版本是8,安装了 tensorflow-gpu 1.5及以上版本,会报错:
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
查看本机 CUDA 版本方法:
cat /usr/local/cuda/version.txt
输出:
CUDA Version 8.0.61
关于cuDNN:
tensorflow-gpu 1.3及以上版本要求cudnn版本为V6及以上;
如果本机装得 cuDNN版本是 V5,安装了 tensorflow-gpu 1.3及以上版本,会报错:
libcudnn.so.6:cannot open sharedobject file: No such file or directory
查看本机 cuDNN版本方法:
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
输出:
#define CUDNN_MAJOR 5
#define CUDNN_MINOR 0
#define CUDNN_PATCHLEVEL 5
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)
#include "driver_types.h"
本机装了 CUDA 8和 cuDNN V5,对照以上两条,选择安装 tensorflow 1.2版本,安装指令:
pip install tensorflow-gpu==1.2
输出贴出来:
Collecting tensorflow-gpu==1.2
Downloading tensorflow_gpu-1.2.0-cp27-cp27mu-manylinux1_x86_64.whl (89.2MB)
100% |████████████████████████████████| 89.2MB 15kB/s
Collecting backports.weakref==1.0rc1 (from tensorflow-gpu==1.2)
Downloading backports.weakref-1.0rc1-py2-none-any.whl
Requirement already satisfied: wheel in ./anaconda2/lib/python2.7/site-packages (from tensorflow-gpu==1.2)
Requirement already satisfied: bleach==1.5.0 in ./anaconda2/lib/python2.7/site-packages (from tensorflow-gpu==1.2)
Requirement already satisfied: numpy>=1.11.0 in ./anaconda2/lib/python2.7/site-packages (from tensorflow-gpu==1.2)
Collecting markdown==2.2.0 (from tensorflow-gpu==1.2)
Downloading Markdown-2.2.0.tar.gz (236kB)
100% |████████████████████████████████| 245kB 42kB/s
Requirement already satisfied: mock>=2.0.0 in ./anaconda2/lib/python2.7/site-packages (from tensorflow-gpu==1.2)
Requirement already satisfied: html5lib==0.9999999 in ./anaconda2/lib/python2.7/site-packages (from tensorflow-gpu==1.2)
Requirement already satisfied: werkzeug>=0.11.10 in ./anaconda2/lib/python2.7/site-packages (from tensorflow-gpu==1.2)
Requirement already satisfied: six>=1.10.0 in ./anaconda2/lib/python2.7/site-packages (from tensorflow-gpu==1.2)
Requirement already satisfied: protobuf>=3.2.0 in ./anaconda2/lib/python2.7/site-packages (from tensorflow-gpu==1.2)
Requirement already satisfied: funcsigs>=1; python_version < "3.3" in ./anaconda2/lib/python2.7/site-packages (from mock>=2.0.0->tensorflow-gpu==1.2)
Requirement already satisfied: pbr>=0.11 in ./anaconda2/lib/python2.7/site-packages (from mock>=2.0.0->tensorflow-gpu==1.2)
Requirement already satisfied: setuptools in ./anaconda2/lib/python2.7/site-packages (from protobuf>=3.2.0->tensorflow-gpu==1.2)
Building wheels for collected packages: markdown
Running setup.py bdist_wheel for markdown ... done
Stored in directory: /home/dcrmg/.cache/pip/wheels/b9/4f/6c/f4c1c5207c1d0eeaaf7005f7f736620c6ded6617c9d9b94096
Successfully built markdown
Installing collected packages: backports.weakref, markdown, tensorflow-gpu
Found existing installation: backports.weakref 1.0.post1
Uninstalling backports.weakref-1.0.post1:
Successfully uninstalled backports.weakref-1.0.post1
Found existing installation: Markdown 2.6.11
Uninstalling Markdown-2.6.11:
Successfully uninstalled Markdown-2.6.11
Successfully installed backports.weakref-1.0rc1 markdown-2.2.0 tensorflow-gpu-1.2.0
要安装哪个版本的tensorflow-gpu,使用 ‘tensorflow-gpu==xx’就行了,安装 1.4版本:
pip install tensorflow-gpu==1.4
要卸载也很容易:
pip uninstall tensorflow-gpu
测试tensorflow是否可以使用GPU
import tensorflow as tf
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
输出:
2018-03-19 07:29:43.114843: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2018-03-19 07:29:43.114898: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2018-03-19 07:29:43.114917: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2018-03-19 07:29:43.114940: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2018-03-19 07:29:43.114960: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2018-03-19 07:29:43.388602: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:893] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-03-19 07:29:43.389607: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 0 with properties:
name: GeForce GTX 970
major: 5 minor: 2 memoryClockRate (GHz) 1.1775
pciBusID 0000:01:00.0
Total memory: 3.94GiB
Free memory: 3.71GiB
2018-03-19 07:29:43.389661: I tensorflow/core/common_runtime/gpu/gpu_device.cc:961] DMA: 0
2018-03-19 07:29:43.389682: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0: Y
2018-03-19 07:29:43.389722: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 970, pci bus id: 0000:01:00.0)
Device mapping:
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce GTX 970, pci bus id: 0000:01:00.0
2018-03-19 07:29:43.455817: I tensorflow/core/common_runtime/direct_session.cc:265] Device mapping:
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce GTX 970, pci bus id: 0000:01:00.0
输出里有 GPU的名称,显存等信息,表示tensorflow可以使用GPU了。
ubuntu安装 tensorflow GPU的更多相关文章
- 【Tensorflow】Ubuntu 安装 Tensorflow gpu
安装环境:Ubuntu 16.04lts 64位,gcc5.4 1.安装Cuda 1. 下载cuda toolkit. 下载cuda8.0 地址:https://developer.nvidia.co ...
- Ubuntu在Anaconda中安装TensorFlow GPU,Keras,Pytorch
安装TensorFlow GPU pip install --ignore-installed --upgrade tensorflow-gpu 安装测试: $ source activate tf ...
- 通过Anaconda在Ubuntu16.04上安装 TensorFlow(GPU版本)
一. 安装环境 Ubuntu16.04.3 LST GPU: GeForce GTX1070 Python: 3.5 CUDA Toolkit 8.0 GA1 (Sept 2016) cuDNN v6 ...
- ubuntu16.04下安装TensorFlow(GPU加速)----详细图文教程【转】
本文转载自:https://blog.csdn.net/zhaoyu106/article/details/52793183 le/details/52793183 写在前面 一些废话 接触深度学习已 ...
- ubuntu 安装TensorFlow
1.安装pip $ sudo apt-get install python-pip python-dev 2.安装 TensorFlow for Python 2.7 # Ubuntu/Linux - ...
- win10系统下安装TensorFlow GPU版本
首先要说,官网上的指南是最好的指南. https://www.tensorflow.org/install/install_windows 需要FQ看. 想要安装gpu版本的TensorFlow.我们 ...
- windows安装tensorflow GPU
一.安装Anaconda Anaconda是Python发行包,包含了很多Python科学计算库.它是比直接安装Python更好的选择. 二.安装Tensorflow 如果安装了tensorflow, ...
- 说说Windows7 64bits下安装TensorFlow GPU版本会遇到的一些坑
不多说,直接上干货! 再写博文,回顾在Windows7上安装TensorFlow-GPU的一路坑 Windows7上安装TensorFlow的GPU版本后记 欢迎大家,加入我的微信公众号:大数据躺过的 ...
- Windows7 64bits下安装TensorFlow GPU版本(图文详解)
不多说,直接上干货! Installing TensorFlow on Windows的官网 https://www.tensorflow.org/install/install_windows 首先 ...
随机推荐
- 4196: [Noi2015]软件包管理器
Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 412 Solved: 251[Submit][Status][Discuss] Descriptio ...
- ubuntu下wget的配置文件在哪里
答:/etc/wgetrc 这个文件里可以指定代理,如: http_proxy = http://myproxy.com:8080
- 使用ubifs作为根文件系统的openwrt如何在进行sysupgrade时保存旧的配置
1.openwrt的默认方案(squashfs + jffs2) sysupgrade脚本直接调用default_do_upgrade更新设备树.内核.根文件系统,那么它是如何保存旧配置的呢?请看de ...
- eclipse中把多个项目放在一个文件夹里
1..Package Explorer 可以在这里打开 2.选择Working sets 3.新建java working set 4.把文件夹显示出来 5.可以把项目移动到文件夹里面了,鼠标左键拖就 ...
- eclipse创建文件package,source folder和folder区别及相互转换
原文:http://blog.csdn.net/u014079773/article/details/66973910 https://www.cnblogs.com/shihaiming/p/735 ...
- maven笔记(2)
项目管理利器(Maven)——maven的生命周期和插件Maven的生命周期大概如下:clean compile test package install这几个命令对应了一个项目的完整的构建过程,这几 ...
- Java之聊天室系统设计一
任务: 先上实现效果图: 登陆界面: index.jsp: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN& ...
- Mac OSX 如何在命令行中生成 md5、sha1、sha256 校验和
计算 MD5 校验和 md5 /tmp/hello.txt 计算 SHA-1 校验和 shasum -a 1 /tmp/hello.txt 计算 SHA-256 校验和 shasum -a 256 / ...
- C# SQLite写入和读取DateTime类型
很简单 1.不要相信网上大部分人说的话,比如存到int里 (ps:版本差距知道吗?) 2.nuget包下载最新版的sqlite 3.SQLite支持DateTime类型(图形化工具不会给提示无视它), ...
- 以普通用户启动的Vim如何保存需要root权限的文件
在Linux上工作的朋友很可能遇到过这样一种情况,当你用Vim编辑完一个文件时,运行:wq保存退出,突然蹦出一个错误: E45: 'readonly' option is set (add ! to ...