Determine if gpuArray or CUDAKernel is available on GPU
TF = existsOnGPU(DATA)
TF = existsOnGPU(DATA) returns a logical value indicating
whether the gpuArray or CUDAKernel object represented by
still present on the GPU and available from your MATLAB session. The result is
DATA is no longer valid and
cannot be used. Such arrays and kernels are invalidated when the GPU device has been
reset with any of the following:
reset(dev) % Where dev is the current gpuDevice gpuDevice(ix) % Where ix is valid index of current or different device gpuDevice() % With an empty argument (as opposed to no argument)
Create a gpuArray on the selected GPU device, then reset the device. Query array’s existence and content before and after resetting.
g = gpuDevice(1); M = gpuArray(magic(4)); M_exists = existsOnGPU(M)
M % Display gpuArray
16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
reset(g); M_exists = existsOnGPU(M)
M % Try to display gpuArray
Data no longer exists on the GPU.