fuel icon indicating copy to clipboard operation
fuel copied to clipboard

Server code to send arrays is wrong

Open abergeron opened this issue 9 years ago • 4 comments

The code was clearly adapted from the example in this page: https://pyzmq.readthedocs.org/en/latest/serialization.html, but it does not pass the copy=False parameter to socket.recv(), which makes the received arrays non-aligned when your data type is bigger than 4 bytes.

abergeron avatar Dec 11 '15 02:12 abergeron

Could you elaborate a bit? In the page you link to, the default for recv_array is copy=True, which is the default of the recv function as well. It's just made non-configurable in the Fuel implementation.

bartvm avatar Dec 11 '15 06:12 bartvm

I've adapted the code to send/receive arrays for some other purpose and got an error from theano about arrays being not aligned.

The problem is that if you specify copy=True, it returns a string. Strings in python have their data inline and the header is 36 bytes long which is not a multiple of 8. Therefore for data types that are longer than 4 the array data is not aligned.

If you specify copy=False, you get a Frame object. It references the data through a pointer which does not have a header offset and you don't have the problem above.

abergeron avatar Dec 11 '15 15:12 abergeron

I think I fixed this bug [https://github.com/mila-udem/fuel/pull/327]

Beronx86 avatar Mar 07 '16 06:03 Beronx86

@abergeron Hi, I did as what you said and modified line 73 in sever.py to socket.recv(copy=False). It works.

Beronx86 avatar Mar 09 '16 08:03 Beronx86