Add the device ID on which the memory was allocated.
You can also use cudaSetDevice(int) in the constructor and destructor to allocated and deallocate on the right GPU.
And maybe to avoid problem, you can use cudaGetDevice to know on which GPU this thread is currently. Change the GPU if needed with cudaSetDevice and restore it to the right device after.
Add the device ID on which the memory was allocated.
You can also use cudaSetDevice(int) in the constructor and destructor to allocated and deallocate on the right GPU.
And maybe to avoid problem, you can use cudaGetDevice to know on which GPU this thread is currently. Change the GPU if needed with cudaSetDevice and restore it to the right device after.