473,503 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Swap memory in Python ? - three questions

Hi,

I am using numpy and wish to create very large arrays. My system is AMD 64 x 2 Ubuntu 8.04. Ubuntu should be 64 bit. I have 3gb RAM and a 15 GB swap drive.

The command I have been trying to use is;
g=numpy.ones([1000,1000,1000],numpy.int32)

This returns a memory error.
A smaller array ([500,500,500]) worked fine..
Two smaller arrays again crashed the system.

So... I did the math. a 1000x1000x1000 array at 32 bits should be around 4gb RAM... Obviously larger than RAM, but much smaller than the swap drive.

1. So... does Numpy have a really lot of overhead? Or is my system just not somehow getting to make use of the 15gb swap area.
2. Is there a way I can access the swap area, or direct numpy to do so? Or do I have to write out my own numpy cache system...
3. How difficult is it to use data compression internally on numpy arrays?

thanks very much
Robert
Jul 29 '08 #1
4 10040
Robert LaMarca wrote:
Hi,

I am using numpy and wish to create very large arrays. My system is AMD 64 x 2 Ubuntu 8.04. Ubuntu should be 64 bit. I have 3gb RAM and a 15 GB swap drive.

The command I have been trying to use is;
g=numpy.ones([1000,1000,1000],numpy.int32)

This returns a memory error.
A smaller array ([500,500,500]) worked fine..
Two smaller arrays again crashed the system.

So... I did the math. a 1000x1000x1000 array at 32 bits should be around 4gb RAM... Obviously larger than RAM, but much smaller than the swap drive.

1. So... does Numpy have a really lot of overhead? Or is my system just not somehow getting to make use of the 15gb swap area.
2. Is there a way I can access the swap area, or direct numpy to do so? Or do I have to write out my own numpy cache system...
3. How difficult is it to use data compression internally on numpy arrays?

thanks very much
Robert
There are architectural issues that you should not expect (and really
do not want) the libraries / languages / os to handle for you
automatically. The reason you don't even _want_ an automatic solution
is that the computer has no understanding of the problem you are trying
to solve. If the machine guesses wrong, it will be doing computations
at I/O speeds, and for 4G of data, that will result in geological
computing times.

On big problems the programming issue is how to break the problem into
tractable sub-problems (of feasible computing size), and how to stitch
those results together. This is a place to apply human intellect, not
machine effort. So, sorry, there is no way to solve the problem without
understanding the field it occurs in and the question being addressed
by the code.

--Scott David Daniels
Sc***********@Acm.Org
Jul 29 '08 #2
Robert LaMarca <ro************@yahoo.comwrote:
Hi,

I am using numpy and wish to create very large arrays. My system is
AMD 64 x 2 Ubuntu 8.04. Ubuntu should be 64 bit. I have 3gb RAM and a
15 GB swap drive.

The command I have been trying to use is;
g=numpy.ones([1000,1000,1000],numpy.int32)

This returns a memory error.
Works for me on AMD64x2, 2GB RAM, 3GB swap. With much paging of course
;) Process size of python 4019508kB.
A smaller array ([500,500,500]) worked fine..
About 0.5GB.. no surprise.
Two smaller arrays again crashed the system.
Crash as in "computer reboots"? Strange. And you say, that two [500,
500, 500] arrays are two much?
So... I did the math. a 1000x1000x1000 array at 32 bits should be
around 4gb RAM... Obviously larger than RAM, but much smaller than the
swap drive.
Sounds like either your kernel or python are not 64bit.
For the kernel, have a look at /proc/meminfo, which value you get for
VmallocTotal. I have VmallocTotal: 34359738367 kB.
For python, check sys.maxint. If it's 2147483647, then you have a 32bit
python. Mine says 9223372036854775807.
1. So... does Numpy have a really lot of overhead? Or is my system
just not somehow getting to make use of the 15gb swap area.
No. Yes.
2. Is there a way I can access the swap area, or direct numpy to do
so? Or do I have to write out my own numpy cache system...
3. How difficult is it to use data compression internally on numpy
arrays?
2 + 3: Should not be necessary.

I just tried a 32bit python on my 64bit system, using Numeric instead of
numpy (don't have a 32bit numpy ready):

g=Numeric.zeros([1000,1000,1000],Numeric.Int32)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
MemoryError: can't allocate memory for array

g=Numeric.zeros([1000,1000,500],Numeric.Int32) succeeds.

So it looks like you have a 32bit kernel.

Marc
Jul 29 '08 #3
Robert LaMarca wrote:
Hi,

I am using numpy and wish to create very large arrays. My system is AMD 64
x 2 Ubuntu 8.04. Ubuntu should be 64 bit. I have 3gb RAM and a 15 GB swap
drive.
Does a full 64-bit version of CPython, one where all pointers
and sizes are 64 bits, even exist?

John Nagle
Jul 31 '08 #4
John Nagle <na***@animats.comwrote:
>Robert LaMarca wrote:
>>
I am using numpy and wish to create very large arrays. My system is AMD 64
x 2 Ubuntu 8.04. Ubuntu should be 64 bit. I have 3gb RAM and a 15 GB swap
drive.

Does a full 64-bit version of CPython, one where all pointers
and sizes are 64 bits, even exist?
Absolutely.

[timr@naxier ~]# uname -a
Linux naxier.xxxxxx.com 2.6.9-42.0.3.ELsmp #1 SMP Mon Sep 25 17:24:31 EDT
2006 x86_64 x86_64 x86_64 GNU/Linux
[timr@naxier ~]# python
Python 2.3.4 (#1, Feb 18 2008, 17:16:53)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>import sys
sys.maxint
9223372036854775807
>>>
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Aug 2 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
392
by: Benoit St-Jean | last post by:
I am wondering if the "swap bug" is present on my kernel/version of RedHat 9 as described at: http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=89226 It looks like the OS prefers to fill the...
9
2195
by: Benoit St-Jean | last post by:
I am wondering if the "swap bug" is present on my kernel/version of RedHat 9 as described at: http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=89226 It looks like the OS prefers to fill the...
0
205
by: Terry Reedy | last post by:
Robert LaMarca wrote: I do not know what numpy does, but constant arrays only need to store the dimensions and the constant value and have a getitem method that returns that constant value for...
0
1223
by: Robert Kern | last post by:
Terry Reedy wrote: Presumably, he's using numpy.ones() as an example of creating a large array, not because he actually needs an array full of 1s. -- Robert Kern "I have come to believe...
0
7083
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3166
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.