Blender Cycles X is Insanely Fast on Google Colab! - Blender Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone i'm very excited to present part three of rendering blender on google collab this is the most exciting tutorial to date because i will be answering some of the most asked questions from my last two collab tutorials firstly it's been asked how to run experimental builds of blender on collab so we're going to be covering that today not only that we're going to be running the experimental cycles x branch of blender which you may have heard is extremely fast compared to the current version of cycles not only that i've had a request to make a tutorial of how to install blender on google drive so you don't have to download it each time you run this code so we're going to run through that today too and then i'm going to do a render time test between cycles in blender 2.93 and cycles x in version 3 on collab and on my pc you won't believe how fast it is it's going to be especially useful for those new artists out there who can't justify spending a lot on an expensive pc with a high powered gpu at the end of this tutorial i'll run through some of the most frequently asked questions from my other blender collab videos so let's get started first of all i want to show you just how quick cycles x can be i've downloaded this demo blender scene from the blender website it's called classroom i've opened it up here on my laptop the only thing that i've changed from the default file is the tile size and selected gpu as the render device as you may have heard cycles x is doing away with tile based rendering and has moved towards progressive rendering only which means it renders the entire frame progressively rather than rendering small tiles individually and then moving on to the next what this means is to make this a fair test of the old and new version of cycles is that i need to render using tile-based rendering for the old version of blender and progressive for the new version for gpu-based rendering large tile sizes generally improve render times so for fairness i've set my tile size to 256 by 256 pixels for blender 2.93 and i don't have to do anything for cycles x it'll set progressive rendering automatically when i run it on collab so let's press render on my laptop and see how long it takes i know some people commented in my first video that it wasn't fair that i was rendering using cpu and gpu together so i've disabled my cpu as a render device and this is now only rendering with my nvidia 1060 graphics card so that render took 8 minutes and 39 seconds to complete now let's run the same file on google collab with the current version of blender 2.93 and see how long that takes i'll run through this code on how to do this later you can also check out my last two collab videos if you just want to run blender directly from colab and not from your google drive so that took two minutes and 47 seconds so that's approximately 3.1 times as quick rendering the same scene on google colab as it is on my laptop now let's see how long cycles x takes to render this same scene so that took just 52 seconds to render that's approximately 3.2 times faster than the previous version of blender blender version 2.93 amazing so that's almost 10 times faster than my laptop that's great news for writers who need to render complex blender scenes and just have a basic laptop or desktop so let's get on with the tutorial and how you can do this yourself to speed up your renders the first thing you're going to want to do is go to google co-lab and this is where you're going to be running the code it just requires a free gmail account to run then you want to go file new notebook and that just takes a second next you can give your jupyter notebook a name so you can just call it blender for example then you want to press edit notebook settings change hardware accelerator to gpu and press emit code cell output when saving this notebook and then press reload okay now press connect so here's a notebook that i've prepared earlier with the code that we're going to need so you just need to type these code cells line by line as we go to create a new code cell you just go insert code cell you can also download this complete jupyter notebook from my github repository and i'll leave a link to that in the description of this video but for now i'll just run through the individual steps and just explain what they do okay so the first thing you're going to want to do is to connect your google drive account to your google co-lab notebook and you do that by running these two lines of code so press start and this will ask you to click on this url which will allow you to authorize the connection between colab and google drive so click this you'll then have to click on the gmail accounts that you want to link to colab say allow and then you'll be asked to copy this code back into your collab notebook so copy this by pressing the button go back into colab and paste it into this box and press enter and that will mount your google drive as a drive in collab so that's complete so the next thing you're going to want to do is to download blender from the blender website so for this i'm going to download the experimental version of blender which is version 3 cycles x branch so to do this you go to the blender website go download scroll all the way to the bottom go to blender experimental then you want to go up here to the top and click experimental change the operating system to linux scroll down until you see blender 3 cycles x then right click go copy link go back to your colab notebook now we want to start working with the second code block here wget minus c downloads the blender file from the website but you need to specify the address so you just paste your web address that we just copied there so it's downloading it from builder.blender we're downloading the experimental branch of blender 3 and cycles x so once you've done that you just press play to run that and that can take just a few minutes we'll come back once this has finished downloading if for some reason you just want to download the latest stable version of blender you go to the main blender website press download go mac os linux and other versions and you want to scroll down to the linux version here and click that and you'll find that that will try and download the blender file automatically but we actually just want the web address for us if you scroll down here to the bottom it says your download should begin automatically if it doesn't click here to retry right click on this link here and go copy link and then you can just paste that into the collab where we specify what version of blender we want to download okay so blend has been downloaded now so the next step is to unzip the tar file that's just been downloaded from the blender website to do this we need to know what the file name of the zip file is you can find that out by typing exclamation mark ls and running that and you can see it saved this file here blender version 3 alpha cycles x branch and the tar dot t xz is just a zip file so to unzip it i'm just going to uncomment this line here that says exclamation mark tar and then you list the file name that's just been printed here so you can just copy and paste this into this line here and then press start and that should just take a few seconds so if you do want to run blender from this location if you just drag this page over here and click the little file icon you'll see the blender has now been unzipped to this folder here and if you open it up you'll see blender here which is the executable so you could just run it from this location here but i'm going to show you how you can copy it to your google drive so you don't have to re-download it every time so depending on where you've mounted your google drive you can see here i've mounted it to forward slash drive so to get to that location you just click on here and you've got a list of all the directories that are on google colab so currently our working directory is in the content folder so you can see the tar file that we downloaded and the unzip directory for blender here i'm going to try and do this with as few coding steps as possible so the easiest way to copy blender version 3 onto google drive so you don't have to re-download every time it's just to go to your directory structure here open drive my drive i'm just going to copy the blender 3 folder into my drive make sure you download the folder and not the tar file so just drag and drop it onto my drive and this can take just a few seconds for it to update okay so you can see it's now been copied onto my drive now just to make it a bit easier for ourselves i'm just going to rename this folder so you can go back to your my drive folder and you can see it appears now here i'm in my google drive so i'm just going to right click on here and go rename and i'm just going to call it blender 3. now go back to google colab and you can press this refresh button here which will update the directory structure sometimes it can be a little bit slow to update but just be patient okay now that you've copied blender to your google drive you don't actually need to use these lines anymore so for future sessions of google colab you can just comment out that line there where we're downloading blender you can comment out this one if you want to and you can also comment out the unzipping of the blender file and i'm just going to go edit and clear all outputs that'll just tidy up my screen a little bit okay so once you've downloaded blender from the blender website you want to copy your blender file that you want to render onto your google drive as i said i just downloaded this example demo file from the blender website which is the classroom example once you unzip this demo file you'll find that it contains an assets folder a textures file and it will also have the blender file as well as well as a readme so you're going to want to copy the assets folder textures and the classroom.blend file to your google drive so you do that just by selecting those three and dropping and dragging onto your google drive just to a file of your choice just make sure you know what the the path for that file is so you can see i've uploaded this to my google drive which is my drive cycles x test and it's in the classroom folder and you can see i've got my classroom.blend textures and assets so the next thing you're going to want to do is to set the file name and file path for the blender file that you want to render so i'm just going to uncomment this line here and i've currently got my file path set to drive my drive which is your google drive i've got a folder called cycles x test it's in a folder called classroom and i've just got a blender file called classroom b3 for blender 3 and blend and if i go to my google drive cycles x tests classroom and you can see that blender file is there that we just uploaded and the associated asset and texture files so an easy way to get this file path is just to bring up your file explorer here you can go navigate to your google drive here in the folder structure go to your corresponding folder but i'm just going to go to my classroom folder here and i want to get the file path for my classroom blender 3.blend and you can just press the three dots here and go copy path and then you can just paste it into this line here and make sure you have the inverted commas around the outside just like that and then run that line there so occasionally i'll get an error when i try and run blender from the command line like this that says command not found one way that i found to get around this is just to change the permissions to be able to execute the blender file from google drive so you could just type this command here so you just run this line here and then finally we can just run blender from the command line so to do this you just go exclamation mark sudo then you need to specify the directory that blend has been installed to for me i just saved it to my google drive root directory and blender 3. if i double click on that you can see we've got our blender executable sitting down here it's just called blender so if you bring up your directory structure here go up one level then go to your google drive my drive blender three and i want to copy the file path for blender just blender on its own and press the three dots and go copy path so then you can just paste that into this first section here okay let's look at the following arguments minus b just means run blender and background so essentially that means just run it without a display and since we don't have a display on colab we kind of need that dollar's file name is a reference to the blender file that we want to run on colab so that just looks for this directory here that we specified earlier no audio is just a required argument minus e is the render engines that we want to use so in this case we're going to use cycles and make sure it's all uppercase and has inverted commas minus o and this bit of code here just specifies where to save our render to so in this case it's going to save a png file to my google drive to the folder called classroom minus little f means which frame do you want to render so i've got minus little one so it's going to render the first frame in my blender file minus capital f and png in inverter commas means i want to render as a png image and then finally we've got dash dash space dash dash and then cycles dash device space optics so with an nvidia gpu you have the option in blender to run using cuda or optics and generally optics is found to be faster and since google collab is running a nvidia gpu behind the scenes we have the option to use either cuda or optics so i'm just going to use optics for now so with that all that set up i'm just going to press start and you can see it's loaded blender 3 alpha i've generally found that running from google drive is a little bit slower to start than just running it from the google temporary directory so depending on your application you may just want to run it from the temporary directory and download it every time but it's up to you be sure to check out my other tutorials on google collab and blender if you do want to run it directly from the temporary directory so you can now see that blender has started to load the file it's loading in all the objects it's loading in all the textures if you scroll down and you can see it's rendering frame one now still loading in all the textures there's quite a lot of textures in this file and then we get to this where it says sample one of 300. frame one and how much time it's taken to render so far so the first time you run blender from colab it can generally take a little bit longer but i found every subsequent run is a little bit quicker we're currently now rendering a sample 129 of 300 as i said cycles x is now progressive so it's just a single tile and it's reporting the number of samples that it's done for that one tile and now it's complete at 300 of 300 samples and it's reporting that it has saved to slash drive slash my drive and classroom0001 so if we navigate to my google drive and go to the main root directory you can see we've now got this classroom classroom0001.png and i can double click on it and you can see the final render result and then you can just download this render to your desktop just by right-clicking and going download and downloading it to wherever you like once you finish rendering your blender file make sure you close the session so priority for the collab gpus is generally given to those who haven't used google collab as much in the past so to make sure you're not wasting gpu time once you finish your blender render go up here where it says ram and disk and click the little down arrow go manage sessions and just make sure you press terminate to end your session and once it's disappeared it means you're not using a gpu anymore next i'm going to answer some questions that have been asked frequently on my last two collab videos so the first one that i get asked is does evie run on collab and the answer to that is yes and no i've done a lot of research and there are ways of making eevee run on collab the main issue is that ev needs to have an active display to render a frame because google collab runs without a display you get an issue about a display not being active if you try and run the render the main workaround that i've found is to set up a virtual display using some python code but my tests and the tests of others have shown that this isn't generally any quicker than running it on your local pc there are a few things in the release notes for upcoming versions of blender which might hint as to a possible workaround for this in the future but for right now it generally isn't possible but if you do have a solution please leave a comment and i'd love to learn how you did it a few people have also asked if the compositor node setup works when rendering on collab and i can confirm yes it does i tried rendering this cube with a low number of samples which generates a lot of noise without the compositor denoiser and i've also changed the colors dramatically to prove that it works it doesn't require any changes to the blender file you just run it using the standard blender collab configuration and you should get the same result another question i've had a few times is whether or not you can bake fluids on google colab using the gpu my research has found that at the moment fluid simulations are baked on the cpu of your computer not the gpu so there really isn't any benefit in baking fluid simulations on colab so you're better off just baking the simulations on your local pc copying the data files for the cache to your google drive and then rendering on colab to do this you need to change your baked directory to be two forward slashes to indicate that the relative path is the same as your blender file then make sure mesh is selected and then press bake all then press file external data and make all paths relative then you just need to upload the blended data directory and your blender file to the same directory on your google drive and run collab as normal make sure though that the blender file isn't in the blender data folder the folder and the blender file need to be in the same directory as each other you are still looking to bake fluid simulations on collab for some reason i've given you a head start and i've uploaded a python script to my github page which will give you the python commands to bake all fluid simulations from the command line you can run this python script as an optional argument when running your render on colab have a look at part one of my collab tutorial for more information on running python scripts from the command line i've had a couple of people ask me why the windows version of blender doesn't run on collab the reason is colab is running linux behind the scenes and you need the linux version of blender to run on codelab it's fine to make your blender seen on windows or mac operating system using those specific versions of blender but you need to use the linux version on collab but it doesn't make any difference to your render one final note i'd also like to mention that according to google the maximum time that you can run blender for oncolab is 12 hours and colab will automatically close the notebook and discontinue any processing after 90 minutes of inactivity thank you very much for watching cycles x is really going to be a great addition to blender but hopefully you can still get some use out of it while it's in the experimental stages please don't forget to like this video and subscribe to my channel if you enjoy these videos stay tuned for more blender tutorials see ya you
Info
Channel: Micro Singularity
Views: 18,978
Rating: undefined out of 5
Keywords: Blender 3, cycles x, blender, blender tutorial, cycles 10, 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, online, cloud render, software
Id: A8FiCPUEv9Q
Channel Id: undefined
Length: 20min 54sec (1254 seconds)
Published: Mon Jun 07 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.