bionanopatterning / Ais

5 stars 0 forks source link

Pip install leads to AttributeError: _ARRAY_API not found #2

Open wlugmayr opened 1 month ago

wlugmayr commented 1 month ago

I did a fresh install of the latest 1.0.26 pip package with python3.9 and when starting Ais the following error appears:

A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.1 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last): File "/gpfs/cssb/software/rhel9/anaconda3/envs/ais-1.0.26/bin/ais", line 5, in from Ais.main import main File "/gpfs/cssb/software/rhel9/anaconda3/envs/ais-1.0.26/lib/python3.9/site-packages/Ais/main.py", line 5, in from Ais.core.segmentation_editor import File "/gpfs/cssb/software/rhel9/anaconda3/envs/ais-1.0.26/lib/python3.9/site-packages/Ais/core/segmentation_editor.py", line 7, in from Ais.core.se_model import File "/gpfs/cssb/software/rhel9/anaconda3/envs/ais-1.0.26/lib/python3.9/site-packages/Ais/core/se_model.py", line 1, in from tensorflow.keras.callbacks import Callback File "/gpfs/cssb/software/rhel9/anaconda3/envs/ais-1.0.26/lib/python3.9/site-packages/tensorflow/init.py", line 37, in from tensorflow.python.tools import module_util as _module_util File "/gpfs/cssb/software/rhel9/anaconda3/envs/ais-1.0.26/lib/python3.9/site-packages/tensorflow/python/init.py", line 37, in from tensorflow.python.eager import context File "/gpfs/cssb/software/rhel9/anaconda3/envs/ais-1.0.26/lib/python3.9/site-packages/tensorflow/python/eager/context.py", line 35, in from tensorflow.python.client import pywrap_tf_session File "/gpfs/cssb/software/rhel9/anaconda3/envs/ais-1.0.26/lib/python3.9/site-packages/tensorflow/python/client/pywrap_tf_session.py", line 19, in from tensorflow.python.client._pywrap_tf_session import * AttributeError: _ARRAY_API not found

bionanopatterning commented 1 month ago

Hi, thanks again for sharing an issue!

We hadn't taken the recent release of numpy 2.0 in to account in requirements.txt yet. Now we do, and with that I've uploaded 1.0.28 to pip (guess I should have waited a little bit longer with uploading 1.0.27 earlier today...)

You can either install Ais-cryoET==1.0.28 or manually downgrade to numpy<2 (pip install "numpy>=1.23.2,<2.0") to avoid the problem you were having.

Best, Mart

wlugmayr commented 1 month ago

Hi,

making a fresh new installation of 1.0.28 did not solve the issue but the pip downgrade: pip install "numpy>=1.23.2,<2.0"

But now I get when I start the software: X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 151 () Minor opcode of failed request: 7 Value in failed request: 0x51e Serial number of failed request: 100 Current serial number in output stream: 100

We use FastX3 as "virtual desktop" and v1.0.23 was running with the additional environment setting: VGL_DISPLAY

wlugmayr commented 1 month ago

I used now the existing, working 1.0.23 environment and upgraded: pip install Ais-cryoET==1.0.28 ... Installing collected packages: Ais-cryoET Attempting uninstall: Ais-cryoET Found existing installation: Ais-cryoET 1.0.23 Uninstalling Ais-cryoET-1.0.23: Successfully uninstalled Ais-cryoET-1.0.23 Successfully installed Ais-cryoET-1.0.28

But when I start it, the gui comes up but says File -> version 1.0.27?

bionanopatterning commented 1 month ago

Oops, the "File -> version 1.0.27" text is not right; I just checked and noticed I forgot to update the version number in one place (there are three separate fields that need to be edited), but you are in fact on 1.0.28 if you updated with pip to ==1.0.28. In trying to get the fixes out quickly I forgot to edit the version number that pops up in the File menu.

Does your second comment mean that the previous error with FastX3 'X Error of failed request: BadValue (integer parameter out of range for operation) [etc.]' is not occurring any more?

wlugmayr commented 1 month ago

I updated the existing conda env made in march 2024. there the error does not appear. but with a fresh conda and 1.0.28 its now happening. shall i post you the pip list?

