Skip to content

Graalpy not work with numpy in static-linked native-image #464

Closed as not planned

Description

@buuuuuuug

Greetings!!
Graalpy is a wonderful work! You guys are brilliant!! It helped me a lot!
i've been trying to use graalpy in static-linked native-image, basic python functions are completely working perfectly.
but when it comes to numpy , it seems graalpy cannot work properly in static-linked NI.

everytime it runs into numpy code, a error occurs:

Traceback (most recent call last):
  File "Unnamed", line 3, in <module>
  File "/graalpy_vfs/venv/lib/python3.11/site-packages/numpy/__init__.py", line 141, in <module>
    from . import core
  File "/graalpy_vfs/venv/lib/python3.11/site-packages/numpy/core/__init__.py", line 23, in <module>
    from . import multiarray
  File "/graalpy_vfs/venv/lib/python3.11/site-packages/numpy/core/multiarray.py", line 10, in <module>
    from . import overrides
  File "/graalpy_vfs/venv/lib/python3.11/site-packages/numpy/core/overrides.py", line 6, in <module>
    from numpy.core._multiarray_umath import (
SystemError: NFIUnsatisfiedLinkError: Dynamic loading not supported

according to the stacks, i found that the _multiarray_umath is provided with a dynamic lib file.
is it possilble to run numpy code in a static NI with graalpy now?
image

Activity

  1. changed the title [-]Graalpy not work with static-linked native-image[/-] [+]Graalpy not work with numpy in static-linked native-image[/+] on Dec 24, 2024
  2. msimacek commented on Jan 2, 2025

    @msimacek
    Contributor

    Hi @buuuuuuug, unfortunately it's not possible. Python native extensions are compiled as dynamic modules and dynamic module loading can't work with a static libc. That's not specific to GraalPy, statically linked CPython would also not be able to load numpy installed as a module. What might work is mostly-static image with dynamically linked glibc (documentation), but then it would still load the modules and their dependencies as dynamic, which would kinda defeat the purpose of static linking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions