TensorFlow Action(开山使用篇)
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(开山使用篇)的更多相关文章
- [翻译] TensorFlow 分布式之论文篇 "TensorFlow : Large-Scale Machine Learning on Heterogeneous Distributed Systems"
[翻译] TensorFlow 分布式之论文篇 "TensorFlow : Large-Scale Machine Learning on Heterogeneous Distributed ...
- [翻译] TensorFlow 分布式之论文篇 "Implementation of Control Flow in TensorFlow"
[翻译] TensorFlow 分布式之论文篇 "Implementation of Control Flow in TensorFlow" 目录 [翻译] TensorFlow ...
- salesforce lightning零基础学习(十) Aura Js 浅谈三: $A、Action、Util篇
前两篇分别介绍了Component类以及Event类,此篇将会说一下 $A , Action以及 Util. 一. Action Action类通常用于和apex后台交互,设置参数,调用后台以及对结 ...
- [Android Pro] AndroidStudio IDE界面插件开发(进阶篇之Action机制)
转载请注明出处:[huachao1001的专栏:http://blog.csdn.net/huachao1001/article/details/53883500] 从上一篇<AndroidSt ...
- [源码解析] TensorFlow 分布式 DistributedStrategy 之基础篇
[源码解析] TensorFlow 分布式 DistributedStrategy 之基础篇 目录 [源码解析] TensorFlow 分布式 DistributedStrategy 之基础篇 1. ...
- Struts2第二篇【开发步骤、执行流程、struts.xml讲解、defalut-struts讲解】
前言 我们现在学习的是Struts2,其实Struts1和Struts2在技术上是没有很大的关联的.Struts2其实基于Web Work框架的,只不过它的推广没有Struts1好,因此就拿着Stru ...
- Struts2入门这一篇就够了
前言 这是Strtus的开山篇,主要是引入struts框架...为什么要引入struts,引入struts的好处是什么,以及对Struts2一个简单的入门.... 为什么要引入struts? 既然Se ...
- 双显卡笔记本安装CUDA+theano、tensorflow环境
原文出处:http://www.cnblogs.com/jacklu/p/6377820.html 个人知乎主页欢迎关注:https://www.zhihu.com/people/jack_lu,相信 ...
- 统计学习方法:罗杰斯特回归及Tensorflow入门
作者:桂. 时间:2017-04-21 21:11:23 链接:http://www.cnblogs.com/xingshansi/p/6743780.html 前言 看到最近大家都在用Tensor ...
随机推荐
- MFC MFC对话框滚动条的使用
对话框的(上下/左右)滚动事件,比如,把一个比较大的对话框放入tab控件的某一页时,就需要添加滚动条.在使用了java和qt等图形界面化的集成开发环境之后,再使用MFC,就会发现,想要让一个对话框 ...
- C++PE文件格式解析类(轻松制作自己的PE文件解析器)
PE是Portable Executable File Format(可移植的运行体)简写,它是眼下Windows平台上的主流可运行文件格式. PE文件里包括的内容非常多,详细我就不在这解释了,有兴趣 ...
- 谈论程序中的token
-> //指针,一旦符号分开就会成以下两个意思,我们一定要注意符号 - //减号 > //大与 int a,big; if(x>big) big = x; C语言以及一些其它语言会自 ...
- centos 安装 htop
centos-install-htop http://elearning.wsldp.com/pcmagazine/centos-install-htop/
- Archlinux休眠设置
2017-03-11 更新: 优化部分文字描述; 默认情况下禁用 swap 分区, 当执行休眠操作时先启用 swap 分区, 然后再执行休眠操作(给 /usr/bin/{swapon,swapoff} ...
- C#遍历指定路径下的目录
通过指定路径訪问路径下的文件.在C#的开发中主要利用了Directory类和DirectoryInfo类,简要介绍Directory类中的成员:命名空间 System.IO 命名空间 1.Create ...
- ie 浏览器无法保存cookie,且与域名包括了下划线(_)有关系的问题
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255) ...
- sql字符串处理
sql字符串截取 substring(ParamName,start,length) start开始位置,length结束位置 DECLARE @Tel NVARCHAR(20) SET @Tel=' ...
- C# 中三个关键字params,Ref,out
一. using System; using System.Collection.Generic; using System.Text; namespace ParamsRefOut { class ...
- 安装gi的时候回退root.sh的运行
</pre><pre name="code" class="html">/u01/app/11.2.0/grid/crs/install ...