Do I have to set the proper device when 'cudaMemcpy' from device to host?

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?

cross posting:

[url]cuda - Do I have to set the proper device when 'cudaMemcpy' from device to host? - Stack Overflow