mitsuba-renderer / mitsuba3

Mitsuba 3: A Retargetable Forward and Inverse Renderer
https://www.mitsuba-renderer.org/
Other
2.1k stars 246 forks source link

Resource deadlock would occur error when using mitsuba.load_file() #1105

Closed PhilSoy closed 7 months ago

PhilSoy commented 8 months ago

Summary

I get an error message when opening a scene imported from Blender with mitsuba.load_file(). Error occurs with mi.set_variant("cuda_ad_rgb") as well as with mi.set_variant('llvm_ad_rgb')

System configuration

System information:

OS: ...Windows 10 Enterprise CPU: ...13th Gen Intel(R) Core(TM) i5-1345U 1.60 GHz GPU: ... Python version: ...Spyder version: 5.4.3 (conda), Python version: 3.11.7 64-bit, Qt version: 5.15.2, * PyQt5 version: 5.15.10 LLVM version: ... LLVM backend LLVM-18.1.0-win64 CUDA version: ... NVidia driver: ...

Dr.Jit version: ..0.4.4.mitsuba 3.5.0
Mitsuba version: ... 3.5.0 Compiled with: ... Variants compiled: ...

Description

I get an error message when opening a scene imported from Blender with mitsuba.load_file(). Error occurs with mitsuba.set_variant("cuda_ad_rgb") as well as with mitsuba.set_variant('llvm_ad_rgb'). I can load with the scalar_rgb option, but this is not enough for Sionna My end goal is to import scenes with Sionna. Sionna requires llvm_as_rgb or cuda_ad_rgb to work (according to a Sionna expert). We managed to isolate the problem. It looks like the issue is on the mitsuba side.

Here are the Python script I used as well as the imported xml and mesh files imported (note that the same problem occurs with any imported file): Etoile.zip anothertestscript.zip

Steps to reproduce

  1. ...just run the script
  2. ...
PhilSoy commented 8 months ago

The problem magically disappeared after modifying DRJIT_LIBLLVM_PATH environment variable. from: C:\Program Files\LLVM\bin\ to: C:\Program Files\LLVM\bin\LLVM-C.dll in other terms, the environment variable should point to the file itself and not to the parent folder. This is quite unusual, but fortunately solved the problem which blocked me for several days

merlinND commented 8 months ago

Hello @PhilSoy,

Thanks for your report, and glad to see that you found a solution (although I agree that it is very counter-intuitive). For convenience, I am pasting the script that you shared:

# -*- coding: utf-8 -*-
"""
Created on Thu Mar 14 10:21:26 2024

@author: sehier1
"""

import mitsuba as mi

mi.set_variant("cuda_ad_rgb")  #--> does not work 
#mi.set_variant('scalar_rgb') --> works
mi.set_variant('llvm_ad_rgb') # crashes 'resource deadlock would occur'
scene=mi.load_file("etoile/etoile.xml")
print(scene)

# Versions:
#   mitsuba                           3.5.0
#   drjit                             0.4.4
#   LLVM backend LLVM-18.1.0-win64

This issue with DRJIT_LIBLLVM_PATH on Windows has tripped up quite a few people (although I don't think it ever manifested as a "resource deadlock would occur" exception).

@njroussel, do you think it would be possible to explicitly check that the env variable points to the DLL directly when set on Windows, and throw otherwise?

njroussel commented 7 months ago

Hi!

@merlinND I'll add that to Dr.Jit and update the Windows installation information. I think LLVM moved LLVM-C.dll to a subdirectory in recent versions, so even when ticking the "Add to %PATH%" box during installation, the DLL isn't automatically picked up anymore.