Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Render Blender Files on Google Collab = MOVED TO https://github.com/donmahallem/colab_blender
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jbjavad-babakan

This comment has been minimized.

Copy link

@jbjavad-babakan jbjavad-babakan commented Mar 6, 2020

dear friend it renders all 10 frames with first frame please help what is wrong with me

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Mar 6, 2020

Did you try to render all frames separately instead of the whole animation? Does it render separately frames locally?

@jbjavad-babakan

This comment has been minimized.

Copy link

@jbjavad-babakan jbjavad-babakan commented Mar 9, 2020

i add -j1 to it now its ok rendering all frames ok
but now i want to render a scene with fluids sim in it and dont render fluids animation
please help how to do render fluids simulation

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Mar 9, 2020

If you want to render just one frame use -f 1 and did you bake your animation and uploaded the baked files too? If not you need to!

@jbjavad-babakan

This comment has been minimized.

Copy link

@jbjavad-babakan jbjavad-babakan commented Mar 11, 2020

dear friend i put cache folder in same folder as blender scene file but no chance still it doesn't change fluid mesh on frames
but i checked in my pc blender command line render it renders correct any help please many thanks in advance

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Mar 11, 2020

To be honest I can just wildly guess. Does the colab console command give any errors about missing files? And are you using the correct blender version in colab? Blender 2.82 projects will not work well with Blender 2.81.

@jbjavad-babakan

This comment has been minimized.

Copy link

@jbjavad-babakan jbjavad-babakan commented Mar 11, 2020

yes i use blender 2.81 but i have flip fluids addon in scene may it cause this i will create a sene with blender native fluids and try again

@jbjavad-babakan

This comment has been minimized.

Copy link

@jbjavad-babakan jbjavad-babakan commented Mar 12, 2020

I create a scene with blender native fluids and tried it no help still it do not render fluids simulation
it is grate with it i can enjoy a good gpu that i cant afford to buy for my computer i know a little and can not edit your code but it should be possible to solve

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Mar 12, 2020

I did use the code above with native fluids aswell with the manta flow build of blender and it both worked fine. Its just important to have the baked simulation and its paths in the correct place. Best is to use relative paths to the blender file

@jbjavad-babakan

This comment has been minimized.

Copy link

@jbjavad-babakan jbjavad-babakan commented Mar 12, 2020

thanks for quick answer i tried to change blender version in your code to "https://ftp.halifax.rwth-aachen.de/blender/release/Blender2.82/blender-2.82-linux64.tar.xz" i get errors if you could please add it to your code

@jbjavad-babakan

This comment has been minimized.

Copy link

@jbjavad-babakan jbjavad-babakan commented Mar 12, 2020

tanks for quick answer I tried to change blender version to 2.82 in your code by adding
"https://ftp.halifax.rwth-aachen.de/blender/release/Blender2.82/blender-2.82-linux64.tar.xz"
but it gives errors if you could kindly please add this to your code.

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Mar 12, 2020

They are using a different compression now indicated by the different extension. I will update it

@jbjavad-babakan

This comment has been minimized.

Copy link

@jbjavad-babakan jbjavad-babakan commented Mar 12, 2020

thanks

@jbjavad-babakan

This comment has been minimized.

Copy link

@jbjavad-babakan jbjavad-babakan commented Mar 12, 2020

"To be honest I can just wildly guess. Does the colab console command give any errors about missing files? And are you using the correct blender version in colab? Blender 2.82 projects will not work well with Blender 2.81."
I am aware of versions i used your new code with 2.82 option no change there is no errors it render all frames with no simulation
I mast add its fine and ok with animations with no fluids thanks a lot for remarkable work
I attach few render frame
bb0012
bb0011
bb0010
bb0003
bb0002
bb0001

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Mar 12, 2020

I do currently dont have enough time and resources to help you any further than give some "guess into the dark". It should work with the build in fluid sim and you probably have to extend the script to use flipfluid addons but thats out of my knowledge as I never used FlipFluids.

@jujubeesloco

This comment has been minimized.

Copy link

@jujubeesloco jujubeesloco commented Mar 24, 2020

Any way to use the EEVEE render engine instead of CYCLES?

-and many thanks! Amazing.

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Mar 24, 2020

