Documentation Center

  • Trial Software
  • Product Updates


Reset GPU device and clear its memory




reset(gpudev) resets the GPU device and clears its memory of gpuArray and CUDAKernel data. The GPU device identified by gpudev remains the selected device, but all gpuArray and CUDAKernel objects in MATLAB representing data on that device are invalid.



GPUDevice object representing the currently selected device


After you reset a GPU device, any variables representing arrays or kernels on the device are invalid; you should clear or redefine them.


expand all

Reset GPU Device

Create a gpuArray on the selected GPU device, then reset the device.

g = gpuDevice(1);
M = gpuArray(magic(4));
M  % Display gpuArray
    16     2     3    13
     5    11    10     8
     9     7     6    12
     4    14    15     1
g   % Show that the device is still selected
  parallel.gpu.CUDADevice handle
  Package: parallel.gpu

                      Name: 'Tesla C1060'
                     Index: 1
         ComputeCapability: '1.3'
            SupportsDouble: 1
             DriverVersion: 5
            ToolkitVersion: 5
        MaxThreadsPerBlock: 512
          MaxShmemPerBlock: 16384
        MaxThreadBlockSize: [512 512 64]
               MaxGridSize: [65535 65535 1]
                 SIMDWidth: 32
               TotalMemory: 4.2948e+09
                FreeMemory: 4.2091e+09
       MultiprocessorCount: 30
              ClockRateKHz: 1296000
               ComputeMode: 'Default'
      GPUOverlapsTransfers: 1
    KernelExecutionTimeout: 0
          CanMapHostMemory: 1
           DeviceSupported: 1
            DeviceSelected: 1
whos  %Show that the gpuArray variable name 
      %is still in the MATLAB workspace
  Name      Size      Bytes  Class
  g         1x1         112  parallel.gpu.CUDADevice
  M         1x1         108  gpuArray
M  % Try to display gpuArray
Data no longer exists on the GPU.
clear M

See Also

| |

Was this topic helpful?