当前位置:网站首页>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() 造成梯度累计
边栏推荐
- wait解决僵尸进程
- U++ learning notes - relaxation
- Local dealers play the community group purchase mode and share millions of operations
- Golang的学习路线
- Dahua cloud native load balancing article - the passenger flow of small restaurants has increased
- 杰理之、产线装配环节【篇】
- UE4 UI adaptive screen
- [leetcode] most elements [169]
- 'when to use const char * and when to use const char []' - when to use const char * and when to use const char []
- 【板栗糖GIS】global mapper 如何通过dsm批量制作贴地等高线
猜你喜欢

从2022年Q1财报看携程的韧性和远景
![P7072 [CSP-J2020] 直播获奖](/img/bc/fcbc2b1b9595a3bd31d8577aba9b8b.png)
P7072 [CSP-J2020] 直播获奖
![Jielizhi, production line assembly link [chapter]](/img/0d/102596ad13aafd9c6133509d9064dd.png)
Jielizhi, production line assembly link [chapter]

SimpleITK使用——4. 奇怪的問題

【板栗糖GIS】global mapper 如何通过dsm批量制作贴地等高线

Struct, bit segment, enumeration, union

Array advanced improvement

数据分析学习记录--用EXCEL完成简单的单因素方差分析

NC50965 Largest Rectangle in a Histogram

中国信通院、清华大学、腾讯安全,云原生安全产学研用强强联合!
随机推荐
分享 10 个 JS 闭包面试题(图解),进来看看你能答对多少
boot actuator - prometheus使用
wait解决僵尸进程
性能优化----严苛模式
Zhong Xuegao responded that the product will not melt for 1 hour: it contains solid components and cannot melt into water
kubernetes 使用主机名将 pod 分配在指定节点上
首批 | 腾讯云完成国内首个云原生安全成熟度评估
图形视图框架
What is the'function'keyword used in some bash scripts- What is the 'function' keyword used in some bash scripts?
[羊城杯2020]easyphp
The threshold value of fusing proportion cannot be changed with sentinel, and setting the slow call proportion has no effect
SimpleITK使用——4. 奇怪的問題
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖
[leetcode] number of palindromes [9]
Unity publishes a method of webgl playing sound
数学建模——图与网络模型及方法(一)
杰理之充电拔出,无法触摸开机【篇】
Simpleitk use - 3 Common operations
Notes on key vocabulary in the English original of the biography of jobs (10) [chapter eight]