Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can I fix RuntimeError: CUDA error: out of memory #42

Open
northmachine opened this issue Dec 30, 2018 · 2 comments
Open

how can I fix RuntimeError: CUDA error: out of memory #42

northmachine opened this issue Dec 30, 2018 · 2 comments

Comments

@northmachine
Copy link

northmachine commented Dec 30, 2018

loading model ./resnext-101-kinetics.pth
resnext-101
resnext-101
./resnext-101-kinetics.pth
./videos/video1.mp4
ffmpeg version 4.1-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './videos/video1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.13.100
Duration: 00:00:22.00, start: 0.000000, bitrate: 408 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 15:16 DAR 5:4], 304 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 0x6972a40] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'tmp/image_%05d.jpg':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 320x240 [SAR 15:16 DAR 5:4], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.35.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 550 fps=0.0 q=24.8 Lsize=N/A time=00:00:22.00 bitrate=N/A speed=49.2x
video:2103kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
/home/northmachine/Desktop/video-classification-3d-cnn-pytorch-master/classify.py:25: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
inputs = Variable(inputs, volatile=True)
Traceback (most recent call last):
File "/home/northmachine/Desktop/video-classification-3d-cnn-pytorch-master/main.py", line 61, in
result = classify_video('tmp', input_file, class_names, model, opt)
File "/home/northmachine/Desktop/video-classification-3d-cnn-pytorch-master/classify.py", line 26, in classify_video
outputs = model(inputs)
File "/home/northmachine/.conda/envs/tensorflow-gpu/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/northmachine/.conda/envs/tensorflow-gpu/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 121, in forward
return self.module(*inputs[0], **kwargs[0])
File "/home/northmachine/.conda/envs/tensorflow-gpu/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/northmachine/Desktop/video-classification-3d-cnn-pytorch-master/models/resnext.py", line 127, in forward
x = self.layer1(x)
File "/home/northmachine/.conda/envs/tensorflow-gpu/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/northmachine/.conda/envs/tensorflow-gpu/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/home/northmachine/.conda/envs/tensorflow-gpu/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/northmachine/Desktop/video-classification-3d-cnn-pytorch-master/models/resnext.py", line 58, in forward
out = self.conv3(out)
File "/home/northmachine/.conda/envs/tensorflow-gpu/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/northmachine/.conda/envs/tensorflow-gpu/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 421, in forward
self.padding, self.dilation, self.groups)
RuntimeError: CUDA error: out of memory

I run with --input ./input --video_root ./videos --output ./output.json --model ./resnext-101-kinetics.pth --mode score --model_depth 101 --model_name resnext --resnet_shortcut B --resnext_cardinality 32 --batch_size 128
I use a gtx1060 3G, is there any parameter I miss

@northmachine northmachine changed the title RuntimeError: CUDA error: out of memory how can I fix RuntimeError: CUDA error: out of memory Dec 30, 2018
@shiyonglian
Copy link

降低batchsize的数量

@suxb201
Copy link

suxb201 commented Jul 18, 2019

/home/northmachine/Desktop/video-classification-3d-cnn-pytorch-master/classify.py:25: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
inputs = Variable(inputs, volatile=True)

You need to add torch.no_grad():
图片

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants