I need to create a random vector with a specific distribution each iteration and run it in gpu/cuda. I know one can do x.cuda() on it but that seems rather slow based on me playing around with it. Is there a better way to do this so that it starts of in GPU or something of that sort? Especially cuz Im doing this every iteration.

Obviously if it generalizes it such that any vector/tensor I create are directly set to CUDA that would be very nice.

Note I want it to make sure it does not screw up my dataloader. For example I am aware that:
torch.default_tensor_type

might screw up my data loader.