|On this page…|
If you have only one GPU in your computer, that GPU is the default. If you have more than one GPU device in your computer, you can use the following functions to identify and select which device you want to use:
|gpuDeviceCount||The number of GPU devices in your computer|
|gpuDevice||Select which device to use, or see which device is selected and view its properties|
This example shows how to identify and select a GPU for your computations.
Determine how many GPU devices are in your computer:
With two devices, the first is the default. You can examine its properties to determine if that is the one you want to use:
gpuDevice parallel.gpu.CUDADevice handle Package: parallel.gpu Properties: Name: 'Tesla C1060' Index: 1 ComputeCapability: '1.3' SupportsDouble: 1 DriverVersion: 5 ToolkitVersion: 5 MaxThreadsPerBlock: 512 MaxShmemPerBlock: 16384 MaxThreadBlockSize: [512 512 64] MaxGridSize: [65535 65535 1] SIMDWidth: 32 TotalMemory: 4.2948e+09 FreeMemory: 4.2563e+09 MultiprocessorCount: 30 ClockRateKHz: 1296000 ComputeMode: 'Default' GPUOverlapsTransfers: 1 KernelExecutionTimeout: 0 CanMapHostMemory: 1 DeviceSupported: 1 DeviceSelected: 1
If this is the device you want to use, you can proceed.
To use another device, call gpuDevice with the index of the other device, and view its properties to verify that it is the one you want. For example, this step chooses and views the second device (indexing is 1-based):