1

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

当我在 Anaconda 提示符中运行此过程时,它会在大约 30 秒后停止并显示此 “RuntimeError: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. 进程停止并写入“RuntimeError:CUDA 内存不足。试图分配 754.00 MiB(GPU 0 ...)我能以某种方式让 cuda 使用 GPU 1 而不是 GPU 0?也许这会有所帮助。

正如我在链接的视频中看到的那样,这个过程可以使用处理器或 nvidia 显卡完成,使用 nvidia 会更快。

这是它运行时的样子

这是它停止的时候

代码在这里:

(base) C:\Users\Nika>cd /d D:\SlowMo\SuperSloMo

(base) D:\SlowMo\SuperSloMo>python video_to_slomo.py --ffmpeg D:\SlowMo\ffmpeg\bin\ --video D:\SlowMo\Input\Rotate.mp4 --sf 4 --checkpoint D:\SlowMo\SuperSloMo\SuperSloMo.ckpt --fps 120 --output D:\SlowMo\Output\Rotate120.mkv
D:\SlowMo\ffmpeg\bin\ffmpeg -i D:\SlowMo\Input\Rotate.mp4 -vsync 0 tmpSuperSloMo\input/%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:\SlowMo\Input\Rotate.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 'tmpSuperSloMo\input/%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:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "D:\SlowMo\SuperSloMo\model.py", line 197, in forward
    x  = F.leaky_relu(self.conv1(x), negative_slope = 0.1)
  File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\functional.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:\SlowMo\SuperSloMo>
4

1 回答 1

1

请试试这个。它对我有用:

import torch, gc

gc.collect()
torch.cuda.empty_cache()
于 2020-05-12T09:48:58.747 回答