主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

reset

重置 GPU 设备并清除其内存

说明

reset(gpudev) 重置 GPU 设备并清除其内存中的 gpuArrayCUDAKernel 数据。由 gpudev 识别出的 GPU 设备仍然是选定的设备,但 MATLAB® 中代表该设备上的数据的所有 gpuArrayCUDAKernel 对象均无效。设备的 CachePolicy 属性被重置为默认值。有关详细信息,请参阅 gpuDevice

示例

示例

全部折叠

选择 GPU 设备并创建 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(D);

表明该设备仍然被选中。

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.

表明 gpuArray 变量名仍在 MATLAB 工作区中。

whos
  Name      Size            Bytes  Class                      Attributes

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

尝试显示 gpuArray

M
M =

    Data no longer exists on the GPU.

清除变量。

clear M

输入参数

全部折叠

GPU 设备,指定为 GPUDevice 对象,代表当前选定的设备

提示

重置 GPU 设备后,设备上代表数组或内核的任何变量均无效;您应该清除或重新定义它们。

扩展功能

全部展开

版本历史记录

在 R2012a 中推出

另请参阅

| |