ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 27 Nov 2017 23:05:39 +0100Sage Math freeze my Linux on intensive computation.https://ask.sagemath.org/question/39818/sage-math-freeze-my-linux-on-intensive-computation/Sage Math hangs my Linux on intensive computation, there was a big loop with floating number and uniform random function. Is there a way to limit the Sage Math resource such that my computer won't hang, or even makes the Sage Math runs slower until the result is found without freezing the Linux?
Mon, 27 Nov 2017 15:30:18 +0100https://ask.sagemath.org/question/39818/sage-math-freeze-my-linux-on-intensive-computation/Answer by tmonteil for <p>Sage Math hangs my Linux on intensive computation, there was a big loop with floating number and uniform random function. Is there a way to limit the Sage Math resource such that my computer won't hang, or even makes the Sage Math runs slower until the result is found without freezing the Linux?</p>
https://ask.sagemath.org/question/39818/sage-math-freeze-my-linux-on-intensive-computation/?answer=39820#post-id-39820You could have a look at the `nice` (for processor) and `ulimit` (for RAM) shell commands.
Mon, 27 Nov 2017 22:24:16 +0100https://ask.sagemath.org/question/39818/sage-math-freeze-my-linux-on-intensive-computation/?answer=39820#post-id-39820Answer by dan_fulea for <p>Sage Math hangs my Linux on intensive computation, there was a big loop with floating number and uniform random function. Is there a way to limit the Sage Math resource such that my computer won't hang, or even makes the Sage Math runs slower until the result is found without freezing the Linux?</p>
https://ask.sagemath.org/question/39818/sage-math-freeze-my-linux-on-intensive-computation/?answer=39821#post-id-39821This is a linux question. Short answer: use `nice` and/or `renice`.
Longer answer. On my machine there are the following sage related processes right now:
$ ps -ef | fgrep sage
dan 5450 5429 0 22:04 pts/7 00:00:00 grep -F --color=auto sage
dan 31748 12728 0 Nov26 pts/5 00:00:30 python2 /usr/bin/sage-ipython -i
dan 32751 31748 0 Nov26 pts/5 00:00:03 python2 /usr/bin/sage-cleaner
In `top -u dan` (top processes for the user named `dan`) there are two relevant columns `PR` and `NI`, priority and nice value. (One can scroll down and later come back in the top terminal menu by using PageDown and PageUp.) The nice value tells how "gentle" is a process w.r.t. the other processes. (A good nice value for a process means, it opens wide the door and lets first the ladies go through, also the friends, and the seniors, even also the kids in hurry to start that action games of intelligent destruction, well they all, the ladies, the friends, the seniors, even the kids will say "what a nice process!" - and now it is really hard to forget why they call it "nice value".)
The process identity, as delivered from `ps -ef` and / or `top` can be used from the terminal line to give more or less "voice" to a process. For instance:
nice -n 17 sage
starts `sage` (in the same terminal) with the `-n`iceness value `17`. In the top of the user `dan` i found among many other lines:
PID USER PR NI VIRT RES %CPU %MEM TIME+ S COMMAND
5429 dan 20 0 7,7m 4,0m 0,0 0,1 0:00.04 S `- bash
6155 dan 37 17 807,0m 170,3m 0,0 5,4 0:02.33 S `- python2
6175 dan 37 17 0,0m 0,0m 0,0 0,0 0:00.02 Z `- python2
5976 dan 20 0 7,7m 4,0m 0,0 0,1 0:00.00 S `- bash
6096 dan 20 0 9,0m 3,7m 1,3 0,1 0:03.18 R `- top
6048 dan 20 0 7,7m 3,9m 0,0 0,1 0:00.03 S `- bash
16226 dan 20 0 208,0m 8,0m 0,0 0,3 0:01.83 S `- xfce4-appfinder
The column NI gives the niceness.
The related `ps` information:
$ ps -lu dan | fgrep python
0 S 1000 6155 5429 0 97 17 - 206636 poll_s pts/7 00:00:02 python2
0 Z 1000 6175 6155 0 97 17 - 0 - pts/7 00:00:00 python2 <defunct>
Let us reset the niceness to 9. I tried:
$ renice -n 9 -p 6155
renice: failed to set priority for 6155 (process ID): Permission denied
$ sudo renice -n 9 -p 6155
[sudo] password for dan:
6155 (process ID) old priority 17, new priority 9
Well, the higher rights could set the priority of the process. Let's check:
$ ps -lp 6155 6175
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 S 1000 6155 5429 0 89 9 - 206636 poll_s pts/7 0:02 python2 /usr/bin/sage-ipython -i
0 Z 1000 6175 6155 0 97 17 - 0 - pts/7 0:00 [python2] <defunct>
It is maybe better to start sage with the right niceness. Note that the default niceness is
$ nice
0
Mon, 27 Nov 2017 23:05:39 +0100https://ask.sagemath.org/question/39818/sage-math-freeze-my-linux-on-intensive-computation/?answer=39821#post-id-39821