Automatically resume rendering animation, after "GPU out of memory" error

Hi everyone,

So I’m trying to render an animation on the GPU. But I guess my scene is just really complex; because each frame has a slight chance of producing a “GPU out of memory” error. It doesn’t happon on most frames; but when it does, Blender then proceeds to force me to start over, and render the entire animation again.

I know it stores the frames somewhere, cause I can see them with View Animation. So I don’t know why it would make me render them again, instead of simply picking up where it left off.

Is there an addon or anything that might allow me to use already-rendered frames in an animation? And possibly do that automatically?

The already-rendered frames are still saved on your computer. They are by default stored in a temporary folder. If you’re on Windows, I believe it’s C:/tmp

1 Like

Interesting, thanks! I’m actually on Ubuntu, but I’ll look around for the folder

I found an article that says where it is on Ubuntu: https://mgtuts.com/housing-planning/where-is-the-blender-tmp-folder.html

Awesome, found it :smiley:

I can’t seem to find any of the frames though, are they in image format?

They should be- by default, they’re PNGs. I’m not really sure where they might be on Ubuntu, but they should be somewhere. Maybe they’re hidden or in a hidden folder? (I don’t know if Linux even has hidden folders tbh :sweat_smile: ) It’s worth noting that the temporary rendered files clear themselves out when you start a new render, so if you’ve rendered an image or animation since, they might not be there

I recommend that you use “OpenEXR” files instead, and these are a “file per frame” format which makes it easier to restart. But of course the real question is why you are running out of GPU memory at all, particularly “only for certain frames but not others.”

Well my GPU is actually pretty good, I get around 20 seconds on a frame that would take 5 minutes rendering on the CPU alone (or like 1:30 rendering on both)

but yeah I guess I’ll have to try EXRs then. Is there a particular benefit to using them over something like PNGs?

wait sorry, just realized I misread that as “the real question is why you are running on GPU memory at all” xD

yeah though, the running out of memory thing is pretty strange. Not really sure what to attribute it to besides there just being a lot of objects. Seems like I’ve rendered more complex scenes before without issue, but I dunno ¯_(ツ)_/¯

Hi, me again.

Really? I just rendered some frames (FFmpeg) and watched C:\tmp (and C:\temp). No files came and went. Is it set in Preferences somewhere? maybe?

I suggest using OpenEXR (or MultiLayer) for all “intermediates” because it is a data file, not an image file. What it contains is numbers. Lots and lots of 'em. Linear color-space and no lossy compression. “Named data-layers” optional. The data that goes in is exactly the data that comes out.

When you’re finally ready to produce “a deliverable(s)” based on your “final cut,” then you consider things like compression and gamma in ways that are appropriate to each target device and file-type.

So a few things.

  1. Unless you are going a quick/simple playblast animation, then never render out directly to a video file format, on top of the issues like GPU out of memory and being forced to render the whole thing again, the software could crash, the PC could crash, power failure, etc, etc. All of which results in having to render it all over again. Maybe not a big deal if it only takes a few mins to start with, but if each frame is like 10 mins and its a 30s animation that’s a lot of wasted time.

  2. As such, always render out to single image files. The Output Properties tab is your key here. You can set the start and end frame for the animation and the Output (both folder location and file format). So say you have 200 frames to render (1-200) and at frame 56 Blender stops. If you render to image files, then frames 1-55 are all done, so change Frame Start to 56 and hit Ctrl-F12 and Blender will then continue to render the rest of the frames while leave 1-55 alone.

  3. As stated, OpenEXR for the image file format is best, but it can result in very large image files, and unless you plan to do compositing, etc afterwards, then it maybe overkill. So for just a general ‘direct’ to video file, using PNG is fine. DO NOT USE JPG.

  4. Once you have all the image files, you then need to create the video file. There are so many ways to do this it isn’t funny. From command line tools like FFMpeg, to video editors to no doubt a range of little GUI based tools. Personally I use Davinci Resolve, but that’s me. If you don’t want to mess with a full video editor, then you can just use Blender itself.

Blender will let you load that image sequence of files in to its compositor (you could even apply various little filters or colour adjustments if you really wanted to) and then output to a mp4 or mkv file using various codecs and settings of your choice. This is where rendering to images has a second huge advantage (outside of system crashes, etc), in that after making the video file, if the file is too large or too small with bad compression artifacts, you can just adjust the settings and create the video again. Compared to re-rendering the whole thing again, it will be super fast to just re-compress those image files into another video file.

