我正在尝试使用 google colab pro 提供的 GPU 在搅拌机中运行脚本。
我使用以下代码来安装和配置 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
之后,我按如下方式运行我的脚本:
!blender -b -noaudio --python /content/code/generate_images.py -E CYCLES -a --cycles-device CUDA
但它给出了以下错误:
Unable to open a display
脚本 generate_images.py 包含一系列操作(相机和灯光被创建,相机沿着预定义位置的轨迹移动),并且在相机的每个位置渲染图像。我注意到当到达以下行时会出现错误:
bpy.ops.render.render(write_still=True)
该脚本在我的笔记本电脑上本地完美运行。你对这个问题有任何线索吗?