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()
相关推荐
站大爷IP5 分钟前
Python中None与NoneType的真相:从单例对象到类型系统的深度解析
python
秋难降6 分钟前
LRU缓存算法(最近最少使用算法)——工业界缓存淘汰策略的 “默认选择”
数据结构·python·算法
站大爷IP17 分钟前
Python新手踩坑实录:这些错误你可能正在犯
python
ezl1fe17 分钟前
RAG 每日一技(十八):手写SQL-RAG太累?LangChain的SQL智能体(Agent)前来救驾!
数据库·人工智能·后端
我星期八休息22 分钟前
大模型 + 垂直场景:搜索/推荐/营销/客服领域开发新范式与技术实践
大数据·人工智能·python
飞哥数智坊27 分钟前
等了这么久,企业微信的AI终于来了!
人工智能
Christo328 分钟前
SIGKDD-2023《Complementary Classifier Induced Partial Label Learning》
人工智能·深度学习·机器学习
深盾安全31 分钟前
uv,下一代Python包管理工具
python
AIGC安琪40 分钟前
Transformer中的编码器和解码器是什么?
人工智能·深度学习·ai·语言模型·大模型·transformer·ai大模型
算家计算1 小时前
3秒搞定产品换装换背景!【ComfyUI-万物迁移工作流】本地部署教程:基于FLUX.1 Kontext上下文感知图像编辑
人工智能