0
将设备设置为1时,以及将设备上的'ptr'复制到'host_ptr'之前,必须将设备重新设置为1,才能将ptr置入?当设备到主机'cudaMemcpy'时,我是否必须设置适当的设备?
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);
@Shadow我测试了两个,所有的工作。所以我很困惑 –