This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


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 DATA is still present on the GPU and available from your MATLAB session. The result is false if 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)


collapse all

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
M_exists = existsOnGPU(M)
M  % Try to display gpuArray
Data no longer exists on the GPU.
clear M

Introduced in R2012a

Was this topic helpful?