What are you trying to achieve using the queue?
Have a look at the Multiprocessing Best Practices, as it might get tricky.



 Wayne_Mai:

What’s more, if I hard code a list, dict or something else (eg. x=[1,2,3,4,5] ) in my model code, will it ( list[1,2,3,4,5] ) be migrated to GPU memory automatically when use model.cuda() ?


No, plain Python types won’t be pushed to the GPU. You would have to create a tensor and register it as an nn.Parameter (if trainable) or buffer (using self.register_buffer, if not trainable).