当前位置:网站首页>pytorch训练CPU占用持续增长(bug)
pytorch训练CPU占用持续增长(bug)
2022-07-02 22:09:00 【zyr_freedom】
CPU内存训练时持续增加,攀升,使用gc.collect()无效
1.使用
@profile 可以查看cpu占用情况
2.排查错误
python 内容与 tensor内容是否有直接互换的位置重点检查,累加的地方重点检查,这里会带来内存泄漏问题
例子
比如 acc += list(correctness) 等号左边是python原生list,correctness是torch.FloatTensor
换成acc += list(np.array(correctness.cpu()))
原因:list与tensor互转会发生内存泄漏问题,如果需要转换,应该将tensor从cuda-->cpu-->numpy.array
例子
total_loss +=loss1------->total_loss +=loss1.item() (.item()就是获取一个元素张量里面的元素值)
推理时忘记torch.no_grad() 造成梯度累计
边栏推荐
- Additional: [login information storage] and [login status verification]; (including: summarizing all the contents of [login information storage] and [login status verification] so far;)
- 【洛谷P1541】乌龟棋【DP】
- 杰理之内置关机电流 1.2uA,之后不能长按开机【篇】
- Niuke: Dragon and dungeon games
- 佩服,竟然有人把高等数学这么晦涩难懂的科目,讲解得如此通俗易懂
- 钟薛高回应产品1小时不化:含固体成分 融化不能变成水
- Qt QScrollArea
- P1007 独木桥
- Kubernetes uses the host name to allocate the pod on the specified node
- Methods of adding styles to native JS
猜你喜欢
电商系统微服务架构
数学建模——图与网络模型及方法(一)
`${}`的用法
Performance optimization - rigorous mode
Jatpack------LiveData
Analyse des données dossiers d'apprentissage - - analyse simple de la variance à facteur unique avec Excel
P7072 [CSP-J2020] 直播获奖
Qt QProgressBar详解
Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises
分享 10 个 JS 闭包面试题(图解),进来看看你能答对多少
随机推荐
数据分析学习记录(二)---响应曲面法及Design-Expert的简单使用
【板栗糖GIS】global mapper 如何通过dsm批量制作贴地等高线
送给即将工作的自己
Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises
Simpleitk use - 4 Strange question
UE4 UI adaptive screen
What is the'function'keyword used in some bash scripts- What is the 'function' keyword used in some bash scripts?
杰理之样机无触摸,拆机之后重新安装变正常【篇】
Baidu AI Cloud - create a face recognition application
牛客网:龙与地下城游戏
Local dealers play the community group purchase mode and share millions of operations
数学建模——图与网络模型及方法(一)
Il n'est pas nécessaire d'appuyer longtemps sur la fonction de démarrage pour modifier Jelly [chapitre]
Film and television excerpts
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
`Usage of ${}`
[leetcode] there are duplicate elements [217]
Server response status code
Additional: [login information storage] and [login status verification]; (including: summarizing all the contents of [login information storage] and [login status verification] so far;)
go 条件变量