Pytorch释放显存占用方式
2020-02-13 11:33
4912 查看
如果在python内调用pytorch有可能显存和GPU占用不会被自动释放,此时需要加入如下代码
torch.cuda.empty_cache()
我们来看一下官方文档的说明
Releases all unoccupied cached memory currently held by the caching allocator so that those can be used in other GPU application and visible in nvidia-smi.
Note
empty_cache() doesn't increase the amount of GPU memory available for PyTorch. See Memory management for more details about GPU memory management.
此外还可以使用
memory_allocated()和max_memory_allocated()
观察显存占用,并使用
memory_cached()和 max_memory_cached()
观察由缓存分配器管理的内存。
以上这篇Pytorch释放显存占用方式就是小编分享给大家的全部内容了,希望能给大家一个参考
您可能感兴趣的文章:
相关文章推荐
- 关于使用PyTorch设置多线程(threads)进行数据读取而导致GPU显存始终不释放的问题
- Pytorch GPU显存充足却显示out of memory的解决方式
- PyTorch使用cpu加载模型运算方式
- Pytorch Tensor 输出为txt和mat格式方式
- 基于pytorch框架使用多gpu训练时,如何有效降低显存
- Pytorch DataLoader 变长数据处理方式
- 使用pytorch完成kaggle猫狗图像识别方式
- Pytorch使用MNIST数据集实现CGAN和生成指定的数字方式
- 如何处理Pytorch使用GPU后仍有GPU资源未释放的情况
- pytorch GAN伪造手写体mnist数据集方式
- pytorch 实现cross entropy损失函数计算方式
- pytorch自定义二值化网络层方式
- 踩坑笔记之Pytorch利器:Pycharm(安装Pycharm破解以及创建快捷方式)
- Qt判断摄像头是否被占用的一种方式
- pytorch 5 classification 分类
- Linux查看端口占用情况,并强制释放…
- [ZT]释放SQL Server占用的内存
- pytorch 实现的cnn卷积神经网络
- 如何释放SP文件在C盘占用的空间
- Faster RCNN pytorch 复现