当前位置:网站首页>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
边栏推荐
- Force buckle 4_ 412. Fizz Buzz
- [recommendation system paper reading] recommendation simulation user feedback based on Reinforcement Learning
- 生命的高度
- 企业培训解决方案——企业培训考试小程序
- WPF custom realistic wind radar chart control
- Learn CV two loss function from scratch (1)
- VIM string substitution
- 【每日一题】648. 单词替换
- Neural network and deep learning-5-perceptron-pytorch
- Ml self realization / logistic regression / binary classification
猜你喜欢
leetcode 869. Reordered Power of 2 | 869. 重新排序得到 2 的幂(状态压缩)
excel函数统计已存在数据的数量
Learn CV two loss function from scratch (4)
[knowledge map paper] attnpath: integrate the graph attention mechanism into knowledge graph reasoning based on deep reinforcement
VR/AR 的产业发展与技术实现
Yolov5 Lite: ncnn+int8 deployment and quantification, raspberry pie can also be real-time
牛熊周期与加密的未来如何演变?看看红杉资本怎么说
leetcode 869. Reordered Power of 2 | 869. Reorder to a power of 2 (state compression)
入侵检测——jsql
JVM memory and garbage collection-3-object instantiation and memory layout
随机推荐
1385:团伙(group)
Semantic segmentation | learning record (1) semantic segmentation Preface
Infrared dim small target detection: common evaluation indicators
Emqx 5.0 release: open source Internet of things message server with single cluster supporting 100million mqtt connections
leetcode 869. Reordered Power of 2 | 869. 重新排序得到 2 的幂(状态压缩)
Give some suggestions to friends who are just getting started or preparing to change careers as network engineers
Why did MySQL query not go to the index? This article will give you a comprehensive analysis
Semantic segmentation | learning record (3) FCN
Master go game through deep neural network and tree search
leetcode 865. Smallest Subtree with all the Deepest Nodes | 865. The smallest subtree with all the deepest nodes (BFs of the tree, parent reverse index map)
Learn face detection from scratch: retinaface (including magic modified ghostnet+mbv2)
Vim 字符串替换
Little knowledge about TXE and TC flag bits
Xiaobai tutorial: Raspberry pie 3b+onnxruntime+scrfd+flask to realize public face detection system
Learn CV two loss function from scratch (1)
Direct addition is more appropriate
银行需要搭建智能客服模块的中台能力,驱动全场景智能客服务升级
LeetCode精选200道--链表篇
Leetcode featured 200 -- linked list
Semantic segmentation | learning record (2) transpose convolution