[visionegg] Re: pre-loading a large number of stimuli
- From: Simeon Fitch <metasim@xxxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Mon, 22 Aug 2005 09:30:48 -0400
I don't know anything about the PIL library (yet... just getting started
with Vision Egg), but from what you describe, memory doesn't sound to be the
issue, and given enough RAM there's no technical reason you you shouldn't be
able to preload the images as you desire. It sounds to me as if there is a
bug somewhere in the code (yours or one of the libraries) that isn't closing
(i.e. calling the close() method) on the file after reading has completed.
I'd step through the code at each iteration and find out where the actual
"open()" call is happening, and see if there is a corresponding "close()"
when the reading is done. The code that does the "open()" should
theoretically be responsible for issuing the "close()" as well.
In case this helps, there is a command line tool on OS X (and Linux) called
"lsof" in "/usr/sbin/lsof" that generates a report all the open file
descriptors a process has.
Here's an example run:
Bongo:~ sfitch$ ps -Ac | grep -i python
347 ?? U 1:04.98 Python
Bongo:~ sfitch$ lsof -p 347 -a /
Python 347 sfitch cwd VDIR 14,2 884 2649263 /Users/sfitch/Coding/UVa
Psychology/PythonDotLattice
Python 347 sfitch txt VREG 14,2 13668 1601957
/System/Library/Frameworks/Python.framework/Versions/2.3/Resources/Python.app/Contents/MacOS/Python
Python 347 sfitch txt VREG 14,2 14236 1600566
/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload/math.so
...
The list will be long, but you can confirm that the problem is indeed files
not being closed.
Simeon
--
Simeon H.K. Fitch, Owner
Mustard Seed Software
http://www.mseedsoft.com/
On 8/15/05, Nick Knouf <nknouf@xxxxxxx> wrote:
> Hi everybody,
>
> (note: this will probably be the beginning of a large barrage of
> questions as I try and implement a standard blocked design fMRI
> experiment in VisionEgg)
>
> I'm trying to pre-load a large number of stimuli for an experiment;
> say, on the order of up to 400 or so. My loop to load the stimuli is
> the following (taken out of context):
>
> stimuli = []
> for condition in filelist:
> texture_list = [Texture(filename) for filename in condition]
> stimuli.append([TextureStimulus(anchor = 'center', position =
> (round(position[0]), round(position[1])), texture = texture, size =
> texture.size, texture_min_filter = gl.GL_LINEAR) for texture in
> texture_list])
>
> (filelist is a list of images to load, indexed first by condition,
> next by image; in this case, it's a list of dimensions 4 by 80)
>
> It seems to bomb out at around 200 images, however, giving the
> following error:
>
> 2005-08-15 20:13:16,390 (7856) CRITICAL: Traceback (most recent call
> last):
> File "test_rsvp.py", line 65, in ?
> File "/Users/nknouf/Development/VisionEgg_work/nklab/experiments/
> common.py", line 67, in createTexturesFromFilelist
> File "/Users/Shared/Library/Python/2.3/lib/python2.3/site-packages/
> VisionEgg/Textures.py", line 171, in __init__
> File "/Users/Shared/Library/Python/2.3/lib/python2.3/site-packages/
> PIL/Image.py", line 1717, in open
> IOError: [Errno 24] Too many open files: '2 objects/gun 25.tif'
>
> Looking at the source for PIL.Image, it appears to be running into
> the per-user open-file limit (since it runs the standard-library
> "open") command. I know that PILs open command only creates a file-
> handle, and actual reading of the data is deferred until later.
>
> Is there a way to force PIL, through VisionEgg, to read the file when
> creating a Texture() object, such that I don't exceed the open file
> limit? I know I could simply increase the limit, but I'd rather not
> do that.
>
> Thanks,
>
> nick knouf
> lab manager, kanwisher lab
>
> PS BTW, is there a reason why all of the demos use "
> texture_min_filter = gl.GL_LINEAR" as a keyword argument to
> TextureStimulus, especially since the help information says that
> texture_min_filter already defaults to gl.GL_LINEAR?
> ======================================
> The Vision Egg mailing list
> Archives: http://www.freelists.org/archives/visionegg
> Website: http://www.visionegg.org/mailinglist.html
>
- References:
- [visionegg] pre-loading a large number of stimuli
- From: Nick Knouf
Other related posts:
- » [visionegg] pre-loading a large number of stimuli
- » [visionegg] Re: pre-loading a large number of stimuli
- » [visionegg] Re: pre-loading a large number of stimuli
- » [visionegg] Re: pre-loading a large number of stimuli
- » [visionegg] Re: pre-loading a large number of stimuli
- » [visionegg] Re: pre-loading a large number of stimuli
- » [visionegg] Re: pre-loading a large number of stimuli
- [visionegg] pre-loading a large number of stimuli
- From: Nick Knouf