You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
numpy 1.25.0 fails with illegal instruction in aws batch #24028
import numpy 1.25.0 in a task running in aws-batch fails with illegal instruction but runs locally.
python version: 3.10.11
working numpy version: 1.24.3
not working numpy version: 1.25.0
AWS batch is configured to use the following instance types:
m6g
r6g
c7g
Error message:
bash: line 1: 47 Illegal instruction (core dumped) ( python -u src-metrics-flows-test.py --quiet --metadata se
Unfortunately due to running in AWS batch we are not able to get the core dump currently.
Additional information:
Roll back to 1.24.3 and it works again without us changing any code. I would hazard an un-scientific guess that this could be related to the build work thats been going on.
Can you help us by saying what type of machines these are? I guess graviton? Also, getting the output of np.show_runtime() is likely necessary to narrow this down.
How exactly did you install/build numpy?
this could be related to the build work thats been going on.
The build work shouldn't affect the released versions of NumPy, although it could be a build issue. Another possibility is incorrect runtime CPU detection, that sometimes happens in virtual machines for example.
A quick update, it seems to be the 7g series that cause the problem, but due to having both 6g and 7g nodes available it has become intermittent triggering this one.
I'll update with the results from a c7g node when I can get them
I am seeing what I believe to be the same issue. I'm also using c7g instances on AWS Batch (EDIT: uses Graviton3). I upgraded from 1.24.3 to 1.25.1 today and all my AWS Batch jobs are failing with exit code 132, which based on some searching seems like is related to invalid instructions. Reverting to 1.24.3 resolved the issue. I instrumented my application to add the following to the entrypoint:
import numpy as np
np.show_runtime()
For context, I'm installing numpy via pip as part of the docker image build process (i.e., I don't build numpy from source). If it's helpful, the docker image is built on an M1 Macbook Pro running Docker Engine v24.0.2.
For 1.24.3 running on c7g instances on AWS Batch, I get the following output:
There are two unrelated systems to use advanced SIMD instructions in NumPy. One is builtin, and is reported in the simd_extensions section. The other is via OpenBLAS, which has its own runtime dispatch and is reflected in the architecture section.
Could you try limiting the simd_extension runtime dispatch by adding export NPY_DISABLE_CPU_FEATURES="ASIMDHP, ASIMDDP,ASIMDFHM" to the image? If you do this with the successful run of 1.24.3, you should see that change reflected in the simd_extensions entry of the np.show_runtime() output.
If that does not work, the problem might be with OpenBLAS (although I think this is less likely). Its dispatch can be controlled by adding export OPENBLAS_CORETYPE=ARMV8. If you do this with the successful run of 1.24.3, you should see that change reflected in the architecture entry of the np.show_runtime() output.
Quickly spun up a c7g ec2 instance to test outside of a docker container. Test consisted of creating a virtual env, and installing numpy, and running the python repl.
Hmm. Outside the container, you can use NumPy 1.25.1. Inside the container, you get an illegal instruction. Perhaps you are pulling in the macos wheel for numpy when building the container, instead of the linux aarch64 one?
Hmm. Outside the container, you can use NumPy 1.25.1. Inside the container, you get an illegal instruction. Perhaps you are pulling in the macos wheel for numpy when building the container, instead of the linux aarch64 one?
I'm not sure how to check that. However, I was able to run the same image directly on the c7g EC2 instance that fails on AWS Batch. Here is the output:
It occurs to me that we (OpenBLAS) are naively expecting SVE to be available if the detected cpu is known to support it (there's currently no fine-grained checking of hwcap, unlike other platforms) , maybe that is not always a given with containers ?
If you could add a call to lscpu or something to print the contents of /proc/cpuinfo (if available) to see if "sve" shows up among the feature flags that would be great
@martin-frbg I was able to run the following directly on the host as well as instrument the container to run the following on entry.
TL;DR
It looks like your hunch was correct, SVE does **not ** appear in the AWS Batch processor feature list, although it does appear when running the commands directly on the host as well as in the image running on Docker.
Note that the same image is used when testing Docker via running on the host C7G instance and AWS Batch.
That would mean you could only run with OPENBLAS_CORETYPE=NEOVERSEN1 on AWS Batch, unless AWS support can
tell if/how to enable SVE with AWS Batch. (Without SVE enabled, you might as well use one of the Graviton2 instances which are possibly cheaper)
Activity
seberg commentedon Jun 23, 2023
Can you help us by saying what type of machines these are? I guess graviton? Also, getting the output of
np.show_runtime()is likely necessary to narrow this down.How exactly did you install/build numpy?
The build work shouldn't affect the released versions of NumPy, although it could be a build issue. Another possibility is incorrect runtime CPU detection, that sometimes happens in virtual machines for example.
emilyselwood commentedon Jun 27, 2023
A quick update, it seems to be the 7g series that cause the problem, but due to having both 6g and 7g nodes available it has become intermittent triggering this one.
I'll update with the results from a c7g node when I can get them
seberg commentedon Jun 27, 2023
Thanks, in that case, it may be good to see the difference between the two also (if there is any).
james-takeone commentedon Jul 13, 2023
I am seeing what I believe to be the same issue. I'm also using
c7ginstances on AWS Batch (EDIT: uses Graviton3). I upgraded from1.24.3to1.25.1today and all my AWS Batch jobs are failing with exit code 132, which based on some searching seems like is related to invalid instructions. Reverting to1.24.3resolved the issue. I instrumented my application to add the following to the entrypoint:For context, I'm installing
numpyvia pip as part of the docker image build process (i.e., I don't buildnumpyfrom source). If it's helpful, the docker image is built on an M1 Macbook Pro running Docker Engine v24.0.2.For
1.24.3running onc7ginstances on AWS Batch, I get the following output:For
1.25.1c7ginstances on AWS Batch, the container exits with code 132 prior to printing anything.For
1.24.3running on my M1 Macbook Pro, I get the following output:For
1.25.1running on my M1 Macbook Pro, I get the following output:mattip commentedon Jul 13, 2023
There are two unrelated systems to use advanced SIMD instructions in NumPy. One is builtin, and is reported in the
simd_extensionssection. The other is via OpenBLAS, which has its own runtime dispatch and is reflected in thearchitecturesection.Could you try limiting the
simd_extensionruntime dispatch by addingexport NPY_DISABLE_CPU_FEATURES="ASIMDHP, ASIMDDP,ASIMDFHM"to the image? If you do this with the successful run of 1.24.3, you should see that change reflected in thesimd_extensionsentry of thenp.show_runtime()output.If that does not work, the problem might be with OpenBLAS (although I think this is less likely). Its dispatch can be controlled by adding
export OPENBLAS_CORETYPE=ARMV8. If you do this with the successful run of 1.24.3, you should see that change reflected in thearchitectureentry of thenp.show_runtime()output.james-takeone commentedon Jul 13, 2023
Quickly spun up a
c7gec2 instance to test outside of a docker container. Test consisted of creating a virtual env, and installing numpy, and running the python repl.Here's the output for
1.24.3:Here's the output for
1.25.1:james-takeone commentedon Jul 13, 2023
Thanks @mattip, I'll give that a shot tomorrow and report back.
mattip commentedon Jul 13, 2023
Hmm. Outside the container, you can use NumPy 1.25.1. Inside the container, you get an illegal instruction. Perhaps you are pulling in the macos wheel for numpy when building the container, instead of the linux aarch64 one?
james-takeone commentedon Jul 13, 2023
I'm not sure how to check that. However, I was able to run the same image directly on the
c7gEC2 instance that fails on AWS Batch. Here is the output:I'm a bit out of my depth now, so I'm going to reach out to AWS business support for some assistance. Thanks for your help @mattip!
martin-frbg commentedon Jul 18, 2023
It occurs to me that we (OpenBLAS) are naively expecting SVE to be available if the detected cpu is known to support it (there's currently no fine-grained checking of hwcap, unlike other platforms) , maybe that is not always a given with containers ?
james-takeone commentedon Jul 18, 2023
@martin-frbg Is there anything that I can do / add to our container to help debug this?
martin-frbg commentedon Jul 18, 2023
If you could add a call to
lscpuor something to print the contents of /proc/cpuinfo (if available) to see if "sve" shows up among the feature flags that would be greatjames-takeone commentedon Jul 18, 2023
@martin-frbg I was able to run the following directly on the host as well as instrument the container to run the following on entry.
TL;DR
It looks like your hunch was correct, SVE does **not ** appear in the AWS Batch processor feature list, although it does appear when running the commands directly on the host as well as in the image running on Docker.
Note that the same image is used when testing Docker via running on the host C7G instance and AWS Batch.
Here are the results:
Directly on the host C7G EC2 instance:
Docker running on the C7G EC2 Instance:
AWS Batch running on a C7G instance:
martin-frbg commentedon Jul 19, 2023
That would mean you could only run with OPENBLAS_CORETYPE=NEOVERSEN1 on AWS Batch, unless AWS support can
tell if/how to enable SVE with AWS Batch. (Without SVE enabled, you might as well use one of the Graviton2 instances which are possibly cheaper)
29 remaining items
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr
chore: Rebuild devctr