tensorflow 内存错误

使用tensorflow训练多个模型时,训练过程中容易出现内存错误,在这里记录一下解决办法。希望能帮到各位。

2025-01-02 22:31:03.489713: W tensorflow/core/common_runtime/bfc_allocator.cc:275] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.41GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.

把下述代码贴到训练完成后

python 复制代码
import tensorflow.keras.backend as K
import gc
import tensorflow as tf

#训练完成后
CNN2_Unet = None
tf.compat.v1.reset_default_graph() 
K.clear_session()
gc.collect()
相关推荐
小弥儿3 分钟前
GitHub今日热榜 | 2026-10-12:pytorch 上升四位
人工智能·pytorch·学习·开源·github
sunneo4 分钟前
Google开源端侧推理引擎ML Drift
人工智能
前端 贾公子9 分钟前
LangGraph == 图的状态(State)管理 (中)
开发语言·数据库·python
m0_5873830011 分钟前
无人自助拼豆系统落地开发实战指南 核心逻辑实现与部署经验分享
前端·javascript·vue.js·人工智能·经验分享·需求分析
troy12813 分钟前
深度解析:如何用好 AI,成为自身能力的放大器
人工智能
ACP广源盛1392462567314 分钟前
硬件选型笔记|国产 PCIe4.0 交换芯片 IX8012@ACP,边缘 AI 设备 IO 扩展方案探讨
人工智能·笔记·硬件架构·pcie·国产芯片
想会飞的蒲公英17 分钟前
Jev 模型详解:不生成文字的决策模型,接口、置信度与评测边界
人工智能·jev
虾..22 分钟前
计算机图形学:理解光照模型
人工智能
武子康24 分钟前
H3-World 的动作控制,为什么不能只靠一句提示词?
人工智能·agent
一木 之林25 分钟前
LangChain 第3章 消息与提示词模板:四类消息、历史管理与 ChatPromptTemplate
人工智能·计算机视觉·langchain