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()
相关推荐
工程师老罗1 分钟前
目标检测数据标注的工具与使用方法
人工智能·目标检测·计算机视觉
yuankoudaodaokou1 分钟前
高校科研新利器:思看科技三维扫描仪助力精密研究
人工智能·python·科技
Acrelhuang7 分钟前
工商业用电成本高?安科瑞液冷储能一体机一站式解供能难题-安科瑞黄安南
大数据·开发语言·人工智能·物联网·安全
小王毕业啦7 分钟前
2010-2024年 非常规高技能劳动力(+文献)
大数据·人工智能·数据挖掘·数据分析·数据统计·社科数据·经管数据
言無咎19 分钟前
从规则引擎到任务规划:AI Agent 重构跨境财税复杂账务处理体系
大数据·人工智能·python·重构
张小凡vip24 分钟前
数据挖掘(十)---python操作Spark常用命令
python·数据挖掘·spark
weixin_3954489125 分钟前
排查流程啊啊啊
人工智能·深度学习·机器学习
U盘失踪了31 分钟前
Reqable 导出响应数据
python
2301_7903009635 分钟前
数据分析与科学计算
jvm·数据库·python
Acrelhuang37 分钟前
独立监测 + 集团管控 安科瑞连锁餐饮能源方案全链路提效-安科瑞黄安南
人工智能