Forming numpy array from array buffer from shared memory (multiprocessing) fails

前端 未结 1 1093
谎友^
谎友^ 2021-01-12 05:49

I need to have a multidimensional array in a shared memory between two processes. I\'m trying to make a simple example that works: I send [1, 2, 3, 4, 5, 6, 7, 8, 9]

相关标签:
1条回答
  • 2021-01-12 06:01

    The dtype for the numpy array needs to be explicitly set as a 32-bit integer.

    nmp = numpy.frombuffer(array.get_obj(), dtype="int32")
    

    If you are on a 64-bit machine, it is likely that you were trying to cast the 32-bit ctypes array as a 64-bit numpy array.

    0 讨论(0)
提交回复
热议问题