@jujubeesloco unfortunately I didn't get it to work quickly but I didn't really need it so I gave up early. I can just give you directions:

You need to google for "headless blender" or "displayless blender" and adapt the above cli command. Blender requires a X-Server if I remember correctly to use Eevee. So you need to emulate a display somehow.

Unfortunately I cant help you any further with this subject but give you the directions.

@agmmnn

This comment has been minimized.

Copy link

@agmmnn agmmnn commented Mar 24, 2020

@jujubeesloco Eevee doesn't support headless rendering, because it needs a display to render. You can follow this instruction for render with eevee, this is the easiest way using OpenGL on Colab. (remocolab)

@jbjavad-babakan

This comment has been minimized.

Copy link

@jbjavad-babakan jbjavad-babakan commented Apr 3, 2020

is it possible to make blender cache folder on colab notebook and bake simulation there

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Apr 3, 2020

No idea but I would really advise against doing that. Collab notebooks(last time I checked) only offer two medium powered logical cores which would make baking really slow.

If you still want to do it my guess would be that you will have to write a small python script to start the bake.

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented May 4, 2020

Will look into it, when I am back at my PC. I guess you get offered different urls to download depending on your geographical location so that might be part of the krux too

@anki24-curious

This comment has been minimized.

Copy link

@anki24-curious anki24-curious commented May 6, 2020

Hi,thank you so much for this great script i am just flattered... :-)
Is there anyway eevee render engine can be used with this script ?

Again thanks for this script

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented May 6, 2020

@anki24-curious look into the discussion above. That was already discussed there

@rahulkrraj0

This comment has been minimized.

Copy link

@rahulkrraj0 rahulkrraj0 commented May 10, 2020

Fra:1 Mem:1980.00M (0.00M, Peak 2020.30M) | Time:01:08.67 | Remaining:00:00.08 | Mem:763.25M, Peak:773.97M | Scene, View Layer | Rendered 509/510 Tiles, Sample 128/128
Fra:1 Mem:1980.00M (0.00M, Peak 2020.30M) | Time:01:08.76 | Mem:763.25M, Peak:773.97M | Scene, View Layer | Rendered 510/510 Tiles
Fra:1 Mem:1980.00M (0.00M, Peak 2020.30M) | Time:01:08.76 | Mem:763.25M, Peak:773.97M | Scene, View Layer | Finished
Unable to open a display

how to solve this

@rahulkrraj0

This comment has been minimized.

Copy link

@rahulkrraj0 rahulkrraj0 commented May 11, 2020

@rahulkrraj0

This comment has been minimized.

Copy link

@rahulkrraj0 rahulkrraj0 commented May 11, 2020

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented May 11, 2020

Weird. I can't see an obvious reason why that should be happening. Afaik your render finishes. Does it output your frame to a file? Did you try to render a different file just with the default cube to check if its blend file specific?

@rahulkrraj0

This comment has been minimized.

Copy link

@rahulkrraj0 rahulkrraj0 commented May 11, 2020

@rahulkrraj0

This comment has been minimized.

Copy link

@rahulkrraj0 rahulkrraj0 commented May 12, 2020

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented May 15, 2020

@jujubeesloco I might want to transfer this gist to a repo so that people can open PRs, Issues and maintain a guide/wiki for people. This is getting a little out of hand and we see the same questions over and over. We will lose the option afaik to directly import gists into Google unfortunately but the comment section will be more managable .

If you don't mind could you open PRs with your additions? I would happily accept them if they look good!

https://github.com/donmahallem/colab_blender

@EyeTreasure

This comment has been minimized.

Copy link

@EyeTreasure EyeTreasure commented Jun 4, 2020

I was just wondering how to make .mov files accessible (prores format). I have a .blend file with a .mov file packed into it (from greensccreening). On colab it only renders a white rectangle, so obviously it cannot read the file as this is an Apple proprietary format. It does work on my Mac where Blender has access to the this. I could try to use a series of stills or a different video format. Any suggestions or workarounds?

@EyeTreasure

This comment has been minimized.

Copy link

@EyeTreasure EyeTreasure commented Jun 4, 2020

OK I am answering my own question. It is dead simple. One cannot pack the .mov file into the .blend file. I have put the .blend and the .mov file in the same directory on the mounted G-drive and they have to be in the same directory on the computer. It worked a treat.

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Jun 5, 2020

