TensorFlow入门——安装(带GPU)

这一系列基本上是属于我自己进行到了那个步骤就做到那个步骤的

由于新装了GPU (GTX750ti)和CUDA9.0、CUDNN7.1版本的软件,所以希望TensorFlow能在GPU上运行,也算上补上之前的承诺

说了下初衷,由于现在新的CUDA版本对TensorFlow的支持不好,只能采取编译源码的方式进行

所以大概分为以下几个步骤

1.安装依赖库(这部分我已经做过了,不进行介绍,可以看前边的依赖库,基本一致)

2.安装Git(有的就跳过这一步)

3.安装TensorFlow的build工具bazel

4.编译TensorFlow源码

5.安装并配置环境变量

1.安装依赖库

2.安装Git

使用

sudo apt-get install git

3. 安装TensorFlow的build工具bazel

这一步比较麻烦,是因为apt-get中没有bazel这个工具

因此需要到GitHub上先下载,再进行安装 下载地址是https://github.com/bazelbuild/bazel/releases

选择正确版本下载,并使用sudo命令安装.sh文件即可

4.编译TensorFlow源码

这一步特别麻烦,有很多选项需要选择,我的选择如下:

 1 [email protected]:~/tools/tensorflow$ ./configure
 2 WARNING: Running Bazel server needs to be killed, because the startup options are different.
 3 You have bazel 0.14.1 installed.
 4 Please specify the location of python. [Default is /usr/bin/python]:
 5
 6
 7 Found possible Python library paths:
 8   /usr/local/lib/python2.7/dist-packages
 9   /usr/lib/python2.7/dist-packages
10 Please input the desired Python library path to use.  Default is [/usr/local/lib/python2.7/dist-packages]
11
12 Do you wish to build TensorFlow with jemalloc as malloc support? [Y/n]: Y
13 jemalloc as malloc support will be enabled for TensorFlow.
14
15 Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: n
16 No Google Cloud Platform support will be enabled for TensorFlow.
17
18 Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: n
19 No Hadoop File System support will be enabled for TensorFlow.
20
21 Do you wish to build TensorFlow with Amazon S3 File System support? [Y/n]: n
22 No Amazon S3 File System support will be enabled for TensorFlow.
23
24 Do you wish to build TensorFlow with Apache Kafka Platform support? [Y/n]: n
25 No Apache Kafka Platform support will be enabled for TensorFlow.
26
27 Do you wish to build TensorFlow with XLA JIT support? [y/N]: y
28 XLA JIT support will be enabled for TensorFlow.
29
30 Do you wish to build TensorFlow with GDR support? [y/N]: y
31 GDR support will be enabled for TensorFlow.
32
33 Do you wish to build TensorFlow with VERBS support? [y/N]: y
34 VERBS support will be enabled for TensorFlow.
35
36 Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: N
37 No OpenCL SYCL support will be enabled for TensorFlow.
38
39 Do you wish to build TensorFlow with CUDA support? [y/N]: y
40 CUDA support will be enabled for TensorFlow.
41
42 Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 9.0]: 8
43
44
45 Please specify the location where CUDA 8.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
46
47
48 Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7.0]:
49
50
51 Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
52
53
54 Do you wish to build TensorFlow with TensorRT support? [y/N]: N
55 No TensorRT support will be enabled for TensorFlow.
56
57 Please specify the NCCL version you want to use. [Leave empty to default to NCCL 1.3]:
58
59
60 Please specify a list of comma-separated Cuda compute capabilities you want to build with.
61 You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
62 Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 5.0]
63
64
65 Do you want to use clang as CUDA compiler? [y/N]: N
66 nvcc will be used as CUDA compiler.
67
68 Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]:
69
70
71 Do you wish to build TensorFlow with MPI support? [y/N]: N
72 No MPI support will be enabled for TensorFlow.
73
74 Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:
75
76
77 Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: N
78 Not configuring the WORKSPACE for Android builds.
79
80 Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See tools/bazel.rc for more details.
81     --config=mkl             # Build with MKL support.
82     --config=monolithic      # Config for mostly static monolithic build.
83 Configuration finished

然后使用bazel进行编译(本步骤非常容易出问题,而且特别耗时)

bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

5.安装并配置环境变量

使用pip进行安装

$ sudo pip install /tmp/tensorflow_pkg/tensorflow

# with no spaces after tensorflow hit tab before hitting enter to fill in blanks

最后就是测试

import tensorflow as tf
sess = tf.InteractiveSession()
sess.close()

如果每一步都不报错的,TensorFlow就编译并安装成功了

原文地址:https://www.cnblogs.com/jourluohua/p/9180709.html

时间: 2024-08-05 21:48:57

TensorFlow入门——安装(带GPU)的相关文章

真正从零开始,TensorFlow详细安装入门图文教程!(linux)

