运行时错误:Cuda内存不足。尝试分配754.00 MiB(GPU0;2.00 GiB总容量;已分配1.21 GiB...) [英] RuntimeError: CUDA out of memory. Tried to allocate 754.00 MiB (GPU 0; 2.00 GiB total capacity; 1.21 GiB already allocated ...)

查看:0
本文介绍了运行时错误:Cuda内存不足。尝试分配754.00 MiB(GPU0;2.00 GiB总容量;已分配1.21 GiB...)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Super-SloMo将视频转换为高FPS镜头 https://www.youtube.com/watch?v=mXwXtIiOjRA&t=329s

当我在Anaconda Prompt中运行此进程时,它在大约30秒后停止,并显示如下 "运行错误:CUDA内存不足。已尝试分配754.00 MiB(GPU 0;2.00 GiB总容量;1.21 GiB已分配;144.74 MiB可用;10.06 MiB已缓存)"

我真的不知道那里发生了什么,我对此几乎没有什么问题。

我的笔记本电脑规格:配备GeFroce 920mx专用显卡的英特尔i3-7100u

  1. 所以当我在这个过程中查看任务管理器时,只有CPU被加载,而GPU-s没有被加载,所以这是正确的吗?比如也许GPU可以处理这些事情?
  2. 进程停止并写入"运行错误:Cuda内存不足。已尝试分配754.00 MiB(GPU 0...)我能否以某种方式使Cuda使用GPU 1而不是GPU 0?这可能会有所帮助。

正如我在我链接的视频中看到的,这个过程可以用处理器或Nvidia显卡来完成,而用Nvidia会快得多。

This is what it looks when it is running

This is when it stops

代码如下:

(base) C:UsersNika>cd /d D:SlowMoSuperSloMo

(base) D:SlowMoSuperSloMo>python video_to_slomo.py --ffmpeg D:SlowMoffmpegin --video D:SlowMoInputRotate.mp4 --sf 4 --checkpoint D:SlowMoSuperSloMoSuperSloMo.ckpt --fps 120 --output D:SlowMoOutputRotate120.mkv
D:SlowMoffmpeginffmpeg -i D:SlowMoInputRotate.mp4 -vsync 0 tmpSuperSloMoinput/%06d.png
ffmpeg version N-94156-g93a73df54d Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190621
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 30.100 / 56. 30.100
  libavcodec     58. 53.101 / 58. 53.101
  libavformat    58. 28.101 / 58. 28.101
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 56.100 /  7. 56.100
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:SlowMoInputRotate.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp41isom
    creation_time   : 2019-04-29T19:00:00.000000Z
  Duration: 00:00:04.67, start: 0.033333, bitrate: 32571 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 2880x2160 [SAR 1:1 DAR 4:3], 33772 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2019-12-08T21:30:20.000000Z
      handler_name    : VideoHandler
      encoder         : AVC Coding
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> png (native))
Press [q] to stop, [?] for help
Output #0, image2, to 'tmpSuperSloMoinput/%06d.png':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp41isom
    encoder         : Lavf58.28.101
    Stream #0:0(und): Video: png, rgb24, 2880x2160 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
    Metadata:
      creation_time   : 2019-12-08T21:30:20.000000Z
      handler_name    : VideoHandler
      encoder         : Lavc58.53.101 png
frame=  135 fps=1.6 q=-0.0 Lsize=N/A time=00:00:04.50 bitrate=N/A speed=0.0525x
video:1337063kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
  0%|                                                       | 0/134 [00:04<?, ?it/s]
Traceback (most recent call last):
  File "video_to_slomo.py", line 217, in <module>
    main()
  File "video_to_slomo.py", line 166, in main
    flowOut = flowComp(torch.cat((I0, I1), dim=1))
  File "C:ProgramDataAnaconda3libsite-packages	orch
nmodulesmodule.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "D:SlowMoSuperSloMomodel.py", line 197, in forward
    x  = F.leaky_relu(self.conv1(x), negative_slope = 0.1)
  File "C:ProgramDataAnaconda3libsite-packages	orch
nfunctional.py", line 1063, in leaky_relu
    result = torch._C._nn.leaky_relu(input, negative_slope)
RuntimeError: CUDA out of memory. Tried to allocate 754.00 MiB (GPU 0; 2.00 GiB total capacity; 1.21 GiB already allocated; 144.74 MiB free; 10.06 MiB cached)

(base) D:SlowMoSuperSloMo>

推荐答案

请尝试此操作。它对我起作用了:

import torch, gc

gc.collect()
torch.cuda.empty_cache()

这篇关于运行时错误:Cuda内存不足。尝试分配754.00 MiB(GPU0;2.00 GiB总容量;已分配1.21 GiB...)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