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 小时前
Skill 为什么不同于 Tool?Agent 技能库的自演进与动态加载机制
人工智能·agent·ai编程
IvanCodes4 小时前
Python 数据处理(十三):JSON、CSV 与数据序列化
开发语言·python
大模型任我行4 小时前
谷歌:“课程学习”融入扩散模型强化学习
人工智能·语言模型·自然语言处理·论文笔记
AIGCmagic社区4 小时前
具身智能专题:机器人也有Scaling Law?智元GE-Act 2.0用3万小时真机数据给出答案
人工智能·aigc·具身智能
Patrick在香港5 小时前
Claude 工具调用返回空:8 次失败里只有 1 次状态码不对,其余全带 200
爬虫·python·api·claude·香港
Web3&Basketball5 小时前
CRM Agent 后训练实战:3 倍更少错误
python·架构·大模型·agent·推理
Rosanci5 小时前
谷歌浏览器插件开发实战指南:从 Hello World 到上架发布
大数据·人工智能·chrome·程序人生
明月_清风5 小时前
AI 越来越强,程序员真正的价值到底是什么?
人工智能·后端
m0_466525296 小时前
云从科技上线云起ModelHub:AI团队时代的模型算力基础设施
大数据·人工智能·科技
火山引擎开发者社区6 小时前
OpenViking:给 Codex 加上长期记忆
人工智能