oracle / graalpython

GraalPy – A high-performance embeddable Python 3 runtime for Java
https://www.graalvm.org/python/
Other
1.25k stars 112 forks source link

Use of Linux extension "so" on MacOs instead of "dylib" when loading PyTorch #428

Open mjschnie opened 1 month ago

mjschnie commented 1 month ago

I'm getting a strange error on my MacOS M2 laptop trying to import the PyTorch library from Python code running on a JVM (GraalPy 3.11.7 Oracle GraalVM Native 24.1.0 on openjdk 23 2024-09-17):: org.graalvm.polyglot.PolyglotException: OSError: dlopen( ... ffx_venv/lib/python3.11/site-packages/torch/lib/libtorch_global_deps.so, 0x000A): tried: ... (no such file) The library is in the virtual environment (after using GraalPy pip to install torch), but on MacOS the extension is "dylib" instead of "so". The correct file is available here: ffx_venv/lib/python3.11/site-packages/torch/lib/libtorch_global_deps.dylib Any ideas why the Linux ".so" extension is being used instead of ".dylib"?

msimacek commented 1 month ago

Hi, please try setting python.PosixModuleBackend option to native. If that doesn't help - what torch version is that? Did you use the maven plugin? Does torch work when ran outside JVM with the standalone launcher? Can you post the Java code that is setting up the context?