graalpython icon indicating copy to clipboard operation
graalpython copied to clipboard

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

Open mjschnie opened this issue 1 year ago • 1 comments

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"?

mjschnie avatar Oct 01 '24 17:10 mjschnie

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?

msimacek avatar Oct 02 '24 09:10 msimacek