Pytorch 1.0.1 might cause memory leak issue

在训练ResNet模型时,使用PyTorch 1.0.1版本导致内存泄漏问题,通过降级到1.0.0版本解决。在中国环境下,安装特定版本的PyTorch遇到困难,最终通过conda安装并指定清华源成功安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Recently when training a resnet model I found that using Pytorch 1.0.1 can cause memory leak, that is memory use keeps increasing while the training is running. Not sure which part of the code is the reason behind it, but downgrade pytorch from 1.0.1 to 1.0.0 solved this issue.

Problems encountered when trying to change the version of Pytorch

First I was using pytorch 0.4.1, which causes another problem which is somehow similar to this one. Basically it is about the arguments put into a tensor (like) cannot be a tuple for 0.4.1 but can for 0.5.

So in order to upgrade from 0.4.1 to 1.0., I tried to follow the official installation guide, according to that just select corresponding options and run the command given, I should be able to install a 1.0. successfully. But I didn’t. The reason, I guess, is that I am in China. So at this stage, I used Pycharm to upgrade it instead. Just enter the project interpreter in Settings, find pytorch in packages and upgrade with ticking the “Specify version” option. By doing this, my pytorch version became 1.0.1.

Then the memory leak issue appears. To downgrade from 1.0.1 to 1.0.0, I first tried to install from the official previous versions website. But again, because I am in China, the connection is extremely unstable and ReadTimeout error occur frequently.

The solution is instead of pip install, I use conda install and tsinghua source. After adding channel just run conda install pytorch=1.0.0 cudaxxx -c pytorch, replace cudaxxx with your cuda version, and pytorch 1.0.0 can then be installed successfully.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值