TensorFlow用法

什么是TensorFlow

TensorFlow是一个开源软件库,用于使用数据流图进行数值计算。图中的节点表示数学运算,而图的边缘表示流动的多维数据数组(张量)。这种灵活的体系结构可以将计算部署到台式机,服务器或移动设备中的一个或多个CPU或GPU上,而无需重写代码。

TensorFlow最初由Google机器智能研究组织内Google Brain团队的研究人员和工程师开发,目的是进行机器学习和深度神经网络研究。该系统足够通用,也可以应用于其他各种领域。

运行TensorFlow

在运行NGC深度学习框架容器之前, Docker环境必须支持NVIDIA GPU。要运行容器,请按照《NVIDIA容器和框架用户指南》中的“运行容器”中的说明发出相应的命令,并指定注册表,存储库和标签。有关使用NGC的更多信息,请参阅《NGC容器用户指南》

系统中实现的方法取决于所安装的DGX OS版本(对于DGX系统),由云服务提供商提供的特定NGC云映像,或为准备在TITAN PC,Quadro PC或vGPU上运行NGC容器而准备的软件。

过程Procedure

  1. 选择“标签选项卡,找到要运行的容器映像版本。
  2. 在“拉标签列中,单击图标以复制docker pull命令。
  3. 打开命令提示符并粘贴pull命令。开始提取容器图像。在继续下一步之前,确保拉取成功完成。
  4. 运行容器映像。

如果具有Docker 19.03或更高版本,则启动容器的典型命令是:

docker run --gpus all -it --rm -v local_dir:container_dir nvcr.io/nvidia/tensorflow:xx.xx-tfx-py3

如果具有Docker 19.02或更早版本,启动容器的典型命令是:

nvidia-docker run -it --rm -v local_dir:container_dir nvcr.io/nvidia/tensorflow:xx.xx-tfx-py3

其中:

- `-it` means run in interactive mode
- `--rm` will delete the container when finished
- `-v` is the mounting directory
- `local_dir` is the directory or file from your host system (absolute path) that you want to access from inside your container.  For example, the `local_dir` in the following path is `/home/jsmith/data/mnist`.  
 
   ```
   -v /home/jsmith/data/mnist:/data/mnist
   ```
 
   If you are inside the container, for example, `ls /data/mnist`, you will see the same files as if you issued the `ls /home/jsmith/data/mnist` command from outside the container.
 
- `container_dir` is the target directory when you are inside your container.  For example, `/data/mnist` is the target directory in the example:
 
   ```
   -v /home/jsmith/data/mnist:/data/mnist
   ```
 
- `xx.xx` is the container version. For example, `20.01`.
- `tfx` is the version of TensorFlow. For example, `tf1` or `tf2`.

通过将TensorFlow导入为Python模块来运行:

$ python
>>> import tensorflow as tf
>>> print(tf.__version__)
1.15.0

You might want to pull in data and model descriptions from locations outside the container for use by TensorFlow. To accomplish this, the easiest method is to mount one or more host directories as Docker data volumes. You have pulled the latest files and run the container image.

Note: In order to share data between ranks, NCCL may require shared system memory for IPC and pinned (page-locked) system memory resources.

可能要从容器外部的位置提取数据和模型描述,供TensorFlow使用。为此,最简单的方法是将一个或多个主机目录挂载为Docker数据卷。提取最新文件并运行容器映像。

注意:为了在ranks之间共享数据,NCCL可能需要IPC和固定(页面锁定)系统内存资源的共享系统内存。

The operating system’s limits on these resources may need to be increased accordingly. Refer to your system’s documentation for details. 
In particular, Docker containers default to limited shared and pinned memory resources. When using NCCL inside a container, it is recommended 
that you increase these resources by issuing:
 
```    
--shm-size=1g --ulimit memlock=-1
```
 
