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图像的信息,参见容器。

最新文章

  1. struts 标签的使用<转>
  2. win10无法使用内置管理员账户打开应用怎么办
  3. 故障排查:是什么 导致了服务器端口telnet失败?
  4. python traceback 变量值
  5. 动态生成Table内文字换行。
  6. 【LeetCode 235】Lowest Common Ancestor of a Binary Search Tree
  7. 实例讲解Nginx下的rewrite规则
  8. PHP+Ajax 异步通讯注册验证
  9. Node.js(window)基础(1)——用cmd命令行访问某一文件夹下的js文件
  10. Struts2框架具体解释
  11. High Performance Browser Networking - TCP UDP TLS
  12. SQL Server 2005中设置Reporting Services发布web报表的匿名访问
  13. HDU 4256 The Famous Clock
  14. request.RequestContextListener
  15. 查看Samba用户的方法
  16. Spring Cloud 之 Ribbon
  17. TMS320F28335系列芯片地址映射表
  18. scanf函数(初学者)
  19. Java NIO系列教程(二) Channel通道介绍及FileChannel详解
  20. 在 Mac 上使用多点触控手势

热门文章

  1. 【秒懂音视频开发】21_显示BMP图片
  2. 1.4.18- HTML之特殊字符标签
  3. 04- HTML常用标签
  4. jQuery+AJAX实现纯js分页功能
  5. 【Scrapy(一)】 Scrapy爬虫的基础执行流程
  6. SPOJ 2713 线段树(sqrt)
  7. spring.framework 版本从4.1.6.RELEASE升到5.0.20.RELEASE
  8. Python | Pandas数据清洗与画图
  9. FHE-Toolkit 安装
  10. istio部署问题Q&A