当前位置:网站首页>Problem solving: runtimeerror: CUDA out of memory Tried to allocate 20.00 MiB
Problem solving: runtimeerror: CUDA out of memory Tried to allocate 20.00 MiB
2022-07-08 02:20:00 【Programming newbird】
Three methods commonly used on the network
Method 1 :
Just reduce batchsize
Change the configuration of the file cfg Of batchsize=1, Generally in cfg Search under file batch or batchsize, take batchsize Turn it down , Run again , Similar to changing the following
Method 2 :
The above method has not been solved yet , Don't change batchsize, Consider links to the following methods
Don't calculate the gradient :
ps: On which line of code is the error reported , Add the following line of code , Don't calculate the gradient
with torch.no_grad()
The method of not calculating the gradient
Method 3 :
Free memory : Links are as follows
Free memory
if hasattr(torch.cuda, 'empty_cache'):
torch.cuda.empty_cache()
ps: On the top of the line of code that reported the error , Add the following two lines of code , Free irrelevant memory
if hasattr(torch.cuda, 'empty_cache'):
torch.cuda.empty_cache()
Method four : My solution
I didn't use the above method , The most important thing is that I'm a novice and don't know where to change , So after reading a lot of online solutions , Try this method , You can train , Successfully solved GPU Out of memory
resolvent : take img-size The small
I put the original [640,640] As shown in the figure above , Solve the problem successfully
边栏推荐
- Ml self realization / linear regression / multivariable
- 非分区表转换成分区表以及注意事项
- JVM memory and garbage collection-3-object instantiation and memory layout
- Learn CV two loss function from scratch (3)
- [knowledge map paper] attnpath: integrate the graph attention mechanism into knowledge graph reasoning based on deep reinforcement
- 牛熊周期与加密的未来如何演变?看看红杉资本怎么说
- 数据链路层及网络层协议要点
- Keras' deep learning practice -- gender classification based on inception V3
- 如何用Diffusion models做interpolation插值任务?——原理解析和代码实战
- Keras深度学习实战——基于Inception v3实现性别分类
猜你喜欢
[knowledge map paper] Devine: a generative anti imitation learning framework for knowledge map reasoning
实现前缀树
Spock单元测试框架介绍及在美团优选的实践_第四章(Exception异常处理mock方式)
《通信软件开发与应用》课程结业报告
Kwai applet guaranteed payment PHP source code packaging
Semantic segmentation | learning record (5) FCN network structure officially implemented by pytoch
数据链路层及网络层协议要点
Applet running under the framework of fluent 3.0
Industrial Development and technological realization of vr/ar
C language -cmake cmakelists Txt tutorial
随机推荐
UFS Power Management 介绍
关于TXE和TC标志位的小知识
Force buckle 4_ 412. Fizz Buzz
Industrial Development and technological realization of vr/ar
Leetcode featured 200 -- linked list
入侵检测——jsql
QT -- create QT program
鱼和虾走的路
Many friends don't know the underlying principle of ORM framework very well. No, glacier will take you 10 minutes to hand roll a minimalist ORM framework (collect it quickly)
Can you write the software test questions?
Master go game through deep neural network and tree search
image enhancement
Strive to ensure that domestic events should be held as much as possible, and the State General Administration of sports has made it clear that offline sports events should be resumed safely and order
PHP calculates personal income tax
Semantic segmentation | learning record (4) expansion convolution (void convolution)
Ml backward propagation
Leetcode featured 200 channels -- array article
For friends who are not fat at all, nature tells you the reason: it is a genetic mutation
Anan's judgment
【每日一题】736. Lisp 语法解析