The Blender Manual pretty says what I’ve detailed above: https://docs.blender.org/manual/en/latest/render/output/animation.html

1 Like

While I acknowledge that OpenEXR and especially MultiLayer files are “large,” I submit that modern disk drives and SSD’s and even thumb-drives are vastly larger. So it really doesn’t matter anymore, and there are real advantages, even if you do not plan on compositing or a multi-pass workflow. (If you do not plan to do these things, you probably don’t need “MultiLayer,” whose files are obviously larger.)

OpenEXR files are loss-less and use a linear color-space. “Just the data, ma’am.” When you are making your “movie file decisions,” you are doing it based on raw data to which no such things have previously been applied. And, if you need to produce more than one type of “deliverable,” you make each one entirely independently from the same pristine source.

I like to deal with compression and gamma and so-forth only once. If you use an image-file as a source for then producing a video file, you are now doing these things twice. Unexpected artifacts can appear quickly as “digital noise” accumulates, and they can be difficult or impossible to get rid of without “re-rendering the image file.” Which you never want to have to do.

1 Like

PNG files are loss-less as well, tho I get what your saying, in that it does basically ‘encode’ the colour space into the file, unlike the OpenEXR file.

And yes, you can get pretty large drives now days, 12, 14, 18 TB are not uncommon and while for a business the cost may not matter as much, they still aren’t that super cheap from an individual point of view. Plus you need to consider backups.

Then of course not everything will work with or nicely handle OpenEXR files, compared to that pretty much any/everything will read a PNG file.

So yes, OpenEXR is ideal, but we don’t know exactly what the project/budget/use case the OP is dealing with, so at the end of the day it… depends. If its a little personal animation for someones birthday that will be viewed via Facebook on a phone then I’d say PNG is just fine, no need to over complicate it.

On the other hand, if the OP is doing VFX animation to be combined with live action for a broadcast TV show at 4K, then no question, you use OpenEXR.

1 Like

Just rendered a clip in the multilayer OpenEXR format. They do seem to be unusually large in size (like 10 MB/frame), but otherwise I’d say it works pretty well. Plus I don’t plan on compositing, so the non-multilayer option might have been a better fit.

I do have one more issue though - while I don’t have to lose progress anymore upon GPU error, the process does still halt completely until I manually start the rendering again. And since I render most of my stuff overnight or just afk, that usually means losing a lot of time.

So, would it be possible to write a script that maybe senses for an interruption, and then clicks “Render Animation” again if it returns positive?

If you are border line on GPU VRAM, which is sounds like you are, there’s maybe a couple of fairly simple things you can try.

  1. Prepare a ‘Render file’. This would be a newly saved as file from the most recent working file. Once saved as, clean up the file as best you can. Apply all modifiers that you can, go to File | Clean-up and removed all unused data blocks. Check all your objects, anything that isn’t needed for rendering just the camera you want to render, then delete it (before doing the unused data clean-up). Check you camera view, do you actually have any objects that are totally behind something else and not seen, casting shadows or anything, if so, delete it.

You can also check your shading nodes, are they over complicated, using textures that just don’t have a visual impact.

  1. On the subject of textures, can you reuse the same one in more then one place or better yet use a procedure node group rather then an image at all. Are you using overly large image textures on some surfaces that don’t even fill 15% of the screen, no point in a 4k texture if its no bigger then 256x256 pixels on the final rendered frames.

  2. Before you start the overnight render, restart the PC, never hurts to clean all RAM, etc out. If you are running the desktop at 4k or even 1440p, before the restart reduce the desktop resolution to 1920x1080. The GPU has to store the desktop frame buffer somewhere and thats VRAM.

  3. Don’t start Blender, load the file and press render, Blenders viewport, etc is using VRAM, instead render from a command line.

  4. Your using Linux right, then go ‘full geek’ and start Linux without a GUI at all. Just login to the terminal and do the command line render from there.

Given you are likely only just going over VRAM, chances are just doing 1 or 2 of the above will be enough for a full render. The quickest and easiest likely just lowering the Desktop resolution and command line render from a terminal. Not fully loading up Blender and its viewports, etc will likely free up enough VRAM.

1 Like