Yeah, exactly like that. Forgot to answer yesterday. Side info: In some cases it does not work. Go to the file menu and use the "make all paths relative" option to fix all paths in case an absolute is used which doesnt work with collab.

@EyeTreasure

This comment has been minimized.

Copy link

@EyeTreasure EyeTreasure commented Jun 5, 2020

I just looked at the rendered footage. There is still an issue. Blender has only processed the first frame from the .mov file but rendered all Blender objects correctly. I am not sure what went wrong here as the footage plays fine on my Mac.

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Jun 5, 2020

I have to guess right now, as I can't test/confirm my suspicion and possible solution right now. You did use the clip as Image Texture probably? Did you set frame count, autorefresh etc. ? So it does chose the correct frame every time? I always used image sequences instead of video clips as they dont suffer from random decoding issues etc so I can only guess why this is happening

@EyeTreasure

This comment has been minimized.

Copy link

@EyeTreasure EyeTreasure commented Jun 6, 2020

Well, I used 'import images as planes'. In the end I got it to work now. I uploaded the .blend file again and made sure everything was in the same folder. I have conisidered image sequences but the original file is prores from my BMPCC so this would have been yet another step.

@rahulkrraj0

This comment has been minimized.

Copy link

@rahulkrraj0 rahulkrraj0 commented Jun 7, 2020

@Raimund58

This comment has been minimized.

Copy link

@Raimund58 Raimund58 commented Jun 24, 2020

Hi there, I think that the GDrive mount should be at the top because that requires user interaction. After that the whole notebook can run without any user interaction (if you already did the setup once) to "render animation".

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Jun 24, 2020

Good point. Would you mind to add another PR?

On the other hand I am considering to split this thing up into 2-3 supportive scripts and just one stream lined notebook. So you just copy the notebook it pulls all required scripts from github and executes them as needed. Like one script to handle version download and another script to create the python script used by blender.

Besides that I would really prefer if the conversation for this would move over to the repository as this is getting a little out of hand imho.

I could create a script which updates this gist with the most current one from the repo but issues and other stuff should move over there

@Raimund58

This comment has been minimized.

Copy link

@Raimund58 Raimund58 commented Jun 24, 2020

Would you mind to add another PR?

Right now I don't have the possibilities.

So you just copy the notebook it pulls all required scripts from github and executes them as needed.

Sounds awesome!

@gunboxstudios2020

This comment has been minimized.

Copy link

@gunboxstudios2020 gunboxstudios2020 commented Oct 14, 2020

Thank you for making this project. How can we alter the code to install and run Blender 2.91 instead and the future versions?

Would be easier to know how to update the code and use instead of asking you to make new versions every time

@MasterHelix9

This comment has been minimized.

Copy link

@MasterHelix9 MasterHelix9 commented Oct 16, 2020

@jujubeesloco Eevee doesn't support headless rendering, because it needs a display to render. You can follow this instruction for render with eevee, this is the easiest way using OpenGL on Colab. (remocolab)

In the tutorial it says to copy colab password and paste it on local machine after ssh command. I did that, then copy-pasted the password and clicked enter and it said 'Access denied' even tough I copy-pasted the correct password. Do you know what might went wrong?

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Oct 16, 2020

@gunboxstudios2020

Hi. If you are savvy you are free to provide updated Version links to this repo. The script above will update once I merge the pull request automatically. My plan was to put some time into it this weekend and atleast update the Version Selector to the most reason one.

@jujubeesloco

This comment has been minimized.

Copy link

@jujubeesloco jujubeesloco commented Oct 16, 2020

@MasterHelix9
I don't think you need those instructions.
Below has been my solution. Taken from closed issues: donmahallem/colab_blender#1

----Rendering EEVEE headless------>
(Note: Replace CYCLES with BLENDER_EEVEE)

!apt-get install python-opengl -y

!apt install xvfb -y

!pip install pyvirtualdisplay

!pip install piglet

from pyvirtualdisplay import Display
Display().start()

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Oct 17, 2020

@gunboxstudios2020 and anyone else who wants 2.90(.1) support would you mind testing the changed script, before I merge it:
https://github.com/donmahallem/colab_blender/blob/blender_2.90.1/runblender.ipynb
and comment at:
donmahallem/colab_blender#11

