python
system_error
ai_generated
true
numpy.core._exceptions._ArrayMemoryError: Unable to allocate 15.3 GiB for an array with shape (45000, 45000) and data type float64
ID: python/numpy-memory-allocation
80%Fix Rate
87%Confidence
0Evidence
2024-09-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Requested array exceeds available RAM; often from dense distance matrices or cross joins.
generic中文
请求的数组超过可用内存;常由稠密距离矩阵或笛卡尔积引起。
Workarounds
-
85% success
Use float32: np.zeros((n, m), dtype=np.float32)
-
90% success
Chunk with sklearn.metrics.pairwise_distances_chunked or use sparse matrices
Dead Ends
Common approaches that don't work:
-
85% fail
Frees only a few GB; array still too large
-
70% fail
Massive slowdown, may still OOM