By default, TensorFlow maps nearly all of the GPU memory of all GPUs (subject to CUDA_VISIBLE_DEVICES) visible to the process. This is done to more efficiently use the relatively precious GPU memory resources on the devices by reducing memory fragmentation.

In some cases it is desirable for the process to only allocate a subset of the available memory, or to only grow the memory usage as is needed by the process. TensorFlow provides two Config options on the Session to control this.

The first is the allow_growth option, which attempts to allocate only as much GPU memory based on runtime allocations: it starts out allocating very little memory, and as Sessions get run and more GPU memory is needed, we extend the GPU memory region needed by the TensorFlow process. Note that we do not release memory, since that can lead to even worse memory fragmentation. To turn this option on, set the option in the ConfigProto by:

 
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config, ...)

The second method is the per_process_gpu_memory_fraction option, which determines the fraction of the overall amount of memory that each visible GPU should be allocated. For example, you can tell TensorFlow to only allocate 40% of the total memory of each GPU by:

 
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.4
session = tf.Session(config=config, ...)

This is useful if you want to truly bound the amount of GPU memory available to the TensorFlow process.

最新文章

  1. eclipse 导入新项目后报错:Cannot change version of project facet Dynamic web module to 2.5
  2. Dmaven.multiModuleProjectDirectory system propery is not set.
  3. Centos 6.4 32位 gcc 升级(已验证)
  4. 在滚动列表中实现视频的播放(ListView & RecyclerView)
  5. Linux C编程--格式化I/O
  6. head 头标签(转发)
  7. TalkingData游戏版本在Cocos2d-x 3.2使用
  8. 转: RequireJS Optimizer 的使用和配置方法
  9. ML技术 - 特征选择
  10. 在用python操作mysql时报错:ModuleNotFoundError: No module named 'MySQLdb'
  11. jQuery的属性,事件及操作
  12. ioremap_nocache() 函数的使用【转】
  13. python虚拟环境迁移
  14. python文件(概念、基本操作、常用操作、文本文件的编码方式)
  15. Spring session(redis存储方式)监听导致创建大量redisMessageListenerContailner-X线程
  16. Linux下Shell元字符的释义
  17. hash专题学习笔记QAQ
  18. 去除 DBGridEh SelectedRows里无效的书签
  19. 使用 OpCache 提升 PHP 5.5+ 程序性能
  20. 归并排序Merge sort2

热门文章

  1. 关于 build tools
  2. Redis 主从复制, 读写分离
  3. C# 把byte[]输出为图片文件
  4. leetcode1017
  5. [转]让linux的coredump文件
  6. 最详细安装Esxi
  7. 深度学习原理与框架-神经网络结构与原理 1.得分函数 2.SVM损失函数 3.正则化惩罚项 4.softmax交叉熵损失函数 5. 最优化问题(前向传播) 6.batch_size(批量更新权重参数) 7.反向传播
  8. c# group by list
  9. day02-数据库操作
  10. cookie操作:设置cookie、读取cookie、删除cookie