识别和选择一个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
启用的功能。有关更多信息,请参见运行在GPU MATLAB函数。
使用另一个设备,电话gpuDevice
与其他设备的索引。
gpuDevice (2)
ans = CUDADevice属性:名称:“方形住宅区P620”指数:2 ComputeCapability:“6.1”SupportsDouble: 1 GraphicsD万博1manbetxriverVersion:“511.79”DriverModel:“WDDM”ToolkitVersion: 11.2000 MaxThreadsPerBlock: 1024 MaxShmemPerBlock: 49152 (49.15 KB) MaxThreadBlockSize: [1024 1024 64] MaxGridSize: [2.1475 e + 09年65535 65535]SIMDWidth: 32 TotalMemory: 2147287040 (2.15 GB) AvailableMemory: 1615209678 (1.62 GB) CachePolicy:“平衡”MultiprocessorCount: 4 ClockRateKHz: 0 ComputeMode:“违约”GPUOverlapsTransfers: 1 KernelExecutionTimeout: 1 CanMapHostMemory: 1 DeviceSupported: 1 DeviceAvailable: 1 DeviceSelected: 1
或者,您可以确定有多少GPU设备可用,检查他们的一些属性,并选择一个设备使用MATLAB®桌面。在家选项卡,环境区域,选择平行>选择GPU环境。
另请参阅
gpuDevice
|gpuDeviceCount
|gpuArray
|gpuDeviceTable