主要内容

识别并选择GPU设备

这个例子展示了如何使用gpuDevice来识别和选择要使用的设备。

若要确定计算机中有多少GPU设备可用,请使用gpuDeviceCount函数。

gpuDeviceCount (“可用”
Ans = 2

当有多个设备时,第一个是默认的。方法检查其属性gpuDeviceTable函数来确定它是否是您想要使用的。

gpuDeviceTable
ans =2×5表索引名称ComputeCapability DeviceAvailable DeviceSelected  _____ __________________ _________________ _______________ ______________ 1”NVIDIA RTX A5000”“8.6”真的真的2”住宅区P620”“6.1”真的假的

如果第一个设备是您想要使用的设备,则可以继续。在GPU上运行计算时,使用gpuArray启用的功能。有关更多信息,请参见在图形处理器上运行MATLAB函数

要使用其他设备,请呼叫gpuDevice与其他设备的索引。

gpuDevice (2)
ans = CUDADevice with properties: Name: 'Quadro P620' Index: 2 ComputeCapability: '6.1' 金宝appSupportsDouble: 1 DriverVersion: 11.6000 ToolkitVersion: 11.2000 MaxThreadsPerBlock: 1024 MaxShmemPerBlock: 49152 (49.15 KB) MaxThreadBlockSize: [1024 1024 64] MaxGridSize: [2.1475e+09 65535 65535] SIMDWidth: 32 TotalMemory: 2147287040 (2.15 GB) AvailableMemory: 1617716430 (1.62 GB) MultiprocessorCount: 4 ClockRateKHz: 1354000 ComputeMode: 'Default' GPUOverlapsTransfers: 1 KernelExecutionTimeout:1 CanMapHostMemory: 1 Device金宝appSupported: 1 DeviceAvailable: 1 DeviceSelected: 1

另请参阅

|||

相关的话题