mitsuba-renderer / drjit

Dr.Jit — A Just-In-Time-Compiler for Differentiable Rendering
BSD 3-Clause "New" or "Revised" License
603 stars 45 forks source link

Access violation upon import using Python 3.12 #314

Open lorenzocelli opened 4 days ago

lorenzocelli commented 4 days ago

Hello, I am trying to use Mitsuba and Drjit after installing via pip. After importing drjit, Python crashes due to an access violation:

Python 3.12.7 (tags/v3.12.7:0b05ead, Oct  1 2024, 03:06:41) [MSC v.1941 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import faulthandler
>>> faulthandler.enable()
>>> import drjit
Windows fatal exception: access violation

Current thread 0x000008b8 (most recent call first):
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1289 in create_module
  File "<frozen importlib._bootstrap>", line 813 in module_from_spec
  File "<frozen importlib._bootstrap>", line 921 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1415 in _handle_fromlist
  File "C:\Users\loren\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\drjit\__init__.py", line 5 in <module>
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 995 in exec_module
  File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "<stdin>", line 1 in <module>

Any help on how to further investigate this would be highly appreciated. I am happy to provide further details on my system specs if needed.

Package Version
------- -------
drjit   1.0.1
mitsuba 3.6.0
pip     24.2
rtabbara commented 3 days ago

Hi @lorenzocelli ,

I tried pip installing the latest mitsuba and drjit on our Windows machine with the same Python version as reported and was unable to reproduce the error you're encountering.

In terms of things to try:

Other than that, some more details of your setup might be helpful in order for us to reproduce the error from our side.

wjakob commented 3 days ago

Could it be a processor issue? Potentially our builds are using AVX2 instructions. If your machine is comparatively old (pre-Haswell), it might crash when executing AVX2 instructions.

lorenzocelli commented 3 days ago

Hello! Thank you for your replies. I have tried:

I just checked and my processor (i7-9750h) should support AVX2. My device specifications:

Processor   Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, 2601 Mhz, 6 Core(s), 12 Logical Processor(s)
Installed Physical Memory (RAM) 16.0 GB
System type 64-bit operating system, x64-based processor

OS:

Edition Windows 11 Home
Version 23H2
Installed on    ‎1/‎1/‎2117
OS build    22631.4541

Graphic card:

DirectX version:    12.0 
GPU processor:      NVIDIA GeForce RTX 2070 with Max-Q Design
Driver version:     566.14
Driver Type:        DCH
wjakob commented 3 days ago

Thank you for the followup. Your hardware + OS should be compatible with Mitsuba & Dr.Jit. However, we cannot reproduce the issue on our end, and it's the first time that this kind of import-time crash is reported. It's quite possible that there is an issue in Dr.Jit, but it sounds like something that is highly specific to your machine that others simply haven't run into yet.

Unfortunately, the Python backtrace in your first post does not contain enough information to identify the issue. Could I ask you to clone https://github.com/mitsuba-renderer/drjit and compile it in MSVC (i.e. without WSL -- I am also assuming that the crashes above happened on the Windows command line, not on WSL). In the ideal case, your compiled version will also crash in the same way. Then you could make a debug build and post a screenshot of the C++ backtrace shown by the Visual Studio debugger. This would narrow things down quite a bit.

lorenzocelli commented 2 days ago

Thank you for your suggestions! Here is what I did:

For me the issue is now solved since I will just use the Python packages produced during the build. Let me know if there is anything else you would like me to try in order to figure out the issue with the pip packages. Otherwise, feel free to close the ticket :)

wjakob commented 2 days ago

Did you compile with Visual Studio? If so, what version?

This is really weird, and it would be good to have a data point. One more request: could you install the crashing version and when the crash happens, open it in Visual Studio and send a backtrace? I'm hoping that this will perhaps identify some API function (e.g. Python API) that is involved.