cudaSetDevice(1);
cudaMalloc(ptr, size);
//do something here
...
cudaSetDevice(0);
//do something here
...
//cudaSetDevice(1); #My qustion: is this line needed?
cudaMemcpy(host_ptr, ptr, size, cudaMemcpyDeviceToHost);
My question is: ptr is malloced when set device to 1, and before copying ‘ptr’ to ‘host_ptr’ from device to host, do I have to set device to 1 again?