Closed gioarma closed 8 months ago
Hi @gioarma ,
I would recommend setting the DRJIT_LIBLLVM_PATH
Windows environment variable. As an example
It worked, thanks!
Hello, I have to reopen this because lately I'm getting again this error, despite having set the DRJIT_LIBLLVM_PATH
variable.
When I run
import mitsuba as mi
I get this popup window error. Sorry, it's in Italian, I hope you can understand the point of the error.
I can press "OK" and go on using for example a cuda
version, and everything runs just fine. But if I set a llvm
version I get the usual error asking to set the DRJIT_LIBLLVM_PATH
variable, which I already did.
mi.set_variant('llvm_ad_rgb')
Output:
AttributeError: jit_init_thread_state(): the LLVM backend is inactive because the LLVM shared library ("LLVM-C.dll") could not be found! Set the DRJIT_LIBLLVM_PATH environment variable to specify its path.
Any idea on how to solve the issue?
Hi @gioarma ,
After a bit of trial and error I was able to reproduce this on my Windows machine. It was an error on my part - you'll need to set your environment variable DRJIT_LIBLLVM_PATH
to the dll not the import library (i.e. DRJIT_LIBLLVM_PATH=C:\Program Files\LLVM\bin\LLVM-C.dll
). Hopefully that should then work.
I`m also confused by this issue in win10, the environment variable is set and checked, but " ("LLVM-C.dll") could not be found" issue is got each time when import sionna:
code: import os file = os.environ['DRJIT_LIBLLVM_PATH'] print('file:',file,'exist:',os.path.exists(file)) import sionna
output: file: C:\Program Files\LLVM\bin\LLVM-C.dll exist: True ...... AttributeError: jit_init_thread_state(): the LLVM backend is inactive because the LLVM shared library ("LLVM-C.dll") could not be found! Set the DRJIT_LIBLLVM_PATH environment variable to specify its path.
Hi @tomajuru ,
My guess is that while LLVM-C.dll
was found there may be other DLL dependencies that couldn't be resolved when attempting to load the library. Perhaps just double-check that the %PATH
environment variable has also been modified to include the LLVM directory. I think with the LLVM Windows installer there's a checkbox to do this for you as part of the installation.
Hello @rtabbara,
After setting DRJIT_LIBLLVM_PATH=C:\Program Files\LLVM\bin\LLVM-C.dll
and restarting the PC, I don't see the error anymore. Thanks a lot!
Hi @rtabbara
Thank you for your quick response.
the checkbox to add LLVM to path in LLVM Windows installer is checked. but no LLVM path is added to %PATH%
. So I added LLVM path to %PATH%
manually .
But the ("LLVM-C.dll") could not be found issue is still triggered when import sionna.
Any idea on how to solve the issue? thank you
siona Release v0.15.0, LLVM-17.0.5-win64 Code:
import os
import re
file = os.environ['DRJIT_LIBLLVM_PATH']
print('file:',file,'exist:',os.path.exists(file))
pattern = r'C:[a-zA-Z\\ ]*\\LLVM[a-zA-Z\\ ]*;'
print(*re.findall(pattern,os.environ['path']))
import sionna
Output:
file: C:\Program Files\LLVM\bin\LLVM-C.dll exist: True
C:\Program Files\LLVM\lib; C:\Program Files\LLVM\bin; C:\Program Files\LLVM;
WARNING:tensorflow:From C:\ProgramData\anaconda3\envs\Sionna\lib\site-packages\keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
File C:\ProgramData\anaconda3\envs\Sionna\lib\site-packages\mitsuba\__init__.py:107, in MitsubaVariantModule.__getattribute__(self, key)
104 with _dr.scoped_rtld_deepbind():
105 modules = (
106 _import('mitsuba.mitsuba_ext'),
--> 107 _import('mitsuba.mitsuba_' + variant + '_ext'),
108 )
110 super().__setattr__('_modules', modules)
File C:\ProgramData\anaconda3\envs\Sionna\lib\importlib\__init__.py:127, in import_module(name, package)
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
File <frozen importlib._bootstrap>:1030, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:1007, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:986, in _find_and_load_unlocked(name, import_)
File <frozen importlib._bootstrap>:666, in _load_unlocked(spec)
File <frozen importlib._bootstrap>:565, in module_from_spec(spec)
File <frozen importlib._bootstrap_external>:1173, in create_module(self, spec)
File <frozen importlib._bootstrap>:228, in _call_with_frames_removed(f, *args, **kwds)
ImportError: jit_init_thread_state(): the LLVM backend is inactive because the LLVM shared library ("LLVM-C.dll") could not be found! Set the DRJIT_LIBLLVM_PATH environment variable to specify its path.
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
Cell In[1], line 7
5 pattern = r'C:[a-zA-Z\\ ]*\\LLVM[a-zA-Z\\ ]*;'
6 print(*re.findall(pattern,os.environ['path']))
----> 7 import sionna
File C:\ProgramData\anaconda3\envs\Sionna\lib\site-packages\sionna\__init__.py:19
17 from . import channel
18 from . import signal
---> 19 from . import rt
20 from .config import *
22 # Instantiate global configuration object
File C:\ProgramData\anaconda3\envs\Sionna\lib\site-packages\sionna\rt\__init__.py:24
22 mi.set_variant('cuda_ad_rgb')
23 else:
---> 24 mi.set_variant('llvm_ad_rgb')
26 ############################################
27 # Objects available to the user
28 ############################################
29 # pylint: disable=wrong-import-position
30 from .scene import load_scene, Scene
File C:\ProgramData\anaconda3\envs\Sionna\lib\site-packages\mitsuba\__init__.py:317, in MitsubaModule.set_variant(self, *args)
315 _reload(_sys.modules['mitsuba.ad.integrators'])
316 else:
--> 317 _import('mitsuba.ad.integrators')
318 del sys
File C:\ProgramData\anaconda3\envs\Sionna\lib\importlib\__init__.py:127, in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
File C:\ProgramData\anaconda3\envs\Sionna\lib\site-packages\mitsuba/python\ad\__init__.py:2
1 from .largesteps import LargeSteps
----> 2 from .integrators import *
3 from .optimizers import *
4 from .reparam import *
File C:\ProgramData\anaconda3\envs\Sionna\lib\site-packages\mitsuba/python\ad\integrators\__init__.py:25
23 importlib.reload(globals()[name])
24 else:
---> 25 importlib.import_module('mitsuba.ad.integrators.' + name)
27 del name
28 del f
File C:\ProgramData\anaconda3\envs\Sionna\lib\importlib\__init__.py:127, in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
File C:\ProgramData\anaconda3\envs\Sionna\lib\site-packages\mitsuba/python\ad\integrators\common.py:8
4 import drjit as dr
5 import gc
----> 8 class ADIntegrator(mi.CppADIntegrator):
9 """
10 Abstract base class of numerous differentiable integrators in Mitsuba
11
(...)
25 visible surfaces. (Default: 5)
26 """
28 def __init__(self, props = mi.Properties()):
File C:\ProgramData\anaconda3\envs\Sionna\lib\site-packages\mitsuba\__init__.py:253, in MitsubaModule.__getattribute__(self, key)
251 sub_suffix = '' if submodule is None else f'.{submodule}'
252 module = _sys.modules[f'mitsuba.{variant}{sub_suffix}']
--> 253 result = module.__getattribute__(key)
255 # Add set_variant(), variant() and variant modules to the __dict__
256 if submodule is None and key == '__dict__':
File C:\ProgramData\anaconda3\envs\Sionna\lib\site-packages\mitsuba\__init__.py:115, in MitsubaVariantModule.__getattribute__(self, key)
113 raise AttributeError('Mitsuba variant "%s" not found.' % variant)
114 else:
--> 115 raise AttributeError(e)
116 finally:
117 # Remove those modules from _sys.modules as only the
118 # MitsubaVariantModule instance should hold a reference to them.
119 _sys.modules.pop('mitsuba.mitsuba_ext', None)
AttributeError: jit_init_thread_state(): the LLVM backend is inactive because the LLVM shared library ("LLVM-C.dll") could not be found! Set the DRJIT_LIBLLVM_PATH environment variable to specify its path.
I traced the code and found that this issue is triggered by this line :import mitsuba.mitsuba_llvm_ad_rgb_ext
:
the module expected to be importe should be: \Sionna\Lib\site-packages\mitsuba\mitsuba_llvm_ad_rgb_ext.cp39-win_amd64.pyd,
import mitsuba.mitsuba_llvm_ad_rgb_ext
ImportError Traceback (most recent call last)
Cell In[1], line 1
----> 1 import mitsuba.mitsuba_llvm_ad_rgb_ext
ImportError: jit_init_thread_state(): the LLVM backend is inactive because the LLVM shared library ("LLVM-C.dll") could not be found! Set the DRJIT_LIBLLVM_PATH environment variable to specify its path.
Hi @tomajuru
Does this happen when you try to import mitsuba/drjiit directly too ? I doubt sionna
is doing anything weird, but hey :man_shrugging:
You could earlier versions of LLVM too. We try our best to stay compatible with newer versions but that isn't always possible.
The error message is a bit of a blanket statement in Dr.Jit. It is used anytime something goes wrong during the loading of the DLL. It might have found the file, but couldn't load a specific symbol for example. The best way to debug this would be compile the code yourself and put a breakpoint here: https://github.com/mitsuba-renderer/drjit-core/blob/master/src/llvm_api.cpp#L84 (the jitc_llvm_api_init
function should return true
).
Hi @njroussel thanks for your comments.
I tryied only install mitsuba and directly run import mitsuba.mitsuba_llvm_ad_rgb_ext
, the error message is the same.
I tried install mitsuba and llvm and set LLVM path manually on a new PC with win11, the error is the same. BTW, LLVM installer on Windows claims to add self to path environment variable but does not is a known issue.
I run twice import mitsuba.mitsuba_llvm_ad_rgb_ext
and the error does not appear at sencond time . I`m not sure if llvm has loaded successful in this case. but the program run well after import twice.
You should not have to load that package manually it is done implicitly by mitsuba when you do
import mitsuba as mi
mi.set_variant('llvm_ad_rgb')
I run twice import mitsuba.mitsuba_llvm_ad_rgb_ext and the error does not appear at sencond time . I`m not sure if llvm has loaded successful in this case. but the program run well after import twice.
I believe Python caches imported modules. So the second time you import it is effectively a noop. I would therefore think that LLVM still wasn't loaded. Of course, if your program doesn't need it because you're using some other variant like cuda_ad_rgb
it doesn't matter if LLVM was succesfully loaded...
You could earlier versions of LLVM too. We try our best to stay compatible with newer versions but that isn't always possible.
I encountered this issue using LLVM 17.0.6 (28 Nov 2023). I uninstalled that version and installed LLVM 16.0.4 (16 May 2023). This resolved the issue for me. For those looking for a workaround, I'd recommend downgrading to an older version if the previous suggestions don't work.
I'm going to close this issue as the original problem reported by @gioarma has been resolved. Please feel free to open a separate issue if any of the suggested fixes still can't resolve the missing LLVM-C.dll
Hello,
I'm having this issue with the LLVM backend. on a Windows 11 machine. I am installing LLVM using the
LLVM-17.0.1-win64.exe
file. During installation I let the installer adjust the%PATH%
variable, as stated in the docs. If I open a Jupyter Notebook and runEverything works as expected. But, if I run the cell a second time I get the error:
jit_init_thread_state(): the LLVM backend is inactive because the LLVM shared library ("LLVM-C.dll") could not be found! Set the DRJIT_LIBLLVM_PATH environment variable to specify its path.
And then, every further attempt of using LLVM returns this error. So, it seems like the path to the dll is set only temporarily, and not permanently.Do you know what might be wrong during LLVM installation? Or may I solve just manually changing the
DRJIT_LIBLLVM_PATH
variable? If so, where is this variable stored?Thank you