fuel
fuel copied to clipboard
Server code to send arrays is wrong
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.
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.
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.
I think I fixed this bug [https://github.com/mila-udem/fuel/pull/327]
@abergeron Hi, I did as what you said and modified line 73 in sever.py to socket.recv(copy=False). It works.