当前位置:网站首页>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() 造成梯度累计
边栏推荐
- Solve the error of changing the selected file when uploading excel file. Net:: err_ UPLOAD_ FILE_ CHANGED
- U++ learning note pile
- 高并发介绍及应对
- Graphic view frame
- 杰理之如何测试按键的误触率【篇】
- Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly
- Notes on key vocabulary of the original English book biography of jobs (IX) [chapter seven]
- NC50965 Largest Rectangle in a Histogram
- 'when to use const char * and when to use const char []' - when to use const char * and when to use const char []
- Jerry's charge unplugged, unable to touch the boot [chapter]
猜你喜欢
![加油站[问题分析->问题转换->贪心]](/img/15/5313f900abedb46ce82d8ab81af1d7.png)
加油站[问题分析->问题转换->贪心]

E-commerce system microservice architecture

Array advanced improvement

`${}`的用法

`Usage of ${}`
![[foreign journal] sleep and weight loss](/img/81/42dcfae19e72a0bc761cb7a40fe5d5.jpg)
[foreign journal] sleep and weight loss

World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection

Oracle PL / SQL programming

Radis:Linux上安装Redis(步骤)

数学建模——图与网络模型及方法(一)
随机推荐
[leetcode] there are duplicate elements [217]
杰理之样机无触摸,拆机之后重新安装变正常【篇】
Baidu AI Cloud - create a face recognition application
stop slave卡住--事务的事件没有复制完整
go 条件变量
Additional: [login information storage] and [login status verification]; (including: summarizing all the contents of [login information storage] and [login status verification] so far;)
[LeetCode] 反转字符串【344】
JS syntax ES6, ES7, es8, es9, ES10, es11, ES12 new features (Abstract)
Performance optimization - rigorous mode
性能优化----严苛模式
Socket socket c/s end process
Golang's learning route
[autosar-dcm] - 4.3-how UDS $22 and $2e services read and write NVM data
Introduction to database system Chapter 1 short answer questions - how was the final exam?
Il n'est pas nécessaire d'appuyer longtemps sur la fonction de démarrage pour modifier Jelly [chapitre]
高并发介绍及应对
boot actuator - prometheus使用
go 4种单例模式
How should programmers write logs
Unity publishes a method of webgl playing sound