Python "numpy.core._exceptions._ArrayMemoryError" in CI
NumPy tried to allocate a contiguous block bigger than the memory available on the runner. The shape and dtype imply a buffer the constrained CI box cannot provide, so the allocation fails outright.
What this error means
A NumPy operation aborts with numpy.core._exceptions._ArrayMemoryError: Unable to allocate X GiB for an array with shape (...) and data type Y. It is reproducible for the same input size and tied to the runner’s memory, not the network.
numpy.core._exceptions._ArrayMemoryError: Unable to allocate 11.2 GiB for an
array with shape (40000, 40000) and data type float64Common causes
Allocation exceeds runner memory
The requested array is larger than the runner’s RAM. A 40000×40000 float64 array is ~12 GiB - far beyond a standard CI box.
Oversized dtype or accidental broadcast
Using float64 where float32 suffices, or an unintended broadcast/outer product, can multiply the needed memory several-fold.
How to fix it
Reduce the allocation
Use a smaller dtype, chunk the work, or operate in place to cut peak memory.
import numpy as np
a = np.zeros((40000, 40000), dtype=np.float32) # half the memory of float64
# or process in chunks instead of one giant arrayRun on a larger runner for genuine workloads
- If the size is legitimate, use a higher-memory runner.
- Otherwise cap test fixture sizes so CI does not allocate production-scale arrays.
- Profile peak memory to find accidental broadcasts.
How to prevent it
- Use the smallest sufficient dtype (float32/int32) for large arrays.
- Keep CI fixtures small; do not allocate production-scale arrays in tests.
- Chunk large computations instead of building one contiguous buffer.