为什么 tensorflow 比模型文件占用更多的 GPU RAM? [英] Why does tensorflow take more GPU RAM than the model file?

查看:33
本文介绍了为什么 tensorflow 比模型文件占用更多的 GPU RAM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 tensorflow 模型作为协议缓冲区格式保存为 model.pb,它是 184 MB.当我使用会话加载它时,我看到该进程占用了 11 GB GPU RAM.这是为什么?

I have a tensorflow model saved as a protocol buffer format as model.pb which is 184 MB. When I load it using a session, I see that the process hogs 11 GB of GPU RAM. Why is that?

推荐答案

Tensorflow 默认使用所有 GPU 内存,以尽量减少内存碎片(请参阅 文档).您可以使用 allow_growth 配置选项来防止这种行为:

Tensorflow uses all the GPU memory by default to minimize memory fragmentation (see the documentation). You can prevent this behavior by using the allow_growth config option:

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

这篇关于为什么 tensorflow 比模型文件占用更多的 GPU RAM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