如何在Tensorflow 2.0b中检查/释放GPU内存?

巴登

在我的tensorflow2.0b程序中,我确实得到了这样的错误

    ResourceExhaustedError: OOM when allocating tensor with shape[727272703] and type int8 on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc [Op:TopKV2]

成功执行此程序中的许多基于GPU的操作后,将发生此错误。

我喜欢释放与这些过去操作相关的所有GPU内存,以避免上述错误。我如何在tensorflow-2.0b中做到这一点?如何在程序中检查内存使用情况?

我只能使用tf.session()查找相关信息,在tensorflow2.0中不再可用

法比恩

您可能对将此Python 3绑定用于NVIDIA Management Library感兴趣

我会尝试这样的事情:

import nvidia_smi

nvidia_smi.nvmlInit()

handle = nvidia_smi.nvmlDeviceGetHandleByIndex(0)
# card id 0 hardcoded here, there is also a call to get all available card ids, so we could iterate

info = nvidia_smi.nvmlDeviceGetMemoryInfo(handle)

print("Total memory:", info.total)
print("Free memory:", info.free)
print("Used memory:", info.used)

nvidia_smi.nvmlShutdown()

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何检查Python中是否同时释放2个键?

如何在TensorFlow 2中写入TensorBoard

如何在Tensorflow中更新2D张量的子集?

如何在Tensorflow中计算R ^ 2

如何在TensorFlow的conv2d中跨越多个通道?

如何在Tensorflow中使用Doc2Vec中的向量

如何在Tensorflow中制作2D高斯滤波器?

如何在C ++中为2d数组正确地释放内存?

如何在Conv2D层Tensorflow中获得步幅值?

如何在Tensorflow渴望的conv2D中包括内核约束?

如何在XGBoost中释放GPU上的所有内存?

如何在Tensorflow 2中将GradientTape与AutoGraph一起使用?

如何在TensorFlow 2中获得Keras张量的值?

如何在tensorflow2.0中导入'tf.contrib.seq2seq.dynamic_decoder'?

如何在TensorFlow 2 Eager中获得learning_phase?

如何在具有tensorflow2和keras的多GPU上训练模型?

如何在预训练的TensorFlow 2模型中访问和可视化权重?

如何在Jupyter中将TensorFlow 2模型的结果保存到文本文件中?

如何在Tensorflow 2中解码示例(从1.12版本移植)

我如何在Tensorflow 2 LSTM培训中屏蔽多输出?

对于tensorflow 2.x,如何在CPU和GPU版本之间切换?

如何在Tensorflow 2中实现小批量梯度下降?

如何在Tensorflow Object Detection API v2中同时训练和评估

如何在Tensorflow 2.x中打印准确性和其他指标?

如何从 keras 模型中释放 GPU 内存?

你如何在 TensorFlow v2 中传递会话对象?

如何在 TensorFlow 2.n 中启用设备放置日志记录 (log_device_placement)

如何在 Tensorflow 2 中测量右填充张量的(内容)长度?

如何在 TensorFlow2 中写出这个方程?(4x+2 = 0)