Main Content

reset

Reset GPU device and clear its memory

Description

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. The CachePolicy property of the device is reset to the default. For more information, see gpuDevice.

example

Examples

collapse all

Select the GPU device and create a gpuArray.

D = gpuDevice;
M = eye(4,"gpuArray")
M =

     1     0     0     0
     0     1     0     0
     0     0     1     0
     0     0     0     1

Reset the device.

reset(D);

Show that the device is still selected.

D
D = 
  CUDADevice with properties:

                 Name: 'NVIDIA RTX A5000'
                Index: 1 (of 2)
    ComputeCapability: '8.6'
          DriverModel: 'TCC'
          TotalMemory: 25544294400 (25.54 GB)
      AvailableMemory: 23952556032 (23.95 GB)
      DeviceAvailable: true
       DeviceSelected: true

  Show all properties.

Show that the gpuArray variable name is still in the MATLAB workspace.

whos
  Name      Size            Bytes  Class                      Attributes

  D         1x1                 8  parallel.gpu.CUDADevice              
  M         4x4                 0  gpuArray                             

Try to display the gpuArray.

M
M =

    Data no longer exists on the GPU.

Clear the variable.

clear M

Input Arguments

collapse all

GPU device, specified as a GPUDevice object that represents the currently selected device

Tips

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

Extended Capabilities

expand all

Version History

Introduced in R2012a