Ask Your Question

Leon's profile - activity

2019-07-17 03:53:41 -0500 commented answer Running Sage from the commad line in Ubuntu 12.04

I installed it to /home/leon/sage-8.8. How do I create a command sage that runs the program? I can't find $HOME/.bashrc in the home folder. Btw, I have Linux Mint Mate 19.1.

2019-06-26 10:42:34 -0500 received badge  Popular Question (source)
2019-02-02 04:25:32 -0500 received badge  Enthusiast
2019-01-23 10:18:07 -0500 received badge  Popular Question (source)
2019-01-21 07:43:39 -0500 commented answer Loading a 5GB dictionary of matrices uses up all of 64GB RAM

Now it works, thank you for your help and patience! : ) Using the above code, I've managed to load 7GB of sparse matrices without crashing (but when loaded, they take up 23GB of RAM, a bit strange).

2019-01-19 10:39:49 -0500 commented answer Loading a 5GB dictionary of matrices uses up all of 64GB RAM

Hmm, I still haven't been able to import the file, but probably due to my incompetence. Could you give me specific instructions on how (in what form) to export the file from Mathematica and how to import it in Sage? Do I export it to file.json? Should its content be e.g. [ "bdrs={", "1: matrix(ZZ,1,7,{}),", "2: matrix(ZZ,7,21,{(3,3):-1, (3,9):-1, (3,14):-1}),", "};" ] How do I import this into sage? If I run load('file.json'), I get No such file or directory: '/home/file.json.sobj'. If I run json.loads('file.json'), I get ValueError: No JSON object could be decoded.

2019-01-16 14:25:05 -0500 commented answer Loading a 5GB dictionary of matrices uses up all of 64GB RAM

Oh, that's disappointing. I thought Sage was supposed to be much more efficient than Mathematica. Even when I try to import just the largest matrix (that takes up less that 800MB), Sage uses up 28GB of RAM and crashes.

2019-01-16 04:01:05 -0500 received badge  Good Question (source)
2019-01-16 02:34:09 -0500 received badge  Nice Question (source)
2019-01-15 17:42:46 -0500 asked a question Loading a 5GB dictionary of matrices uses up all of 64GB RAM

In a 5GB file.sage, I stored a chain complex as a dictionary of sparse matrices (created it in Mathematica with no problems). When I run load(file.sage), the program uses up all 64GB RAM + 64GB swap and crashes. Why does Sage use that much of memory for a small file?

I tried splitting the file into three smaller ones and load one after another, but already with the first 1.3GB file, the system crashes after using all RAM, but without using swap. I get:

---------------------------------------------------------------------------
MemoryError                               Traceback (most recent call last)
<ipython-input-1-8cecfac681b8> in <module>()
----> 1 load('/home/leon/file.sage');

sage/structure/sage_object.pyx in sage.structure.sage_object.load (build/cythonized/sage/structure/sage_object.c:12879)()

/usr/lib/python2.7/dist-packages/sage/repl/load.pyc in load(filename, globals, attach)
    245             if attach:
    246                 add_attached_file(fpath)
--> 247             exec(preparse_file(open(fpath).read()) + "\n", globals)
    248     elif ext == '.spyx' or ext == '.pyx':
    249         if attach:

MemoryError:
2019-01-11 11:08:26 -0500 commented question max memory used during a process

Any ideas?

2019-01-07 15:00:12 -0500 asked a question max memory used during a process

In Mathematica, the command MaxMemoryUsed[computation] tells you what the largest usage of RAM was when executing some computation. Is there a similar comand in SageMath?

2018-10-28 09:45:02 -0500 commented answer ChainComplex() runs 24 times slower than homology()

Surely, ChainComplex() detects that these are sparse matrices, otherwise I wouldn't have enough RAM to store $10^6\times10^6=10^{12}$ entries... But still, thank you for your help!

2018-10-28 09:42:00 -0500 commented answer ChainComplex() runs 24 times slower than homology()

Aaah, you're right, with check=False, it only takes 3sec. Sorry for not noticing this option in the documentation, and thank you for your help!

2018-10-28 06:15:41 -0500 received badge  Nice Question (source)
2018-10-28 03:55:39 -0500 asked a question ChainComplex() runs 24 times slower than homology()

I load a list of matrices bdrs representing a chain complex, their dimensions are {1, 21, 210, 1330, 5985, 20349, 54264, 116280, 203490, 293930, 352716, 352716, 293930, 203490, 116280, 54264, 20349, 5985, 1330, 210, 21, 1}, and the largest has density 3.91*10^-6. In total they take up 50MB of disk space. This finishes in 63sec.

When I run chcx=ChainComplex(bdrs,base_ring=GF(2)), it takes 7hrs20min, but chcx.homology() finishes in only 18min. Why does it take so long to just store a few matrices? At first I thought that ChainComplex() also does some simplifications/reductions, but [chcx.free_module_rank(i) for i in range(0,21)] shows the original dimensions of matrices :/.

Is there a faster way to compute the homology of a chain complex (over $\mathbb{Z}$ or $\mathbb{Z}_p$)?

2018-10-27 03:45:21 -0500 received badge  Scholar (source)
2018-10-27 03:45:15 -0500 commented answer How to read and run commands from a text file?

Yes, I'll be computing a lot of homology of chain complexes. Thank you for your answers!!

2018-10-26 16:14:38 -0500 received badge  Supporter (source)
2018-10-26 15:54:42 -0500 commented answer How to read and run commands from a text file?

Great, it works! Could you also please answer the question about RAM, before I accept?

2018-10-26 15:14:01 -0500 received badge  Student (source)
2018-10-26 15:10:54 -0500 asked a question How to read and run commands from a text file?

I have all my commands in a text file, and I would just like to run them in Sage. What is the easiest way to do this?

For example, in sage.txt, I have written:

d0=matrix(ZZ,4,4,{(0,0):1,(2,0):1,(1,1):1,(3,1):1,(1,2):1,(3,2):1});
d1=matrix(ZZ,4,4,{(1,0):-1,(2,0):-1,(3,1):-1,(1,2):1,(2,2):1,(3,3):1});

The command with open('/home/sage.txt','r') as ll: bdrs=[sage_eval(l.strip()) for l in ll]; returns

File "<string>", line 1
    d0=matrix(ZZ,Integer(4),Integer(4),{(Integer(0),Integer(0)):Integer(1),(Integer(2),Integer(0)):Integer(1),(Integer(1),Integer(1)):Integer(1),(Integer(3),Integer(1)):Integer(1),(Integer(1),Integer(2)):Integer(1),(Integer(3),Integer(2)):Integer(1)});
      ^
SyntaxError: invalid syntax

Also, does Sage have a limit on how much RAM it can use? If yes, how can I increase the available memory?