@MasterHelix9

This comment has been minimized.

Copy link

@MasterHelix9 MasterHelix9 commented Oct 17, 2020

@MasterHelix9
I don't think you need those instructions.
Below has been my solution. Taken from closed issues: donmahallem/colab_blender#1

----Rendering EEVEE headless------>
(Note: Replace CYCLES with BLENDER_EEVEE)

!apt-get install python-opengl -y

!apt install xvfb -y

!pip install pyvirtualdisplay

!pip install piglet

from pyvirtualdisplay import Display
Display().start()

Where should I put that part of the code and/or how would the full code look like?

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Oct 17, 2020

@MasterHelix9 this part should be placed in a code cell anywhere before the actual rendering is invoked. So just add it at the very start.

@MasterHelix9

This comment has been minimized.

Copy link

@MasterHelix9 MasterHelix9 commented Oct 18, 2020

@MasterHelix9 this part should be placed in a code cell anywhere before the actual rendering is invoked. So just add it at the very start.
Should I then paste your code after that? Do I need to paste just the "Rendering Eevee headless" section at the beggining?

@jujubeesloco

This comment has been minimized.

Copy link

@jujubeesloco jujubeesloco commented Oct 18, 2020

@MasterHelix9

Just add it before this(the invoking of the render):

!sudo ./$blender_version/blender -P './setgpu.py' -b '/gdrive/My Drive/{path_to_blend}' -E CYCLES -o '/gdrive/My Drive/{output_path}' -a

‐------------

And remember to replace CYCLES with BLENDER_EEVEE in the above.

@MasterHelix9

This comment has been minimized.

Copy link

@MasterHelix9 MasterHelix9 commented Oct 18, 2020

@jujubeesloco @donmahallem
Thank you for your help!

@MasterHelix9

This comment has been minimized.

Copy link

@MasterHelix9 MasterHelix9 commented Oct 20, 2020

Is it possible to change active camera and scene while rendering?

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Oct 20, 2020

Absolutely. You just need to extend the the quoted python script and select programmatically the camera and scene you prefer

@MasterHelix9

This comment has been minimized.

Copy link

@MasterHelix9 MasterHelix9 commented Oct 21, 2020

Absolutely. You just need to extend the the quoted python script and select programmatically the camera and scene you prefer

@donmahallem What's the code to do that?

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Oct 21, 2020

@MasterHelix9 I would refer you to google, stack overflow and the current Blender Api Documentation.

It all depends on what you are trying to accomplish. Otherwise you would have to do that manually by rendering just the frames you need and switch out the file

@MasterHelix9

This comment has been minimized.

Copy link

@MasterHelix9 MasterHelix9 commented Oct 21, 2020

@donamhallem I have multiple cameras in my scene and they should render same frames but from different angles, so I need a way to switch between cameras inside google colab without having to change active camera in project file and reuploading it again every time. I found a command that can do that: bpy.context.scene.camera = bpy.data.objects["camera_name"] Do I need to import or install any extra modules to google colab for this to work?

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Oct 21, 2020

The only other way I see is switching the camera of the scene as described above or create multiple linked scenes with a camera for each one.

Imho: it's easier just to reupload the changed active camera imho and render everything twice as you multiply the render time anyway with the camera count.

@MasterHelix9

This comment has been minimized.

Copy link

@MasterHelix9 MasterHelix9 commented Oct 21, 2020

@donmahallem If I want to use this command: bpy.context.scene.camera = bpy.data.objects["camera_name"] do I need to install/import any extra modules (bpy) to the google colab?

@donmahallem

This comment has been minimized.

Copy link
Owner Author

@donmahallem donmahallem commented Oct 21, 2020

Afaik no.

For reference you can use the documentation linked above where you can look up available interfaces for any given blender version and which instructions to use.

In the gist above there is a section which uses and launches a small python script as well.

I am currently only on the phone and can only give coarse directions where you need to look. Try the script locally for switching the cams. Either embed it into the blend file(might be prone to issues) or queue it after the blend file loading with a '-P' cli argument.

From what I understood you want to do the easiest imho is still to render all frames for one camera. Switch active camera and render all frames again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.