Python/Numpy MemoryError

Rewrite to

p *= alpha
u += p

and this will use much less memory. Whereas p = p*alpha allocates a whole new matrix for the result of p*alpha and then discards the old p; p*= alpha does the same thing in place.

In general, with big matrices, try to use op= assignment.

Leave a Comment