ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 15 Jan 2019 17:42:46 -0600Loading a 5GB dictionary of matrices uses up all of 64GB RAMhttp://ask.sagemath.org/question/45062/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: LeonTue, 15 Jan 2019 17:42:46 -0600http://ask.sagemath.org/question/45062/max memory used during a processhttp://ask.sagemath.org/question/44944/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?LeonMon, 07 Jan 2019 15:00:12 -0600http://ask.sagemath.org/question/44944/Memory leaks with matrix multiplication over GF(2)http://ask.sagemath.org/question/43769/memory-leaks-with-matrix-multiplication-over-gf2/Hello everyone,
I have memory leaks when I run this program:
#### Memory leaks with sage 8.3 and sage 8.1 !!!
n = 8
X = zero_vector(GF(2), n)
M = zero_matrix(GF(2), n, n)
for _ in range(10000000):
Y = M * X
I use debian buster and sage-8.3-Debian_GNU_Linux_9-x86_64.
Is there something I'm doing wrong?
Thanks !agrospelWed, 26 Sep 2018 04:18:13 -0500http://ask.sagemath.org/question/43769/Sage 8.1 eats memory until system freezehttp://ask.sagemath.org/question/41009/sage-81-eats-memory-until-system-freeze/Hi, I have a quite long code (which uses arbitrary precision real numbers) which runs perfectly on Sage 7.5.1 (ppa for Mint 17.3 - Ubuntu 14.04). On Sage 8.1 (sage-8.1-Ubuntu_14.04-x86_64.tar.bz2) it starts to eat the memory until it freezes the system. I would like to help in debugging. Is there something that I can try/run/test? I can also upload the code, if necessary.
Finally, I have a minimal working code
def test(m,c,precision):
M = 3*m
RRR = RealField(prec = precision)
coef02 = [RRR(1/i) for i in [1..M+1]]
g = coef02[M]
for i in [M-1..2,step=-1]: # Horner
g = x*g+coef02[i]
ME = 32
disk = [exp (2*pi.n(precision)*I*i/ME) for i in range(ME)]
gamma = abs(c)/2
ellipse = [(gamma*(w+c^2/(4*gamma^2)/w)) for w in disk]
epsilon1 = max([abs(g(x=z)) for z in ellipse])
return
m = 40
for c in [1/2..10,step=1/2]:
for ell in [1..10]:
test(m,c,165)
If I run this in 7.5.1, I see (in top) the memory percentage stable around 2.5. If I run in 8.1, it grows up to 7.3 before code termination. If I increase the length of the loops, memory usage continues to grow.Marco CaliariWed, 07 Feb 2018 04:16:09 -0600http://ask.sagemath.org/question/41009/Can make doc use less memory?http://ask.sagemath.org/question/35780/can-make-doc-use-less-memory/Running make doc works fine during the night on my computer because I am not using it. But running make doc is really annoying during the day when let's say I want to use firefox at the same time: the computer gets swapping and becomes unusable.SébastienTue, 29 Nov 2016 07:46:38 -0600http://ask.sagemath.org/question/35780/Memory leak when doing ANF of boolean functions?http://ask.sagemath.org/question/35623/memory-leak-when-doing-anf-of-boolean-functions/I am using SageMath version 7.2 (EDIT: I confirm the same behavior under Sage version 7.4)
sage: B = random_boolean_function(3)
sage: get_memory_usage()
732.5078125
sage: B.algebraic_normal_form()
x0*x1*x2 + x0*x1 + x0 + x2
sage: get_memory_usage()
743.53125
sage: B.algebraic_normal_form()
x0*x1*x2 + x0*x1 + x0 + x2
sage: get_memory_usage()
749.04296875
sage: B.algebraic_normal_form()
x0*x1*x2 + x0*x1 + x0 + x2
sage: get_memory_usage()
754.6875
sage: B.algebraic_normal_form()
x0*x1*x2 + x0*x1 + x0 + x2
sage: get_memory_usage()
760.19921875
After each ANF call the memory used is **rising**. Is this a memory leak?sageuser1Thu, 17 Nov 2016 02:50:56 -0600http://ask.sagemath.org/question/35623/Memory leak somewhere?http://ask.sagemath.org/question/34364/memory-leak-somewhere/My code is using massive amounts of memory (eventually), which I don't think should be the case. The memory use slowly increases until my computer runs out of memory. I tried enabling garbage collection, but that didn't help (or didn't help enough). I don't see any reason why this should use more and more memory. It takes somewhere between 5 and 10 hours for this program to use up my 16 GB of memory, but that memory user is increasing is clear quickly.
import numpy
trials = 5800
length = 5000
mean = 0
results = [0]*trials
data = [0]*length
for i in range(trials):
data[0] = numpy.random.normal(0,1)
for j in range(1, length):
data[j] = data[j-1] + numpy.random.normal(0,1)
for k in range(2, length):
if data[k] > 2*sqrt(k*log(log(k+1))):
results[i] += 1
mean += results[i]vukovSun, 07 Aug 2016 13:04:22 -0500http://ask.sagemath.org/question/34364/Memory saturation when I test equalities in symbolic ring.http://ask.sagemath.org/question/32920/memory-saturation-when-i-test-equalities-in-symbolic-ring/Hello,
I use sage 7.1 on a debian computer. I have a problem of memory when I test an equality in SR. It seems that sage does not free the memory used at the end of the test. For example with the programm:
a = sqrt(2)
while(true):
if (a == 0):
break
The memory used by sage grows and my computer crashes if I wait too long. There is no problem if I replace sqrt(2) by 1...
Is there something I am doing wrong?
Antoine
agrospelThu, 31 Mar 2016 03:03:41 -0500http://ask.sagemath.org/question/32920/High memory usage when substituting variableshttp://ask.sagemath.org/question/29444/high-memory-usage-when-substituting-variables/I need to make a lot of variable substitutions in multivariate polynomials. However, I only need to store one polynomial at a time and I only need to make one substitution at a time. Nonetheless sage uses a lot of memory. This memory is not freed until sage is killed.
Here is a small example:
var("x y z")
# A polynomial in three variables (The Trott quartic):
poly=12^2*(x^4+y^4)-15^2*(x^2+y^2)*z^2+350*x^2*y^2+9^2*z^4
poly=poly.polynomial(ZZ)
pnt=[1,2,3]
# Makes a certain variable subsitution, defined by pt, n times.
def test_subs(f,pt,n):
for i in xrange(n):
temp=f.substitute(x=x+pt[0]*z,y=y+pt[1]*z,z=pt[2]*z)
#temp=f(x=x+pt[0]*z,y=y+pt[1]*z,z=pt[2]*z) #This also uses a lot of memory.
When i run `test_subs(poly,pnt,100000)` I can see the memory usage ticking up from around 1% up to nearly 2%. if I then run the function again the ticking starts at 2%, and so on. In the real problem I have my program eventually fills up all memory and then crashes.
Can you see why this is happening and do you know how to prevent it from happening?Olof BergvallTue, 15 Sep 2015 04:09:49 -0500http://ask.sagemath.org/question/29444/maxima is eating up all the memoryhttp://ask.sagemath.org/question/7954/maxima-is-eating-up-all-the-memory/I am running a sage script that uses maxima_methods().exponentialize(). I have a time out wrapper that kills the sage after a specific amount of time say 20 secs. Normamly when I kill sage, the associated process including maxima are killed. But, in a case, it kills the sage but not the associated maxima process. And the maxima process is eating up all the memory. Any way to kill that associated maxima process when I kill the sage script. Shoud I need to change/tweak anything in the file sage/interfaces/maxima.py ShuThu, 17 Feb 2011 11:24:38 -0600http://ask.sagemath.org/question/7954/Cannot allocate memory?http://ask.sagemath.org/question/25189/cannot-allocate-memory/ I use the sagemath package distributed with Ubuntu. Recently, it was automatically suggested that I update this package, which I did. After that I have had a lot of problems.
I use sage almost exclusively as an R interface. All my problems are with R. After the upgrade, I will frequently get a message like "R Interpreter crashed -- automatically restarting." - except that it never restarts automatically I have to manually restart the entire sage notebook server.
I have also had several messages like R cannot allocate 125 MB memory for an array... Where I have 4 GB RAM so it shouldn't be a problem at all and I could run this code before the upgrade without problem. Just now, I tried to run install.packages() but got the error " system call failed: Cannot allocate memory". This is for a 28 kB package, so I should be able to run it on an old 286 computer for christs sake.
1) Does anyone have any suggestions on how to solve these memory limitations?
2) Alternatively, how can I "downgrade" and get my previous version of sage back? Because in my previous version I had no problems at all.
EDIT:
Ubuntu version from /etc/issue = Ubuntu 14.04.1 LTS
Package: sagemath-upstream-binary
Priority: extra
Section: math
Installed-Size: 3102314
Maintainer: Jan Groenewald <jan@aims.ac.za>
Architecture: amd64
Version: 6.4.1
Recommends: openssl, build-essential, gfortran, imagemagick, dvipng, texlive, texlive-pictures, icedtea-plugin, bash, python
Suggests: m4, openssh-client, git
Depends: libc6, libexpat1, libfontconfig1, libgcc1, libssl1.0.0, libstdc++6, libgfortran3, libgomp1, libquadmath0
Pre-Depends: dpkg (>= 1.15.6~)
Filename: pool/main/s/sagemath-upstream-binary/sagemath-upstream-binary_6.4.1_amd64.deb
Size: 483102424
MD5sum: 26845d5ae2d46f2f2687693fd7819a7e
SHA1: f06b711ffd514d5d9738925d50bca212f8241f80
SHA256: 6c34bc35af4f7a0c166b3bf9bbe9c68ecfd1f5a2f7b71523abb79a9326ca40be
Description-en: Sage is a free open-source mathematics software system
Sage is a free open-source mathematics software system licensed under the GPL. It combines the power of many existing open-source packages into a common Python-based interface.
Mission: Creating a viable free open source alternative to Magma, Maple, Mathematica and Matlab.
.
This package is a wrapper around an upstream pre-built binary for Ubuntu 14.04.
Description-md5: 0a4e6e212377f9056703508d29d73269
Example code that produces memory allocation error for me:
# Important notice:
# When running this through Sage, have to divide the code into 3 or more cells, because R interface
# will only accept short code snippets.
# Error will then appear in either first or last cell (creating data frames OR plotting data)
library(ggplot2)
library(gridExtra)
xvar <- c(rnorm(15000000, mean = -1), rnorm(15000000, mean = 1.5))
yvar <- c(rnorm(15000000, mean = 1), rnorm(15000000, mean = 1.5))
zvar <- as.factor(c(rep(1, 15000000), rep(2, 15000000)))
xy <- data.frame(xvar, yvar, zvar)
#placeholder plot - prints nothing at all
empty <- ggplot()+geom_point(aes(1,1), colour="white") +
theme(
plot.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank()
)
#scatterplot of x and y variables
scatter <- ggplot(xy,aes(xvar, yvar)) +
geom_point(aes(color=zvar)) +
scale_color_manual(values = c("orange", "purple")) +
theme(legend.position=c(1,1),legend.justification=c(1,1))
#marginal density of x - plot on top
plot_top <- ggplot(xy, aes(xvar, fill=zvar)) +
geom_density(alpha=.5) +
scale_fill_manual(values = c("orange", "purple")) +
theme(legend.position = "none")
#marginal density of y - plot on the right
plot_right <- ggplot(xy, aes(yvar, fill=zvar)) +
geom_density(alpha=.5) +
coord_flip() +
scale_fill_manual(values = c("orange", "purple")) +
theme(legend.position = "none")
png("temp.png", width=1500, height=750)
#arrange the plots together, with appropriate height and width for each row and column
grid.arrange(plot_top, empty, scatter, plot_right, ncol=2, nrow=2, widths=c(4, 1), heights=c(1, 4))
dev.off()Dan-ErikWed, 10 Dec 2014 01:47:19 -0600http://ask.sagemath.org/question/25189/Insufficient RAM for computing newformshttp://ask.sagemath.org/question/7711/insufficient-ram-for-computing-newforms/In a Mac OS X, with a 2.5Ghz processor and 4Gb RAM I ran the following lines in Sage:
D = DirichletGroup(20)
g = D[7].extend(1600) # order 4 character
N = Newforms(g,2,names='a')
In two hours the 4Gb were full and it started writing to swap. Is it normal that 4Gb RAM is not enough to perform the above computation? I'm new to Sage (and to the forum) but since Sage tells me that the space
S = ModularSymbols(g,2,sign=1).cuspidal_subspace().new_submodule()
has dim 34 I was expecting it to be within the powers of my computer. Thanks, NunonbfrSat, 25 Sep 2010 08:36:20 -0500http://ask.sagemath.org/question/7711/sage solve memory linear system runtimehttp://ask.sagemath.org/question/11038/sage-solve-memory-linear-system-runtime/Hello,
I have a system of linear algebraic equations formed by the nodal equations of a linear electric circuit. The nodal voltages are the unknowns.
There are 16 unknowns.
sage runs forever and in the end I obtain:
RuntimeError: ECL says: Memory limit reached. Please jump to an outer pointer,
quit program and enlarge the
memory limits before executing the program again.
Am I missing something or doing something wrong ?
It is possible that sage cannot solve this linear algebraic system in a reasonable (short) time with "only" 16 unknowns ?
The unknowns are
[V_3, V_4, V_5, V_8, V_7, V_1, V_8, V_10, V_9l, V_4, V_4, V_7, V_2, V_3, V_6, V_9]
and the system is:
[V_10/RLOAD + ((V_1 - V_8)*K1*sqrt(Ltrafo6) - sqrt(Ltrafo5)*V_10)/((K1^2*Ltrafo6*s - Ltrafo6*s)*sqrt(Ltrafo5)) == 0,
-(V_9 - V_9l)/RL2 + ((V_4 - V_7)*(K3*K4 - K2)*sqrt(L1)*sqrt(L2) + ((K4^2 - 1)*(V_4 - V_9l)*sqrt(L1) + (V_2 - V_3)*(K2*K4 - K3)*sqrt(L2))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*sqrt(L1)*L2*sqrt(L3)) == 0,
(V_1 - V_7)/R4 + (V_1 - V_2)/R1 + V_1/RI + (K1*sqrt(Ltrafo5)*V_10 - (V_1 - V_8)*sqrt(Ltrafo6))/((K1^2*Ltrafo5*s - Ltrafo5*s)*sqrt(Ltrafo6)) - ICC_small_signal_0_1(s) == 0,
(V_3 - V_4)*CBC_Q1*s + (V_4 - V_5)*GM_Q1 + (V_3 - V_5)/RO_Q1 - ((V_4 - V_7)*(K2*K3 - K4)*sqrt(L1)*sqrt(L2) - ((K2^2 - 1)*(V_2 - V_3)*sqrt(L2) + (V_4 - V_9l)*(K2*K4 - K3)*sqrt(L1))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*L1*sqrt(L2)*sqrt(L3)) == 0,
Cbp1*V_2*s - (V_1 - V_2)/R1 + V_2/RCbp1 + ((V_4 - V_7)*(K2*K3 - K4)*sqrt(L1)*sqrt(L2) - ((K2^2 - 1)*(V_2 - V_3)*sqrt(L2) + (V_4 - V_9l)*(K2*K4 - K3)*sqrt(L1))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*L1*sqrt(L2)*sqrt(L3)) == 0,
(V_5 - V_7)*CBE_Q2*s + (V_5 - V_7)*GM_Q2 - (V_4 - V_5)*GM_Q1 + (V_5 - V_8)/RO_Q2 + (V_5 - V_7)/RPI_Q2 - (V_4 - V_5)/RPI_Q1 - (V_3 - V_5)/RO_Q1 + (V_5 - V_6)/(LRFC1*s) == 0, -(V_3 - V_4)*CBC_Q1*s + (V_4 - V_5)/RPI_Q1 - ((V_4 - V_7)*(K3*K4 - K2)*sqrt(L1)*sqrt(L2) + ((K4^2 - 1)*(V_4 - V_9l)*sqrt(L1) + (V_2 - V_3)*(K2*K4 - K3)*sqrt(L2))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*sqrt(L1)*L2*sqrt(L3)) - ((K3^2 - 1)*(V_4 - V_7)*sqrt(L1)*sqrt(L2) + ((V_4 - V_9l)*(K3*K4 - K2)*sqrt(L1) - (V_2 - V_3)*(K2*K3 - K4)*sqrt(L2))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*sqrt(L1)*sqrt(L2)*L3) == 0,
(V_7 - V_8)*CBC_Q2*s - (V_5 - V_7)*CBE_Q2*s + Cbp2*V_7*s - (V_5 - V_7)/RPI_Q2 - (V_1 - V_7)/R4 + V_7/R3 + ((K3^2 - 1)*(V_4 - V_7)*sqrt(L1)*sqrt(L2) + ((V_4 - V_9l)*(K3*K4 - K2)*sqrt(L1) - (V_2 - V_3)*(K2*K3 - K4)*sqrt(L2))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*sqrt(L1)*sqrt(L2)*L3) == 0,
V_6/R2 - (V_5 - V_6)/(LRFC1*s) == 0,
C2*V_9*s + (V_9 - V_9l)/RL2 == 0,
-(V_7 - V_8)*CBC_Q2*s - (V_5 - V_7)*GM_Q2 - (V_5 - V_8)/RO_Q2 - (K1*sqrt(Ltrafo5)*V_10 - (V_1 - V_8)*sqrt(Ltrafo6))/((K1^2*Ltrafo5*s - Ltrafo5*s)*sqrt(Ltrafo6)) == 0]
Thank you
ekaSat, 15 Feb 2014 07:10:45 -0600http://ask.sagemath.org/question/11038/solve fails to solve a simple system and runs out of memoryhttp://ask.sagemath.org/question/11037/solve-fails-to-solve-a-simple-system-and-runs-out-of-memory/Hello,
I have a system of linear algebraic equations formed by the nodal equations of a linear electric circuit. The nodal voltages are the unknowns.
There are 16 unknowns.
sage runs forever and in the end I obtain:
RuntimeError: ECL says: Memory limit reached. Please jump to an outer pointer,
quit program and enlarge the
memory limits before executing the program again.
Am I missing something or doing something wrong ?
It is possible that sage cannot solve this linear algebraic system in a reasonable (short) time with "only" 16 unknowns ?
The unknowns are
[V_3, V_4, V_5, V_8, V_7, V_1, V_8, V_10, V_9l, V_4, V_4, V_7, V_2, V_3, V_6, V_9]
and the system is:
[V_10/RLOAD + ((V_1 - V_8)*K1*sqrt(Ltrafo6) - sqrt(Ltrafo5)*V_10)/((K1^2*Ltrafo6*s - Ltrafo6*s)*sqrt(Ltrafo5)) == 0,
-(V_9 - V_9l)/RL2 + ((V_4 - V_7)*(K3*K4 - K2)*sqrt(L1)*sqrt(L2) + ((K4^2 - 1)*(V_4 - V_9l)*sqrt(L1) + (V_2 - V_3)*(K2*K4 - K3)*sqrt(L2))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*sqrt(L1)*L2*sqrt(L3)) == 0,
(V_1 - V_7)/R4 + (V_1 - V_2)/R1 + V_1/RI + (K1*sqrt(Ltrafo5)*V_10 - (V_1 - V_8)*sqrt(Ltrafo6))/((K1^2*Ltrafo5*s - Ltrafo5*s)*sqrt(Ltrafo6)) - ICC_small_signal_0_1(s) == 0,
(V_3 - V_4)*CBC_Q1*s + (V_4 - V_5)*GM_Q1 + (V_3 - V_5)/RO_Q1 - ((V_4 - V_7)*(K2*K3 - K4)*sqrt(L1)*sqrt(L2) - ((K2^2 - 1)*(V_2 - V_3)*sqrt(L2) + (V_4 - V_9l)*(K2*K4 - K3)*sqrt(L1))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*L1*sqrt(L2)*sqrt(L3)) == 0,
Cbp1*V_2*s - (V_1 - V_2)/R1 + V_2/RCbp1 + ((V_4 - V_7)*(K2*K3 - K4)*sqrt(L1)*sqrt(L2) - ((K2^2 - 1)*(V_2 - V_3)*sqrt(L2) + (V_4 - V_9l)*(K2*K4 - K3)*sqrt(L1))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*L1*sqrt(L2)*sqrt(L3)) == 0,
(V_5 - V_7)*CBE_Q2*s + (V_5 - V_7)*GM_Q2 - (V_4 - V_5)*GM_Q1 + (V_5 - V_8)/RO_Q2 + (V_5 - V_7)/RPI_Q2 - (V_4 - V_5)/RPI_Q1 - (V_3 - V_5)/RO_Q1 + (V_5 - V_6)/(LRFC1*s) == 0, -(V_3 - V_4)*CBC_Q1*s + (V_4 - V_5)/RPI_Q1 - ((V_4 - V_7)*(K3*K4 - K2)*sqrt(L1)*sqrt(L2) + ((K4^2 - 1)*(V_4 - V_9l)*sqrt(L1) + (V_2 - V_3)*(K2*K4 - K3)*sqrt(L2))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*sqrt(L1)*L2*sqrt(L3)) - ((K3^2 - 1)*(V_4 - V_7)*sqrt(L1)*sqrt(L2) + ((V_4 - V_9l)*(K3*K4 - K2)*sqrt(L1) - (V_2 - V_3)*(K2*K3 - K4)*sqrt(L2))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*sqrt(L1)*sqrt(L2)*L3) == 0,
(V_7 - V_8)*CBC_Q2*s - (V_5 - V_7)*CBE_Q2*s + Cbp2*V_7*s - (V_5 - V_7)/RPI_Q2 - (V_1 - V_7)/R4 + V_7/R3 + ((K3^2 - 1)*(V_4 - V_7)*sqrt(L1)*sqrt(L2) + ((V_4 - V_9l)*(K3*K4 - K2)*sqrt(L1) - (V_2 - V_3)*(K2*K3 - K4)*sqrt(L2))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*sqrt(L1)*sqrt(L2)*L3) == 0,
V_6/R2 - (V_5 - V_6)/(LRFC1*s) == 0,
C2*V_9*s + (V_9 - V_9l)/RL2 == 0,
-(V_7 - V_8)*CBC_Q2*s - (V_5 - V_7)*GM_Q2 - (V_5 - V_8)/RO_Q2 - (K1*sqrt(Ltrafo5)*V_10 - (V_1 - V_8)*sqrt(Ltrafo6))/((K1^2*Ltrafo5*s - Ltrafo5*s)*sqrt(Ltrafo6)) == 0]
Thank you
ekaSat, 15 Feb 2014 07:09:08 -0600http://ask.sagemath.org/question/11037/Using less RAM memoryhttp://ask.sagemath.org/question/10561/using-less-ram-memory/Hi experts!
I wanna use less RAM memory in my Monte Carlo simulations. In my algorithm I use numpy arrays and `xrange()` function.
I hear that I can reduce RAM used in my lagorithm if I do the next:
1) replace `xrange()` for `range()`.
2) replace numpya arrays for python lists
3) use `reset()` function for deleting useless arrays.
Is that true?
Please help.
Thanks a lot!!mresimulatorTue, 24 Sep 2013 04:59:03 -0500http://ask.sagemath.org/question/10561/Out of memory while enumerating vectorshttp://ask.sagemath.org/question/10527/out-of-memory-while-enumerating-vectors/I am trying to enumerate all vectors of a certain dimension with entries less then some prescribed values and then check some conditions on each of them. This is the code I was thinking about:
`A = [(a,b,c,d) for a in range(100) for b in range (100) for c in range (100) for d in range (10)]`
`for f in A:`
`if Condition(f):`
`print f`
The problem is that when the product of my ranges is larger than $10^7$ or so I get a `MemoryError`.
Is there a more efficient way of enumerating vectors or avoiding the `MemoryError`?
Thank you.Alexandru PapiuMon, 09 Sep 2013 11:42:56 -0500http://ask.sagemath.org/question/10527/save command in SAGEhttp://ask.sagemath.org/question/10496/save-command-in-sage/I'm trying to save a 'big' rational matrix in SAGE, but I'm running into problems.
After computing my matrix A, which has size 5 x 10,000 and each entry contains rational numbers in fraction form with total number of digits for numerator and denominator more than 10 pages, I run the following command:
save(A, DATA + 'A').
This gives me the following error message:
Traceback(most recent call last):
...
RuntimeError: Segmentation fault.
After this, I can't access A at all any more. In other words, when I try to compute say A[2,3], I get an error. However, before running the save command I was able to compute this entry. Also, I tried the same save command with a 'smaller' matrix and that worked fine. I should also note that I'm using a laptop with 64-bit operating system, x64-based processor, Windows 8, i7 CPU @ 2.40 GHz and 8 GB RAM. Let me know if you need further information. My questions are:
1. Why can't I save my matrix? Why do I get the above error message? What does it mean?
2. How can I save my matrix A? Is there any other way I can save it?Sandi XhumariSun, 01 Sep 2013 11:07:15 -0500http://ask.sagemath.org/question/10496/sparse differential of a chain complexhttp://ask.sagemath.org/question/10415/sparse-differential-of-a-chain-complex/I'm trying to convert a simplicial complex into a chain complex and then extract the differential map. However the simplicial complex is rather large and sage runs out of memory when it tries to make the conversion. However, the differential should be a very sparse matrix and there should be plenty of memory to store a sparse representation of the differential. Is it possible to have sage compute the differential as a sparse matrix? Specifically the method which gives the out of memory error is `chain_complex()`.parsons.kyle.89Mon, 05 Aug 2013 11:16:29 -0500http://ask.sagemath.org/question/10415/polynomial ring variable limit workaroundhttp://ask.sagemath.org/question/10377/polynomial-ring-variable-limit-workaround/
On my machine, the maximum number of variables allowed in a polynomial ring is 32767.
For instance,
S = PolynomialRing(QQ, 32767,'s')
works, but
S = PolynomialRing(QQ, 32768,'s')
does not.
Is there a workaround with enough functionality to allow me to do something like compute a primary decomposition of an ideal?
Patrick ClarkeTue, 30 Jul 2013 22:28:17 -0500http://ask.sagemath.org/question/10377/Bad alloc occurs during echelonizationhttp://ask.sagemath.org/question/10076/bad-alloc-occurs-during-echelonization/Hi,
I've tried to echelonize a 2500x2601 sparse matrix, constisting of 0-1.
I think Sage has consumed the entire RAM during the echelonization, and exited with a "bad alloc" error. This is the error stack:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
------------------------------------------------------------------------
/usr/lib/sagemath/local/lib/libcsage.so(print_backtrace+0x3b)[0xb6e930d8]
/usr/lib/sagemath/local/lib/libcsage.so(sigdie+0x43)[0xb6e9327d]
/usr/lib/sagemath/local/lib/libcsage.so(sage_signal_handler+0x187)[0xb6e929cc]
[0xb77a0400]
[0xb77a0424]
/lib/i386-linux-gnu/libc.so.6(gsignal+0x4f)[0xb74101df]
/lib/i386-linux-gnu/libc.so.6(abort+0x175)[0xb7413825]
/usr/lib/sagemath/local/lib/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x178)[0xb6e4d130]
/usr/lib/sagemath/local/lib/libstdc++.so.6(+0xb1974)[0xb6e4a974]
/usr/lib/sagemath/local/lib/libstdc++.so.6(+0xb19a8)[0xb6e4a9a8]
/usr/lib/sagemath/local/lib/libstdc++.so.6(__cxa_rethrow+0x0)[0xb6e4abc1]
/usr/lib/sagemath/local/lib/libstdc++.so.6(_Znwj+0x73)[0xb6e4b4ef]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix_modn_dense_double.so(_ZN6LinBox10BlasMatrixINS_7ModularIdEEEC2IyEERKS2_RKyRKT_+0x6a)[0xb226e35a]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix_modn_dense_double.so(+0x32bdc)[0xb2260bdc]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x14d)[0xb766023d]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix_modn_dense_double.so(+0x1c0e0)[0xb224a0e0]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x14d)[0xb766023d]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix2.so(+0x3b98d)[0xb261f98d]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x14d)[0xb766023d]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix0.so(+0x14c31)[0xb2559c31]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x184)[0xb7660274]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix_integer_dense.so(+0x4c793)[0xb2396793]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x184)[0xb7660274]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix_rational_dense.so(+0x2c737)[0xb22f0737]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x14d)[0xb766023d]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix_rational_dense.so(+0x13a3b)[0xb22d7a3b]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x14d)[0xb766023d]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix0.so(+0x14c31)[0xb2559c31]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x184)[0xb7660274]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix2.so(+0xbc2d)[0xb25efc2d]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x184)[0xb7660274]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix2.so(+0x3c676)[0xb2620676]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x14d)[0xb766023d]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix2.so(+0x35c91)[0xb2619c91]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x14d)[0xb766023d]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x51ff)[0xb76c59cf]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x852)[0xb76c78e2]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x588b)[0xb76c605b]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x852)[0xb76c78e2]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x588b)[0xb76c605b]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x852)[0xb76c78e2]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x588b)[0xb76c605b]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x852)[0xb76c78e2]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(+0x5747e)[0xb764947e]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix_integer_dense.so(+0x5d00c)[0xb23a700c]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x14d)[0xb766023d]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix2.so(+0x7dde3)[0xb2661de3]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x14d)[0xb766023d]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyObject_Call+0x64)[0xb761fc94]
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/matrix/matrix2.so(+0x3fdfe)[0xb2623dfe]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyCFunction_Call+0x14d)[0xb766023d]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x51ff)[0xb76c59cf]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x852)[0xb76c78e2]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyEval_EvalCode+0x63)[0xb76c7a53]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyRun_FileExFlags+0xb5)[0xb76e88f5]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyRun_SimpleFileExFlags+0xe9)[0xb76e94e9]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(PyRun_AnyFileExFlags+0x8c)[0xb76ea1dc]
/usr/lib/sagemath/local/lib/libpython2.7.so.1.0(Py_Main+0xc3c)[0xb76fd9ac]
python(main+0x27)[0x8048517]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb73fb4d3]
python[0x804853d]
What can I do to echelonize a 2000x2000 matrix?
Thank you,
AndreaAndreaSun, 28 Apr 2013 22:44:33 -0500http://ask.sagemath.org/question/10076/Array of graphs consuming too much memory?http://ask.sagemath.org/question/10048/array-of-graphs-consuming-too-much-memory/I want to work in Sage with a large array of small graphs.
To create this array, I load a textfile that has 100000 lines of the following form
gs = []
gs.append(Graph([(0,1,0),(0,1,1),(0,1,2),(0,1,3),(2,3,4),(2,3,5),(2,3,6),(4,5,7),(4,5,8),(4,5,9),(0,1,10), (0,1,11),(0,1,12),(0,1,13),(0,1,14)]))
gs.append(Graph([(0,1,0),(0,1,1),(0,1,2),(0,1,3),(2,3,4),(2,3,5),(2,3,6),(4,5,7),(4,5,8),(4,5,9),(0,1,10),(0,1,11),(0,1,12),(0,1,13),(0,2,14)]))
gs.append(Graph([(0,1,0),(0,1,1),(0,1,2),(0,1,3),(2,3,4),(2,3,5),(2,3,6),(4,5,7),(4,5,8),(4,5,9),(0,1,10),(0,1,11),(0,1,12),(0,1,13),(2,3,14)]))
The textfile occupies a total of 14Mb of diskspace only, but when imported into Sage, the memory usage of the process jumps by nearly 800Mb, and indeed at intermediate stages of the importing, it jumps to over 5Gb before dropping back down again. (Presumably this is due to some sort of memory allocation strategy that keeps doubling the memory required?)
Clearly I am doing something wrong, because an array of 100000 graphs should be no trouble at all to a modern computer, but I don't know **what** I am doing wrong and how to fix it.GordonSun, 21 Apr 2013 21:20:57 -0500http://ask.sagemath.org/question/10048/How to reset memory limitshttp://ask.sagemath.org/question/9554/how-to-reset-memory-limits/Hi everyone: I am trying to compute the determinant of an 11-by-11 complex matrix on SAGE v5.4 notebook() on a 2010 Mac 4G RAM etc running OS X v10.6.8. I would have thought that that would not be a big deal, but after 30 seconds or so I get a screed of traceback stuff ending with:
"... RuntimeError: ECL says: Memory limit reached. Please jump to an outer pointer, quit program and enlarge the memory limits before executing the program again."
There are no other programs open on the Mac, and the only other things in SAGE memory are 10 other matrices of the same size. In addition I have been having similarly limiting behaviour in all my matrix calcs, also on an HP laptop (using Sage v5.4 on Virtual Machine etc).
Could someone please tell me where I might be going wrong?
Many thanksGaryMakTue, 20 Nov 2012 21:29:17 -0600http://ask.sagemath.org/question/9554/how to increase memory used by sagehttp://ask.sagemath.org/question/9406/how-to-increase-memory-used-by-sage/Hello
I want to use sage with RAM memory 4Go because my programm is to late.
it's possible at sage? how can I do this? sezzouakTue, 09 Oct 2012 07:22:12 -0500http://ask.sagemath.org/question/9406/Runaway memory usage in Sage 5.0?http://ask.sagemath.org/question/9180/runaway-memory-usage-in-sage-50/Hi,
I am running Sage 5.0 on Windows 7 (as it is the latest Windows version available) and my code is crashing after a couple of hours of computation. Downgrading to Sage 4.8 fixes the problem. I'm not sure exactly where the issue is so I will try to say as much about what I'm doing as possible.
I am using the algorithm described in this paper:
http://www.springerlink.com/content/1f6xdjt3a7e7h0qn/
to build a database of the lattices of order $n$ up to isomorphism. I am up to $n=12$ so far, and my goal is to reach $n=15$. The program works by generating the lattices of order $n+1$ from the lattices of order $n$.
As such, I am using lots of Posets and LatticePosets. Sage should not have to store in memory more than a thousand or so Posets on $\leq 15$ nodes at any point during the code's execution, and should not have to hold much else in memory beyond these posets. My code takes as input the lattices of order $n$ and writes the lattices of order $n+1$ as it generates them to a file. I am running Sage 5.0 in VirtualBox with 4 processors and 1500MB RAM allocated.
My code uses the @parallel decorator on one function. With this, the overall memory usage of my system climbs rapidly from what it was before (X) to X+1500MB, and after a few hours one of the return values from the parallelized function will be 'NO DATA' (instead of what I expected, which is a short list of posets), which tells me something went wrong. If I remove the @parallel decorator and just call my function with single inputs instead of lists of inputs, the memory usage of my system rises rapidly to X+1500MB and after a few hours the entire Sage virtual machine just shuts down.
However, if I downgrade to Sage 4.8, dedicate 4 processors and only 1250MB RAM to Virtualbox, I can use the @parallel decorator and my code will run stably for hours and eventually complete, without my system ever going over X+1000MB memory usage.
Does anyone have any idea what's going on here? Is Sage 5.0 caching all of the lattices of order $n+1$ that I'm generating along the way and eventually running out of memory or something?Martin MalandroWed, 25 Jul 2012 07:52:05 -0500http://ask.sagemath.org/question/9180/Number fields and memoryhttp://ask.sagemath.org/question/9167/number-fields-and-memory/Hi,
I'm intensively using number fields. More precisely, I have a matrix group for which the coefficients belong to some number field and I iterate through this group.
For degree beyond a certain threshold (~ degree 8), Sage starts to fill more and more memory and I don't understand why (there is no reason from algorithmic point of vue). Is there a way to improve memory usage ? How could you explain such behavior ?
Thanks,
VincentvdelecroixFri, 20 Jul 2012 18:28:13 -0500http://ask.sagemath.org/question/9167/out of core exact linear algebrahttp://ask.sagemath.org/question/8810/out-of-core-exact-linear-algebra/I'm trying to solve a large (17000x250000) sparse (density=0.01) system over the rationals. Are there any routines in Sage (or out) that could give the reduced row echelon form, or the null space?
Everything I've looked into either runs out of memory or isn't exact.tagitagiWed, 21 Mar 2012 11:21:05 -0500http://ask.sagemath.org/question/8810/Overview of security and memory management?http://ask.sagemath.org/question/8649/overview-of-security-and-memory-management/Hi all,
I've been looking around the documentation for an explanation of how Sage is able to sandbox user code to prevent unauthorized access to the system the platform is being hosted on. Given that Sage Notebook is deployed in production on a public server, how does the platform isolate user environments/worksheets? Furthermore, how does Sage manage memory on a per-worksheet basis?
I'd appreciate any insight from those who have deployed Sage in a production environment, either internal or external to an organization. +5 pts if you have a sys admin background!
Thanks!
(For what it's worth, I've been going through the thesis titled "Securing the Sage Notebook", but I'd also like some more practical input. I'll be scrounging through the dev discussion threads for an answer as well and will follow up if I come across any good explanations.)stefMon, 23 Jan 2012 04:10:48 -0600http://ask.sagemath.org/question/8649/memory increasing when generating lots of hyperelliptic curves (without storing them)http://ask.sagemath.org/question/8437/memory-increasing-when-generating-lots-of-hyperelliptic-curves-without-storing-them/Executing the code given below (it generates hyperelliptic curves), the used memory increases all the time. Since nothing is stored permanently, this should not happen. How do I avoid it? (It is not really a problem with the example given, but using more loops, it becomes a problem.)
Here an example code:
F = GF(4, 'a')
R.<t> = PolynomialRing(F)
for x in F:
for y in F:
for z in F:
h = x*t^2 + y*t + z
for a in F:
for b in F:
for c in F:
for d in F:
for e in F:
f = t^5 + a*t^4 + b*t^3 + c*t^2 + d*t + e
C = HyperellipticCurve(f,h)
Daniel KrennFri, 04 Nov 2011 04:59:41 -0500http://ask.sagemath.org/question/8437/get_memory_usage returning negative numbershttp://ask.sagemath.org/question/8355/get_memory_usage-returning-negative-numbers/Is there a reason that get_memory_usage should ever return a negative number?
I tried running a "toy" program (after get_memory_usage returned surprisingly large numbers on a more complicated program that I'm using in my research - I wanted to see what the standard memory usage should look like for a basic counter function) and here is what happened:
def toy(n):
c = 0
for k in xrange(0, n):
c = c+1
return c
get_memory_usage(toy(1000))
-464.0859375
I could be misunderstanding how get_memory_usage works, but it seems to me that the memory usage should never be negative!
(In case this is relevant, I am using Sage 4.7.1 on my laptop.)lolaSun, 02 Oct 2011 14:13:59 -0500http://ask.sagemath.org/question/8355/How many memories uses Sage?http://ask.sagemath.org/question/7847/how-many-memories-uses-sage/How can I ask the memory usage? For example how many bytes we need to a polynom or other mathematical object? How many kbytes used by a function after running?czsanMon, 10 Jan 2011 00:58:43 -0600http://ask.sagemath.org/question/7847/