先说下我的电脑环境:win10 3060ti torch10 python3.8 cuda11.3

RuntimeError: CUDA out of memory. Tried to allocate 128.00 MiB (GPU 0; 23.70 GiB total capacity; 7.44 GiB already allocated; 87.88 MiB free; 7.71 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

训练一个很小的网络的时候,报了一个这个错,很奇怪,看了一下以为是显存不够的原因 ,但是很矛盾,之前训练过transformer,不可能是这个原因。

通过网络上找来找去,众说纷纭

  1. 降低Dataloader中的batch_size
  2. import gc 清除cuda显存中的缓存
  3. 不让图片送入cuda,这个很明显没有意义
  4. 降低torch版本
  5. 不采用预训练模型

上述在我这里都不通, 我最终的解决方案来自这个链接中的一个回复 CUDA out of memory

降低了图片的像素,最开始的像素是2400x2400,resize到400x400后就可以玩耍了
因为是目标检测任务,resize图片后,label位置也需要进行改变,这里附上一篇不错的博客,希望可以帮到你:label随着resize而改变

RuntimeError: CUDA out of memory 已解决相关推荐

  1. CUDA out of memory.(已解决)+Windows和Linux查看占用显存的程序

    参考链接:1.CUDA out of memory.(已解决)(有用有用) 2.Linux下查看CPU.内存占用率 Ubuntu下查看cuda占用情况&清除gpu占用&跑深度学习报错R ...

  2. pytorch遇见RuntimeError: CUDA out of memory的解决

    RuntimeError: CUDA out of memory 1.查看是否其他程序占用显存 遇到此类错误后,对于py格式的文件来说,程序会进行终止,也就是当前程序占用的显存将会被释放.此时可用 w ...

  3. 已解决yolov5报错RuntimeError: CUDA out of memory. Tried to allocate 14.00 MiB

    问题 RuntimeError: CUDA out of memory. Tried to allocate 14.00 MiB (GPU 0; 4.00 GiB total capacity; 2. ...

  4. 如何解决“RuntimeError: CUDA Out of memory”问题

    点击上方"AI公园",关注公众号,选择加"星标"或"置顶" 作者:Nitin Kishore 编译:ronghuaiyang 导读 一些可以 ...

  5. 使用GPU训练yolo_v2报错:RuntimeError: CUDA out of memory. Tried to allocate XXX MiB

    报错内容: RuntimeError: CUDA out of memory. Tried to allocate 200.00 MiB (GPU 0; 8.00 GiB total capacity ...

  6. RuntimeError: CUDA out of memory. Tried to allocate 132.00 MiB (GPU 2; 3.95 GiB total capacity; 3.41

    pytorch报错:RuntimeError: CUDA out of memory. Tried to allocate 132.00 MiB (GPU 2; 3.95 GiB total capa ...

  7. pytorch出现RuntimeError: CUDA out of memory.

    无论batch-size设置多小也是会出现这个问题的,我的原因是我将pytorch升级到了1.0.1,然后出现了这个问题 RuntimeError: CUDA out of memory. Tried ...

  8. 出现 CUDA out of memory 的解决方法

    目录 1. 问题所示 2. 原理分析 3. 解决方法 3.1 调batch_size大小 3.2 不考虑梯度 3.3 删除无用变量 3.4 kill进程(暴力放弃) 3.5 其他方法 1. 问题所示 ...

  9. RuntimeError: CUDA out of memory. Tried to allocate 1.54 GiB...

    报错 F:\Anaconda3\python.exe "E:/Program Files/PyCharm 2019.2/***/xxx.py" F:\Anaconda3\lib\s ...

最新文章

  1. 提高工作效率的 7 个 Vim 使用技巧!
  2. day3 python 学习随笔
  3. 【求助】哪个软件负责在屏幕右下角显示类似“caps lock on/off”的? - 技术封存区 - 专门网论坛 -...
  4. phpexcel的自动加载与其他框架有冲突
  5. 配置多个git账号_在Windows下配置多个git账号
  6. Ultraedit使用技巧收集
  7. 如何断开GitLab远程仓库链接
  8. Linux基础命令---lpq查看打印队列
  9. U盘怎么重装系统到电脑上
  10. java aop注解日志记录_springMVC自定义注解,用AOP来实现日志记录的方法
  11. HDU-1013-Digital root
  12. Sakai Demo搭建及遇到的问题汇总
  13. Python 列表与元组
  14. 计算机网络研究进展,计算机网络信息空间(Cyberspace)的人文地理学的研究进展和展望.pdf...
  15. 【SpringBoot】3、SpringBoot中整合Thymeleaf模板引擎
  16. 程序员的浪漫------下雪氛围圣诞树源码
  17. vue--单页面应用和多页面应用
  18. 外贸人如何使用intbell挖掘优质客户
  19. 轻松玩转新编日语4 zz江沪
  20. 13.2.1 访问世界银行的数据

热门文章

  1. 户外蓝牙耳机什么牌子好、户外运动耳机推荐
  2. 定时器/计数器实验报告
  3. 陶哲轩实分析-第9章 R上的连续函数
  4. JCJC错别字检测-华为的选择
  5. Ubuntu 经验 —— Fcitx专题:安装Fcitx
  6. html显示宇宙星星,css 如何在html页面上输出一个六角星星呢?
  7. CSS---三大定位方式(相对,绝对,固定定位)
  8. java.lang.IllegalStateException
  9. new与malloc比较与底层实现
  10. malloc函数实现过程