读懂智能&未来 首页 专栏 专题 公开课   AI慕课学院 爱搞机 极客购 申请专栏作者 业界人工智能智能驾驶AI+Fintech未来医疗网络安全AR/VR机器人开发者智能硬件物联网GAIR 业界正文 13 真正从零开始,TensorFlow详细安装入门图文教程! 本文作者:黄鑫 2016-06-11 21:32 导语:帮你完成那个最难的从0到1 AI这个概念好像突然就火起来了,年初大比分战胜李世石的AlphaGo成功的吸引了大量的关注,但其实看看你的手机上的语音助手,相机上的人脸识别,今日头条

【转】真正从零开始,TensorFlow详细安装入门图文教程!(帮你完成那个最难的从0到1)

AI这个概念好像突然就火起来了,年初大比分战胜李世石的AlphaGo成功的吸引了大量的关注,但其实看看你的手机上的语音助手,相机上的人脸识别,今日头条上帮你自动筛选出来的新闻,还有各大音乐软件的歌曲"每日推荐"--形形色色的AI早已进入我们生活的方方面面.深刻的影响了着我们,可以说,这是一个AI的时代. 其实早在去年年底,谷歌就开源了其用来制作AlphaGo的深度学习系统Tensorflow,相信有不少同学曾经对着这款强大的机器学习系统蠢蠢欲动,但虽然有关Tensorflow的教程其实

深度学习入门——测试PyTorch和Tensorflow能正常使用GPU

1.测试PyTorch能正常使用GPU: import torch torch.cuda.is_available() 返回结果: True 2.测试Tensorflow能正常使用GPU: 示例一: tf.test.is_gpu_available() 返回结果: True 示例二: gpu_device_name = tf.test.gpu_device_name() print(gpu_device_name) 返回结果: /device:GPU:0 示例三: import tensorfl

在Windows上玩TensorFlow(一)——安装Docker【转】

"谷歌"+"深度学习",两个标签让2015年12月才由谷歌开源的深度学习工具TensorFlow在其发布之后就迅速地成为了全球最为炙手可热的开源项目,2016年4月,开源的TensorFlow又支持了分布式特性,向着生产环境下的应用更进一步. TensorFlow API支持Python 2.7和Python 3.3+,共支持4种安装方式. Pip install Virtualenv install Anaconda install Docker install

Tensorflow的安装和使用——Jetson Nano 初体验3

目录 1.安装 Jupyter notebook 和 Jupyter Lab 1.1 安装pip3 1.2 安装 Jupyter notebook 1.3 启动 notebook 服务器并配置远程访问 1.3.1 配置Jupyter 1.3.2 启动 notebook 1.3.3 关闭 Jupyter 1.3.4 保存Notebook 1.4 Notebook用法 1.4.1 Markdown单元格 1.4.2 Magic关键词 1.5 Jupyter Lab 安装 1.5.1 安装Jupyte

Mongodb for PHP教程之入门安装

简介: MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的.他支持的数据结构非常松散,是类似json的bjson格式,因此可以存储比较复杂的数据类型.Mongo最大的特点是他支持的查询语言非常强大,其语法有点类似于面向对象的查询语言,几乎可以实现类似关系数据库单表查询的绝大部分功能,而且还支持对数据建立索引. 它的特点是高性能.易部署.易使用,存储数据非常方便.主要功能特性有: · 面向集合存储,易存储对象类型的数据. · 模式自由. · 

win10上Tensorflow的安装教程

这几天打算自己入门学习机器学习的内容,首先要安装Tensorflow. 自己捣鼓了几天才捣鼓出来.可能真的是比较笨orz 现在试试写一个教程,希望可以帮到迷路滴孩子们! 大体地说四步: 安装python环境->配置python的path->安装numpy->安装tensorflow step1 安装python环境 安装python的时候 进入这个地方:https://www.python.org/downloads/windows/ 点选Windows x86-64 executabl

GoLang入门-安装-配置

Go的三种安装方式 Go有多种安装方式,你可以选择自己喜欢的.这里我们介绍三种最常见的安装方式: Go源码安装:这是一种标准的软件安装方式.对于经常使用Unix类系统的用户,尤其对于开发者来说,从源码安装是最方便而熟悉的.Go标准包安装:Go提供了方便的安装包,支持Windows.Linux.Mac等系统.这种方式适合初学者,可根据自己的系统位数下载好相应的安装包,一路next就可以轻松安装了.第三方工具安装:目前有很多方便的第三方软件包工具,例如Ubuntu的apt-get.Mac的homeb

Debian 入门安装与配置1

Debian 入门安装与配置1 最近安装了多个发行版本的Linux,包括Ubuntu.Fedora.Centos和Debian,发现只有Debian在界面和稳定性等综合特性上表现最优,自己也最喜欢,所以最后选择长久使用Debian作为自己的家用笔记本操作系统,也想借助Debian来深入的学习Linux,因此在这里记录一些日生使用Debian过程中遇到的问题及解决办法. 1.Debian安装 选择Debian的版本对于新手至关重要,本人安装Debian的时候,Debian官方发行稳定版本是7.7.