Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading numpy-array attributes broken with numpy>2.0.0 with RockyLinux 9 #4287

Open
jorgensd opened this issue Aug 4, 2024 · 0 comments
Open

Comments

@jorgensd
Copy link

jorgensd commented Aug 4, 2024

I have the following minimal script that writes a numpy array as an attribute in adios2, and in turn read it into the code again:

import adios2.bindings as adios2
from mpi4py import MPI
import numpy as np

engine = "BP5"
filename = "test.bp"

adios = adios2.ADIOS(MPI.COMM_WORLD)

io = adios.DeclareIO("writer")

out_data = np.array([13, 11, 7, 5], dtype=np.int32)

# Write array to file as attribute
io.SetEngine(engine)
adios_file = io.Open(str(filename), adios2.Mode.Write, MPI.COMM_WORLD)
adios_file.BeginStep()
io.DefineAttribute("data", out_data)
adios_file.PerformPuts()
adios_file.EndStep()
adios_file.Close()
adios.RemoveIO("writer")

# Read array from file as attribute
io = adios.DeclareIO("reader")
io.SetEngine(engine)
adios_file = io.Open(str(filename), adios2.Mode.Read, MPI.COMM_WORLD)
adios_file.BeginStep()
attr = io.InquireAttribute("data")
in_data = attr.Data()
adios_file.EndStep()
adios_file.Close()
adios.RemoveIO("reader")

np.testing.assert_array_equal(out_data, in_data)

This works fine with rockylinux 9:

FROM rockylinux/rockylinux:9

ARG ADIOS2_VERSION=v2.10.1

ARG NUMPY_VERSION=1.26.4
ARG MPICH_VERSION=4.2.2
WORKDIR /tmp



RUN dnf -y update && \
    dnf install -y dnf-plugins-core && \
    dnf config-manager --set-enabled crb && \
    dnf install -y epel-release && \
    dnf -y install \
    cmake \
    gcc \
    gcc-c++ \
    gcc-gfortran \
    pugixml-devel \
    python3 \
    python3-devel \
    python3-pip \
    spdlog-devel \
    # Utility
    git \
    # Only in crb set
    ninja-build \
    openblas-devel && \
    dnf -y clean all && \
    rm -rf /var/cache

# Build MPICH (see https://github.com/pmodels/mpich/issues/5811)
RUN curl -L -O https://www.mpich.org/static/downloads/${MPICH_VERSION}/mpich-${MPICH_VERSION}.tar.gz && \
    tar -xf mpich-${MPICH_VERSION}.tar.gz && \
    cd mpich-${MPICH_VERSION} && \
    FCFLAGS=-fallow-argument-mismatch FFLAGS=-fallow-argument-mismatch ./configure --with-device=ch4:ofi --enable-shared --prefix=/usr/local && \
    make -j 4 install && \
    rm -rf /tmp/*

# Install numpy and Mpi4py
RUN python3 -m pip install numpy==${NUMPY_VERSION} mpi4py


# BUILD ADIOS2
RUN git clone --branch=${ADIOS2_VERSION} --single-branch https://github.com/ornladios/ADIOS2.git adios2 && \
    cmake -G Ninja -DADIOS2_USE_HDF5=off -DADIOS2_USE_Python=on -DADIOS2_USE_Fortran=off -DBUILD_TESTING=off -DADIOS2_BUILD_EXAMPLES=off -DADIOS2_USE_ZeroMQ=off -B build-dir-adios2 -S ./adios2 && \
    cmake -G Ninja -B build-dir-adios2 -DCMAKE_BUILD_TYPE="Release" -S ./adios2/ && \
    cmake --build build-dir-adios2 --parallel 2 && \
    cmake --install build-dir-adios2


WORKDIR /src/test/
COPY mwe.py mwe.py
RUN python3 mwe.py

RUN bpls -a -l test.bp

which you can build with:

 docker build -t adios2_image --build-arg="NUMPY_VERSION=1.26.4" . --progress=plain

However, using numpy 2.0.1, one gets

 docker build -t adios2_image --build-arg="NUMPY_VERSION=2.0.1" . --progress=plain

with the following traceback

> [ 9/10] RUN python3 mwe.py:
1.777   File "/usr/local/lib64/python3.9/site-packages/numpy/testing/_private/utils.py", line 885, in assert_array_compare
1.777     raise AssertionError(msg)
1.777 AssertionError: 
1.777 Arrays are not equal
1.777 
1.777 Mismatched elements: 3 / 4 (75%)
1.777 Max absolute difference among violations: 8
1.777 Max relative difference among violations: 0.61538462
1.777  ACTUAL: array([13, 11,  7,  5], dtype=int32)
1.777  DESIRED: array([13, 13, 13, 13], dtype=int32)
------
Dockerfile:55
--------------------
  53 |     WORKDIR /src/test/
  54 |     COPY mwe.py mwe.py
  55 | >>> RUN python3 mwe.py
  56 |     
  57 |     RUN bpls -a -l test.bp
--------------------
ERROR: failed to solve: process "/bin/sh -c python3 mwe.py" did not complete successfully: exit code: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant