Adaptive Compile with Blender Cycles on CUDA
I was lucky enough to catch DingTo on IRC #BlenderChat and he was able to walk me through how to get the new âAdaptive Compileâ to work in the latest version of Blender. It took a little bit of doing but once I got it working I was more than amazed at the memory optimization of this new feature.
If you would like to try it yourself, and you happen to have an nvidia GPU on a linux system, just download the very latest version of Blender from https://builder.blender.org/download/. (It doesnât work yet for the Windows or OSX builds.)
You will also need to install the nvidia-cuda-toolkit. This is so that Cycles can compile before you render each new scene. To do that on my Debian Testing machine I just. . . .
sudo apt-get install nvidia-cuda-toolkit
Iâm sure you can find instructions for your specific Linux distro if you are not using Debian.
I had to revert back to the Debian Nvidia drivers instead of the ones from Nvidia directly to install this but thatâs a pretty painless process with smxi.
So once you have those things working, open up version of blender you downloaded and with the mouse in the 3D view window, hit the space bar and search for Debug. There should only be one option. Select that. Then enter 256 as the debug value and press ok.
What that does is enable a preference box in your interface that will allow you to control different optimizations made for Cycles. âDebugâ Â Make SURE you are using the Cycles render engine or you will not see this option.
Enable the Adaptive Compile flag.
One extra step that you need to do right now that we wonât have to do in the future is to delete the pre-compiled Kernels for your system so that it knows to compile you a new one.  To do that you go into 2.77/scripts/addons/cycles/lib and delete all of the .cubin files.
Now load up a scene and hit F12 to start rendering. The first time you render the scene it will take a while to compile the new custom version of Cycles for your specific scene but once it is through, it will start rendering your scene. You can go ahead and stop stop the render and start it again. This time it will render your scene without having to compile Cycles again and will use your customized version of Cycles built specifically for your scene! Â How awesome is that!?!
It was SUPPOSED to render faster than the standard Cycles but I didnât find that to be the case with my system. What it DID do was dramatically decrease the memory footprint of my scene. I went from using 3368MiB of V-Ram to only 1471MiB! Â
The best way to tell how much memory your scene is using is to open up another terminal window and type in nvidia-smi while your scene is rendering.
You will then get a report that looks like this.
So here you can see that I have two video cards in my system. Â One a GTX 970 and the other a GTX 980 Ti. Â The 980 is the one I was rendering with when I ran nvidia-smi so you can see that it is pegged at 99% usage. Â But the thing you want to look for is the âMemory-Usageâ Â For my scene it was 1471MiB / 6143MiB.
So thatâs it! Â
On the BMW27.blend benchmark scene, with blender 2.77a, my memory footprint was 2668MiB.
With the new Adaptive Compile feature, my memory requirement for the exact same scene went down to just 600MiB. Â That is a MASSIVE drop.
With this new feature Iâll now be able to render on video cards that have much less V-Ram. Â I have a pair of GTX 580s that have been gathering dust for quite a while now. Â All of a sudden those cards have value again! Â They will be able to mix it up with their newer cousins even though they only have 1.5 gigs of V-Ram! Â
If you canât tell. . . Iâm very excited about this. Â :-)