While this list may seem like an Array, it is a JavaScript Proxy that only creates and
returns a Device instance for a given device ordinal the first time it's accessed.
Note
Enumerating the devices list (i.e. [...devices]) will create and cache Device instances
for all CUDA devices available to the current process.
Example
import {Device, devices} from'@rapidsai/cuda';
console.log(`Number of devices: ${devices.length}`);
// CUDA Device 0 is automatically activated by default console.log(`Active device id: ${Device.activeDeviceId}`); // 0
Note
While this list may seem like an Array, it is a JavaScript Proxy that only creates and returns a Device instance for a given device ordinal the first time it's accessed.
Note
Enumerating the
deviceslist (i.e.[...devices]) will create and cache Device instances for all CUDA devices available to the current process.Example