当前位置:网站首页>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() 造成梯度累计
边栏推荐
- Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly
- Methods of adding styles to native JS
- 存储单位换算
- Go four singleton modes
- `Usage of ${}`
- Film and television excerpts
- Graphic view frame
- P7072 [CSP-J2020] 直播获奖
- 【板栗糖GIS】arcscene—如何做出有高度的高程图
- Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
猜你喜欢
![[羊城杯2020]easyphp](/img/12/da28f738e50e625b0a66a94af3703d.png)
[羊城杯2020]easyphp

Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed

Dahua cloud native load balancing article - the passenger flow of small restaurants has increased

Leetcode circular linked list (fast and slow pointer) code line by line interpretation

从2022年Q1财报看携程的韧性和远景

P1007 独木桥

Qt QScrollArea

Qt QSplitter拆分器

百度智能云-创建人脸识别应用

悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖
随机推荐
[LeetCode] 反转字符串中的单词 III【557】
【板栗糖GIS】arcmap—如何批量修改注记要素的字体,颜色,大小等
[ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)
世界环境日 | 周大福用心服务推动减碳环保
【板栗糖GIS】arcscene—如何做出有高度的高程图
Oracle-PL/SQL编程
数组进阶提高
大一学习分享
Jielizhi, production line assembly link [chapter]
Jatpack------LiveData
U++ learning notes - relaxation
【硬件】标准阻值的由来
Array advanced improvement
钟薛高回应产品1小时不化:含固体成分 融化不能变成水
杰理之直接触摸样机的顶针反应不正常【篇】
[LeetCode] 多数元素【169】
对象与对象变量
Introduction to database system Chapter 1 short answer questions - how was the final exam?
Qt QScrollArea
To myself who is about to work