python – 将report_tensor_allocations_upon_oom添加到cifar10_estimator示例
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python – 将report_tensor_allocations_upon_oom添加到cifar10_estimator示例,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1796字,纯文字阅读大概需要3分钟。
内容图文
![python – 将report_tensor_allocations_upon_oom添加到cifar10_estimator示例](/upload/InfoBanner/zyjiaocheng/774/14277f30211a49089b824ec6afacaa1b.jpg)
我正在运行TensorFlow示例https://github.com/tensorflow/models/tree/master/tutorials/image/cifar10_estimator的修改版本,但我的内存不足.
ResourceExhausted错误说:
提示:如果要在OOM发生时查看已分配的张量列表,请将report_tensor_allocations_upon_oom添加到RunOptions以获取当前分配信息.
我已经尝试在main()中显而易见的位置添加它,但是我得到了protobuf错误的变体,说找不到report_tensor_allocations_upon_oom运行选项.
def main(job_dir, data_dir, num_gpus, variable_strategy,
use_distortion_for_training, log_device_placement, num_intra_threads,
**hparams):
# The env variable is on deprecation path, default is set to off.
os.environ['TF_SYNC_ON_FINISH'] = '0'
os.environ['TF_ENABLE_WINOGRAD_NONFUSED'] = '1'
# Session configuration.
sess_config = tf.ConfigProto(
allow_soft_placement=True,
log_device_placement=log_device_placement,
intra_op_parallelism_threads=num_intra_threads,
report_tensor_allocations_upon_oom = True, # Nope
gpu_options=tf.GPUOptions(
force_gpu_compatible=True,
report_tensor_allocations_upon_oom = True)) # Nope
config = cifar10_utils.RunConfig(
session_config=sess_config, model_dir=job_dir,
report_tensor_allocations_upon_oom = True) #Nope
tf.contrib.learn.learn_runner.run(
get_experiment_fn(data_dir, num_gpus, variable_strategy,
use_distortion_for_training),
run_config=config,
hparams=tf.contrib.training.HParams(
is_chief=config.is_chief,
**hparams))
在此示例中,我在哪里添加report_tensor_allocations_upon_oom = True?
解决方法:
您需要注册一个会话运行挂钩,以将额外的参数传递给estimator所做的session.run()调用.
class OomReportingHook(SessionRunHook):
def before_run(self, run_context):
return SessionRunArgs(fetches=[], # no extra fetches
options=tf.RunOptions(
report_tensor_allocations_upon_oom=True))
将钩子列表中的钩子传递给估算器中的相关方法:
https://www.tensorflow.org/api_docs/python/tf/estimator/Estimator
内容总结
以上是互联网集市为您收集整理的python – 将report_tensor_allocations_upon_oom添加到cifar10_estimator示例全部内容,希望文章能够帮你解决python – 将report_tensor_allocations_upon_oom添加到cifar10_estimator示例所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。