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 小时前
深入剖析大模型在文本生成式 AI 产品架构中的核心地位
人工智能·架构
想要成为计算机高手2 小时前
11. isaacsim4.2教程-Transform 树与Odometry
人工智能·机器人·自动驾驶·ros·rviz·isaac sim·仿真环境
mortimer2 小时前
安装NVIDIA Parakeet时,我遇到的两个Pip“小插曲”
python·github
@昵称不存在3 小时前
Flask input 和datalist结合
后端·python·flask
静心问道3 小时前
InstructBLIP:通过指令微调迈向通用视觉-语言模型
人工智能·多模态·ai技术应用
宇称不守恒4.03 小时前
2025暑期—06神经网络-常见网络2
网络·人工智能·神经网络
赵英英俊3 小时前
Python day25
python
东林牧之3 小时前
Django+celery异步:拿来即用,可移植性高
后端·python·django
何双新4 小时前
基于Tornado的WebSocket实时聊天系统:从零到一构建与解析
python·websocket·tornado
小楓12014 小时前
醫護行業在未來會被AI淘汰嗎?
人工智能·醫療·護理·職業