bionanopatterning commented 1 month ago

Yes please, that would be very helpful :)

wlugmayr commented 1 month ago

maybe the opengl package?

Package Version


absl-py 2.1.0 Ais-cryoET 1.0.28 astunparse 1.6.3 cachetools 5.3.3 certifi 2024.2.2 charset-normalizer 3.3.2 dill 0.3.8 flatbuffers 24.3.25 gast 0.5.4 glfw 2.7.0 google-auth 2.29.0 google-auth-oauthlib 0.4.6 google-pasta 0.2.0 grpcio 1.62.1 h5py 3.10.0 idna 3.6 imageio 2.34.0 imgui 2.0.0 importlib_metadata 7.1.0 keras 2.8.0 Keras-Preprocessing 1.1.2 lazy_loader 0.4 libclang 18.1.1 Markdown 3.6 MarkupSafe 2.1.5 mrcfile 1.5.0 networkx 3.2.1 numpy 1.26.4 oauthlib 3.2.2 opt-einsum 3.3.0 packaging 24.0 pillow 10.3.0 pip 24.0 protobuf 3.20.0 pyasn1 0.6.0 pyasn1_modules 0.4.0 PyOpenGL 3.1.7 pyperclip 1.8.2 requests 2.31.0 requests-oauthlib 2.0.0 rsa 4.9 scikit-image 0.22.0 scipy 1.13.0 setuptools 69.2.0 six 1.16.0 tensorboard 2.8.0 tensorboard-data-server 0.6.1 tensorboard-plugin-wit 1.8.1 tensorflow 2.8.0 tensorflow-io-gcs-filesystem 0.36.0 termcolor 2.4.0 tf-estimator-nightly 2.8.0.dev2021122109 tifffile 2024.2.12 typing_extensions 4.11.0 urllib3 2.2.1 Werkzeug 3.0.2 wheel 0.43.0 wrapt 1.16.0 zipp 3.18.1

bionanopatterning commented 1 month ago

Yep, OpenGL could be the issue, but this is a bit hard hard for me to figure out from here. Do you use the same VGL_DISPLAY setting in both environments?

There was someone before who also ran in to a problem with OpenGL on a virtual desktop Linux cluster that used llvmpipe for rendering. I was able to trace the issue down to just OpenGL, but not to solve it. If you want, you could try to run this script in the environment where you're getting the FastX3 error:

import glfw
from OpenGL.GL import *

def main():
    if not glfw.init():
        return

    window = glfw.create_window(512, 512, "OpenGL Test Window", None, None)
    if not window:
        glfw.terminate()
        return

    glfw.make_context_current(window)

    while not glfw.window_should_close(window):
        glClear(GL_COLOR_BUFFER_BIT)
        glBegin(GL_TRIANGLES)
        glColor3f(1.0, 0.0, 0.0)
        glVertex3f(-0.6, -0.4, 0.0)
        glColor3f(0.0, 1.0, 0.0)
        glVertex3f(0.6, -0.4, 0.0)
        glColor3f(0.0, 0.0, 1.0)
        glVertex3f(0.0, 0.6, 0.0)
        glEnd()

        glfw.swap_buffers(window)

        glfw.poll_events()

    glfw.terminate()

if __name__ == "__main__":
    main()

If it doesn't work, there is indeed a problem with OpenGL.

But if I understand correctly you do have a working installation of Ais 1.0.28 now?

wlugmayr commented 1 month ago

so it works now as: pip install ais-cryoet pip install "numpy>=1.23.2,<2.0"

and we run it like vglrun /fullpath/ais

bionanopatterning commented 1 month ago

Okay, I think I'll close this issue for now then as the numpy>=1.23.2,<2.0 is in the new requirements.txt and should be automatic with 1.0.28. The OpenGL version is specified as 3.1.6 but 3.1.7 also works for me on both Windows and Debian.

If there are no differences between your two environments and vglrun is used in both cases then I remain confused why it does run in the one but not in the other but... if it works it works.

bionanopatterning commented 1 month ago

actually I will leave it open so that it is easier for others to find.