I'm trying to run a script in blender, using the GPU available from google colab pro.
I use the following code to install and configure Blender:
import os
os.environ["LD_PRELOAD"] = ""
!apt remove libtcmalloc-minimal4
!apt install libtcmalloc-minimal4
os.environ["LD_PRELOAD"] = "/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4.3.0"
!wget https://download.blender.org/release/Blender2.93/blender-2.93.0-linux-x64.tar.xz
!tar -xf blender-2.93.0-linux-x64.tar.xz
# if you still get any errors regarding LD_PRELOAD you can check whether a good path is applied (if the version of library has not changed)
!dpkg -L libtcmalloc-minimal4
!ln -s /content/blender-2.93.0-stable+blender-v293-release.84da05a8b806-linux.x86_64-release/blender /usr/local/bin/blender
!blender -v
After that, I run my script as follows:
!blender -b -noaudio --python /content/code/generate_images.py -E CYCLES -a --cycles-device CUDA
But it gives the following error:
Unable to open a display
The script generate_images.py contains a series of operations (camera and light are created, and the camera is moved along a trajectory of pre-defined positions), and at each position of the camera an image is rendered. I noticed that the error arises when the the following line is reached:
bpy.ops.render.render(write_still=True)
The script runs perfectly locally on my laptop. Do you have any clue about the problem?