[SciPy-user] shared memory machines

Philip Semanchuk philip@semanchuk....
Tue Feb 10 17:23:13 CST 2009


On Feb 10, 2009, at 6:13 PM, Gael Varoquaux wrote:

> Now I am stuck because shared memory allocation is not working. This
> boils down to the following traceback:
>
> Traceback (most recent call last):
>  File "test.py", line 4, in <module>
>    a = shmem.shared_zeros(10)
>  File "ndarray.py", line 135, in shared_zeros
>    arr = shared_empty(shape, dtype, order)
>  File "ndarray.py", line 126, in shared_empty
>    wrapper = heap.BufferWrapper(nbytes)
>  File "array_heap.py", line 168, in __init__
>    block = BufferWrapper._heap.malloc(size)
>  File "array_heap.py", line 148, in malloc
>    (arena, start, stop) = self._malloc(size)
>  File "array_heap.py", line 70, in _malloc
>    arena = Arena(length)
>  File "array_heap.py", line 37, in __init__
>    self.buffer = SharedMemoryBuffer(size)
>  File "sharedmemory_sysv.pyx", line 170, in
> sharedmemory_sysv.SharedMemoryBuffer.__init__ (sharedmemory_sysv.c: 
> 1400)
>    raise OSError, "Failed to attach shared memory: permission denied"
> OSError: Failed to attach shared memory: permission denied
>
> Basically this means that the shmat on line 167 of  
> sharedmemory_sysv.pyx
> is failing. I don't really know why, but I suspect this might be
> something stupid.

One problem I see is that the call to shmget() specifies no  
permissions. The third param to shmget() should  contain two sets of  
bitwise params OR-ed together. The first set is IPC_CREAT and  
IPC_EXCL, the second set is the permissions. So you might want to  
change line 156 to this:
shmid = shmget(key, buf_size, IPC_CREAT | IPC_EXCL | 0600)
or this:
shmid = shmget(key, buf_size, IPC_CREAT | IPC_EXCL | 0666)

http://www.opengroup.org/onlinepubs/009695399/functions/shmget.html




More information about the SciPy-user mailing list