1、TensorFlow安装:

  使用pip install tensorflow安装CPU版;

  或使用pip install tensorflow-gpu==1.2.1指定版本安装GPU版。

2、TensorFlow测试样例:

import tensorflow as tf
a = tf.constant([1.0, 2.0], name="a")
b = tf.constant([3.0, 4.0], name="b")
add = a + b
sess = tf.Session()
sess.run(add)

  使用python的import操作加载TensorFlow;

  使用tf.constant函数定义两个常量tensor,并将两个tensor相加;

  使用tf.Session函数生成一个会话(session)并通过这个session来计算结果;

  以上若运行无误,则说明TensorFlow安装成功。

3、TensorFlow指定GPU占用 示例:

import os
import tensorflow as tf
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = ""
config = tf.ConfigProto()
# 设置定量的GPU使用量,占用GPU50%的显存
# config.gpu_options.per_process_gpu_memory_fraction = 0.5
# 设置最小的GPU使用量,自动增长:按需求分配显存
config.gpu_options.allow_growth = True
# 打印详细日志信息
config.log_device_placement = True
a = tf.constant([1.0, 2.0], name="a")
b = tf.constant([3.0, 4.0], name="b")
add = a + b
with tf.Session(config=config) as sess:
sess.run(add)

  使用os.environ指定具体的GPU,指定GPU占用可参考TensorFlow指定GPU使用及监控GPU占用情况

  使用tf.ConfigProto()函数设置config设定GPU使用量及tf的其他属性参数,并在tf.Session()中指定该config。

TensorFlow Action(开山使用篇)的更多相关文章

  1. [翻译] TensorFlow 分布式之论文篇 "TensorFlow : Large-Scale Machine Learning on Heterogeneous Distributed Systems"

    [翻译] TensorFlow 分布式之论文篇 "TensorFlow : Large-Scale Machine Learning on Heterogeneous Distributed ...

  2. [翻译] TensorFlow 分布式之论文篇 "Implementation of Control Flow in TensorFlow"

    [翻译] TensorFlow 分布式之论文篇 "Implementation of Control Flow in TensorFlow" 目录 [翻译] TensorFlow ...

  3. salesforce lightning零基础学习(十) Aura Js 浅谈三: $A、Action、Util篇

    前两篇分别介绍了Component类以及Event类,此篇将会说一下 $A , Action以及 Util.  一. Action Action类通常用于和apex后台交互,设置参数,调用后台以及对结 ...

  4. [Android Pro] AndroidStudio IDE界面插件开发(进阶篇之Action机制)

    转载请注明出处:[huachao1001的专栏:http://blog.csdn.net/huachao1001/article/details/53883500] 从上一篇<AndroidSt ...

  5. [源码解析] TensorFlow 分布式 DistributedStrategy 之基础篇

    [源码解析] TensorFlow 分布式 DistributedStrategy 之基础篇 目录 [源码解析] TensorFlow 分布式 DistributedStrategy 之基础篇 1. ...

  6. Struts2第二篇【开发步骤、执行流程、struts.xml讲解、defalut-struts讲解】

    前言 我们现在学习的是Struts2,其实Struts1和Struts2在技术上是没有很大的关联的.Struts2其实基于Web Work框架的,只不过它的推广没有Struts1好,因此就拿着Stru ...

  7. Struts2入门这一篇就够了

    前言 这是Strtus的开山篇,主要是引入struts框架...为什么要引入struts,引入struts的好处是什么,以及对Struts2一个简单的入门.... 为什么要引入struts? 既然Se ...

  8. 双显卡笔记本安装CUDA+theano、tensorflow环境

    原文出处:http://www.cnblogs.com/jacklu/p/6377820.html 个人知乎主页欢迎关注:https://www.zhihu.com/people/jack_lu,相信 ...

  9. 统计学习方法:罗杰斯特回归及Tensorflow入门

    作者:桂. 时间:2017-04-21  21:11:23 链接:http://www.cnblogs.com/xingshansi/p/6743780.html 前言 看到最近大家都在用Tensor ...

随机推荐

  1. 报错:LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 1>

    这段时间忙于看文献,没用过VS了. 今天用着用着就报错了: LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 1> 问度娘,大神给出了解决方法 ...

  2. linux网络管理之网络基础

    iso/osi模型 OSI七层框架每层作用 应用层:用户操作的层 表示层:二进制数据与显示数据之间的转换,也是加密的地方 会话层:确定网络传输还是本地存储,是邮件还是ppt等 传输层:确定tcp还是u ...

  3. GIS可视化——聚散图

    一.简介 随着计算机的发展,浏览器的不断进步与完善,现今大部分浏览渲染效率有了很大的改善, 但是由于浏览器厂商的不同,浏览器种类繁多,性能不一,并且很多用户还使用着不少老的浏览, 那些如IE6.7等的 ...

  4. WinForm启动时接收参数

    1 默认的Main函数,修改如下: static class Program { /// <summary> /// 应用程序的主入口点. /// </summary> [ST ...

  5. 导出excel(利用工具类导出excel)

    /** * 添加导出功能 * @param creditPageResult * @param request * @param response */ @RequestMapping(value = ...

  6. AAuto如何设置定时器

    在设计视图中(一定要有个Form)点击左下角的功能组件   点击定时器即可切换到代码视图,并添加如下代码.其中我每隔一秒改变一下winform.static2.text的文本值      

  7. bigAutocomplete实现联想

    直接举例说明: //xx联想 var list = $(".js-xxxx").text();//需要联想出的内容的list,该list由后台传入,保存在jsp页面,js取隐藏域值 ...

  8. Node.js 把抓取到的电影节目列表单发或者群发到QQ邮箱

    代码地址如下:http://www.demodashi.com/demo/12381.html 一.前言 上一节我们演示了如何用Node的各种包去抓取电影天堂最新电影列表,接下来我们会讲解如何发送我们 ...

  9. Hbase Basic

    启动:start-hbase.sh 停止:stop-hbase.sh 进入shell:hbase shell 状态:status 创建表:create 'tableName', 'colFam1' 查 ...

  10. swiper-demo1

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...