Computing the nullspace of a moderate matrix blows up RAM

88 views
Skip to first unread message

Emanuel Sygal

unread,
Apr 25, 2018, 11:59:52 AM4/25/18
to sympy
I am trying to find a basis for the nullspace of some matrix $A$ in sympy of size (384, 120). When calling  
A.nullspace()
The RAM usage gradually rises up to the 60GB that I have, and then the kernel dies.
The matrix consists of elements that are just 1,-1,0 and mostly zero.I create the matix like this:
A = sympy.Matrix(vectors_list)

where every element of vectors_list is a tuple of elements of type sympy.core.numbers.
I tried setting the environment variables "SYMPY_USE_CACHE", "SYMPY_INT_TRACE" to "no"
and it did not make a change.

without luck. What can I do more?

Aaron Meurer

unread,
Apr 25, 2018, 2:27:10 PM4/25/18
to sy...@googlegroups.com
This should probably be considered a bug. Most likely our nullspace
algorithm is doing something inefficient.

Since your matrix is mostly zeros, you might try using a sparse matrix
(SparseMatrix).

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/4b5bb5ee-2a42-4489-b062-22c4a3098e90%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Emanuel Sygal

unread,
Apr 25, 2018, 4:35:07 PM4/25/18
to sympy
Hi, thanks for the suggestion. 
Using DenseMatrix did not seem to rectify the problem.
I attach a .txt file containing the matrix as a list of tuples, to help reproducing. I do not know how to file a bug formally.
(Does this also happen to you?)

The file can be loaded, e.g., by the commands
with open("vectors_list.txt", "rb") as f:
    x = eval(f.read())
A = sympy.SparseMatrix(x)
y = A.nullspace()
vectors_list.txt

Emanuel Sygal

unread,
Apr 27, 2018, 11:12:22 AM4/27/18
to sympy
This seems to be more than an inefficiency but rather a bug that causes it to never stop. I ran the code on an AWS machine and it consumed 360GB of RAM by now. (and is still running.)

How can I report it as a bug?

Nathan Goldbaum

unread,
Apr 27, 2018, 11:15:59 AM4/27/18
to sy...@googlegroups.com
On Fri, Apr 27, 2018 at 10:12 AM Emanuel Sygal <imanue...@gmail.com> wrote:
This seems to be more than an inefficiency but rather a bug that causes it to never stop. I ran the code on an AWS machine and it consumed 360GB of RAM by now. (and is still running.)

How can I report it as a bug?

Reply all
Reply to author
Forward
0 new messages