in the command line to:
```
docker run --gpus all

有关/workspace/README.md自定义TensorFlow图像的信息,参见容器。

TensorFlow用法的更多相关文章

  1. tensorflow用法记录

    使用 embedding 变量 import tensorflow as tf import numpy as np sess = tf.InteractiveSession() M = list(' ...

  2. tensorflow例子-【老鱼学tensorflow】

    本节主要用一个例子来讲述一下基本的tensorflow用法. 在这个例子中,我们首先伪造一些线性数据点,其实这些数据中本身就隐藏了一些规律,但我们假装不知道是什么规律,然后想通过神经网络来揭示这个规律 ...

  3. TensorFlow tf.app&tf.app.flags用法介绍

    TensorFlow tf.app&tf.app.flags用法介绍 TensorFlow tf.app argparse  tf.app.flags 下面介绍 tf.app.flags.FL ...

  4. 查询tensorflow中的函数用法

    一下均在ubuntu环境下: (1)方法一,使用help()函数: 比如对于tf.placeholder(),在命令行中输入import tensorflow as tf , help(tf.plac ...

  5. tensorflow中batch normalization的用法

    网上找了下tensorflow中使用batch normalization的博客,发现写的都不是很好,在此总结下: 1.原理 公式如下: y=γ(x-μ)/σ+β 其中x是输入,y是输出,μ是均值,σ ...

  6. 第一节,TensorFlow基本用法

    一 TensorFlow安装 TensorFlow是谷歌基于DistBelief进行研发的第二代人工智能学习系统,其命名来源于本身的运行原理.Tsnsor(张量)意味着N维数组,Flow(流)意味着基 ...

  7. 【TensorFlow】tf.nn.softmax_cross_entropy_with_logits的用法

    在计算loss的时候,最常见的一句话就是 tf.nn.softmax_cross_entropy_with_logits ,那么它到底是怎么做的呢? 首先明确一点,loss是代价值,也就是我们要最小化 ...

  8. tensorFlow 三种启动图的用法

    tf.Session(),tf.InteractivesSession(),tf.train.Supervisor().managed_session()  用法的区别: tf.Session() 构 ...

  9. 【TensorFlow】tf.nn.embedding_lookup函数的用法

    tf.nn.embedding_lookup函数的用法主要是选取一个张量里面索引对应的元素.tf.nn.embedding_lookup(tensor, id):tensor就是输入张量,id就是张量 ...

随机推荐

  1. 12- APP接口测试以及接口文档的分析

    什么是接口? 为什么要做接口测试? 接口测试流程 需求评审 需求分析 接口用例设计 执行测试用例 bug的定位于追踪 接口文档分析 接口文档分析:开发 内容: 1.接口名称 2.接口地址 3.支持方式 ...

  2. hdu4585 STL水题

    题意:       成立少林寺,刚开始有一个大师,id是1,攻击力是10E,现在陆续来人,每个人有自己的id,和自己的攻击力,但是每一个新来的要和之前的和尚pk,他必须选择和他攻击力差值最小的那个,如 ...

  3. 【aws-系统】简单的SNS到电报通知机器人

    动机 我已经使用此设置几个月了,这是我的用例: 预定的提醒.我有一些安排好的CloudWatch Events,以提醒我有关各种日常活动以及我从文章和书籍中保存的想法数据库中的随机推销的信息. 应用程 ...

  4. PAT 乙级 -- 1003 -- 我要通过!

    题目简述 "答案正确"是自动判题系统给出的最令人欢喜的回复.本题属于PAT的"答案正确"大派送 -- 只要读入的字符串满足下列条件,系统就输出"答案正 ...

  5. 深入浅出带你玩转sqlilabs(二)

    MYSQL高权限注入 mysql跨库注入 详情请看上一篇:深入浅出带你玩转sqlilabs(一) mysql文件操作注入-sqlilabs less7 可能用到的函数: into outfile()函 ...

  6. Swift系列五 - 可选项

    可选项,一般也叫可选类型,它允许将值设为nil. 一.定义可选项 平时开发中,如果我们需要把一个变量置空时只需要把变量赋值一个nil即可: 上面尝试后不行,那怎么把一个变量置空呢? 答案:把变量设置可 ...

  7. 【JavaScript】Leetcode每日一题-矩形区域不超过K的最大值和

    [JavaScript]Leetcode每日一题-矩形区域不超过K的最大值和 [题目描述] 给你一个 m x n 的矩阵 matrix 和一个整数 k ,找出并返回矩阵内部矩形区域的不超过 k 的最大 ...

  8. Docker+Nginx配置SSL

    参考阿里云文档教程 前提条件 购买服务器的服务商开启443端口和服务器已开启443端口(https的默认端口) nginx容器已经安装http_ssl_module模块(启用SSL功能) 下面的教程基 ...

  9. Pycharm集成码云,图文手把手教学!

    Pycharm集成码云 码云(http://gitee.com)是开源中国推出的代码托管平台,支持 Git 和 SVN,提供免费的私有仓库托管 可以通过码云保管你的代码,每次修改完代码提交,就是一个版 ...

  10. Linux(深度)系统安装富士施乐(网络)打印机

    一般来讲,linux系统识别打印机没有问题,重点难点在于后面设置.此文特别感谢:河北石龙的陈一繁销售代表.P288dw施乐官网并未提供Linux的驱动并在安装过程中遇到很多问题,其不厌其烦的为我联系厂 ...