Blender Tutorial - How to Speed Up Renders using Google Colab for Free!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
have you spent ages working on a blender scene only to finish set up your render settings for a final render and find that it's going to take hours or even days to get a high quality render how could you fix this well you could go out and spend thousands on a new pc or a good gpu or you could drop your samples on your render activate the aid noise and get an ok result or you could upload your blender files to google colab and get access to free gpus and get a high quality render in a fraction of the time how much quicker you ask well in my test i was able to speed up my render by a factor of 9. in my test i was just using an nvidia geforce 1060m in my alienware laptop it's not a high-end graphics card but it's a decent gaming gpu and something a new user to blender might be using in this tutorial i'm going to show you how i set up a google colab account to provide you access to a free render farm for your blender renders it's a fairly simple process to set up initially and once you've configured it all you need to do in the future is upload your blender files to your google drive run the script and it will save the final render or animations to your google drive so let's get started okay so the first thing i'm going to do is just download a sample blender file from the blender website so if you just go to www.blender.org download demo files you'll get a list of these splash screens if you scroll down a little bit more you'll get some sample ev render files and if you scroll down a little bit further you get some cycles demo blender files so i'm just going to download this car demo which is just a render of a bmw so if you just click on the bmw save it to your desktop so if you open up the zip file you'll find that there's a gpu and a cpu version so if you just double click on the gpu version with the blender file open what we need to do is configure some of the settings that we want to use when we render on google colab and the reason for this is we can't change a lot of these settings when they're open on the command line so when you're in blender the first thing you want to do is change your device from cpu to gpu if possible if your computer has a gpu graphics card the other thing you want to do is go down to the second icon here and under the output tab assuming you want to render as a jpeg or a png you want to change your output path to two forward slashes and what that will do is when it's rendered the final image it will save the image in the same directory as the blend file and you can also change your file format to an avi if you want to render an animation out the point is that you want to set up all your render settings the way you want them for when we copy it to google colab so once you've done that just close down your blend file and you want to upload this blend file to your google drive so i've already got my google drive open here so i'm just going to create a folder called blender renders and i'm going to drop and drag the blender file that i just modified onto my google drive and upload that and that'll just take a minute the next thing you want to do is go to google colab so if you just go to google and type colab that's coa you'll be directed to this landing page for google so you just want to sign in to your google colab account using your gmail account and that will take you here to create a new jupyter notebook you go file new notebook and this is where you can execute your python code or your command line code which will allow you to render your blender file via the command line i've already created a jupyter notebook which will allow you to render this blender file so i'm just going to open that up so i'm not going to type out all these commands again in full but i'll explain what each of the individual steps do you can copy down this code into your own jupyter notebook so the first one is the command which will download the latest version of blender from the official blender website so the exclamation mark wget will download this tar zip file from the blender website so you can see it's just directed to blender.org and i'm downloading version 2.91 if you want to download another version of blender for some reason you can go to the blender website if you go down to the downloads section you can click previous versions and then down here it's got download every version of blender if you click on that you'll get a list of every version of blender that's been released i just scrolled down here and selected the folder labeled blender 2.91 and you want to download the linux 64-bit tar file so you'll want to depending on what version of blender you want to download you want to copy this file name into your jupyter notebook you can see here i've got the 2.91 and this folder before is the blender 2.91 directory so if i go up one directory on the blender website you can see i've got the blender 2.91 folder so depending on what version of blender you want to download you want to get this file at this folder correct and you want to get the file name correct so that's fairly straightforward the next step is to install the blender zip file that you've just um downloaded so this is just unzipping and installing the blender tar file so this version number here has to match the version number that you entered to download up here so this next section here you may or may not need to run it's sometimes required depending on the type of gpu that's installed if your blender render doesn't work for some reason on google collab run this step so this next step is to mount your google drive account and link it to your google colab notebook so it's just going to mount your google drive to the following directory which is slash g drive the next step is to list the file name of the blender file that you've just uploaded so you can see that i've placed my bmw blend file in slash g drive which is my google drive you need to have this my drive as a subfolder and if you remember i've already created a folder called blender renders where i place my bmw 27 gpu.blend before i get to the last step which is to run blender via the command line i need to tell you about this extra python script that's required if you want to run on a gpu on google colab if you don't do the step you'll only be running on the cpu and your renders won't happen very quickly at all so i found this step by going to stack overflow to the blender sub forum and came across this rendering on command line via gpu for blender and if you scroll down here you can see i found this script on stack overflow the blender sub forums which automatically detects any cuda devices on the system that you're running on and automatically enables them which is what's required for running on google colab because we're not sure at any given time what sort of gpu would be running on and this was provided by robert here so if you just copy this entire script and you can just use any text editor that you like or code editor but i'm just going to do this in blender so i'm just loading up blender here i'm going to go over to the scripting tab create a new script ctrl v to paste and i'm just going to go text save as just save it to your desktop somewhere call it gpu dot pi close blender go back to your google drive account and upload that gpu.pyscript to your google drive so with that gpu pi script uploaded to your google drive account you want to go back to your google colab notebook and i'll explain the last step in this process so this step is just to run the blender executable that you installed previously and it's being run from the blender 2.91 subdirectory the next step minus b just runs blender in background so on the command line and doesn't show you the normal interface that you're used to dollar's file name tells blender to render the blender file that you've listed here in file name so in this case our bmw blender file minus p means to run a python script when it runs blender so in this case we're going to run the gpu python script that we just uploaded to google drive so you can see i've placed the python script in the google drive my drive blender renders and the file name which is gpu.pi and this is in the same directory as the bmw gpu.blend file minus e instructs blender to use the specified render engine so in this case we want to use cycles minus f and the number one after it means i want to render the first frame and minus capital f and the png tells blender that i want to save my render as a png file okay so now that we've typed all our code into our jupyter notebook we can start executing the code before you do this you want to go to the edit menu notebook settings and you want to make sure under hardware accelerator you have gpu selected and this will allow us to render our blender file on the gpu within google colab if you don't select this and you have none selected it'll just use a cpu which won't be very fast at all you also want to make sure that you've got this option ticked to emit code cell output when saving from this notebook and then just press save so let's start running the code so press the little play button and this will start downloading blender to our virtual machine and this will take just a few minutes depending on how quick your internet connection is the next step is to install blender the version we just downloaded so press the next play button and just give it a few moments and you can see blender has now been installed and just for completeness sake i'm just going to run this step here which will install those libraries and in this case it looks like they're not required next step is to mount your google drive account so that google collab can see the blender file and the gpu python file so run that and google collab is going to ask you to authorize the link to your uh google drive account so it just says go to this url on the browser so you click that it asks you to choose a google drive account to link so just click your google drive and it says it wants access so just allow and it will ask you to copy this code so you just press the little copy button go back to your google colab and paste the authorization code into the little box and press enter and that will match your google drive account then run the next set of code which is just selecting the file name that you want which is the bmw blend file and then you just want to run the last step which is just executing blender via the command line and rendering the blend file so just press play to make this interesting i'm going to do a side-by-side comparison to see just how much quicker google collab can render this blender file compared with my laptop which is running the nvidia geforce 1060m graphics card so i'm just going to press play here and i'm going to see how long it takes google collab to perform this render so you can see it's loading in all the relevant files this is what you would see as a standard output when you're running a blender file and if you look at the command line here you can see that it started rending the various tiles you can see it's up to sample 1000 of 1600 for the first tile and now it's moved on to this next tile tile 1 of 12 and you can see it's estimating about 1 minute and 35 seconds left to render this so i'm just going to speed this up and see just how long it took to render this file and it looks like it's finished and it took exactly two minutes to render this file and you can just go to your google drive where it's output the the output file and there we have it there's the bmw so now what i'm going to do is render the exact same blender file on my laptop using the nvidia geforce 1060m graphics card and see how long it takes to run on that so i'm just going to go up here and press render render image and let's see how long it takes so at the moment it's estimating about three minutes to render but it looks like it's still fluctuating a bit so it's been rendering for about seven minutes now and it's now says the remaining time is five minutes so it's still increasing so it's now been rendering for about 13 and a half minutes now and the remaining time is one minute 56 we've now been rendering for about 17 and a half minutes so well and truly longer than google collab and it says we've got about four seconds left and there we have it the render is finished it took about 17 minutes and 49 seconds with very little work whatsoever we've dramatically decreased the time it takes to render this file and it didn't cost us a cent if you like this tutorial or any of the other videos on our youtube channel please don't forget to subscribe we'll be uploading more blender tutorials very soon thanks for watching you
Info
Channel: Micro Singularity
Views: 37,479
Rating: undefined out of 5
Keywords: blender, blender tutorial, cycles, render, GPU, optimise, optimize, speed, fast, free, easy, google, google colab, colab, Colaboratory, animation, eevee, blender 2.9, google drive, python, free render farm, software
Id: lEW7efy_aiY
Channel Id: undefined
Length: 15min 29sec (929 seconds)
Published: Fri Dec 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.