主要内容

识别并选择GPU设备

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

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

gpuDeviceCount (“可用”
Ans = 2

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

gpuDeviceTable
ans =2×5表索引名称ComputeCapability DeviceAvailable DeviceSelected  _____ _____________ _________________ _______________ ______________ 1“泰坦RTX”“7.5”真的真的2”住宅区K620”“5.0”真的假的

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

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

gpuDevice (2)
ans = CUDADevice with properties: Name: 'Quadro K620' Index: 2 ComputeCapability: '5.0' 金宝appSupportsDouble: 1 DriverVersion: 11 ToolkitVersion: 10.2000 MaxThreadsPerBlock: 1024 MaxShmemPerBlock: 49152 MaxThreadBlockSize: [1024 1024 64] MaxGridSize: [2.1475e+09 65535 65535] SIMDWidth: 32 TotalMemory: 2.1475e+09 AvailableMemory: 1.6776e+09 MultiprocessorCount: 3 ClockRateKHz: 1124000 ComputeMode: 'Default' GPUOverlapsTransfers: 1 KernelExecutionTimeout: 1 CanMapHostMemory: 1 DeviceSupported:1 DeviceAvailable: 1 DeviceSelected: 1

另请参阅

|||

相关的话题