Overview
TheDevice class abstracts computational hardware, allowing Neurenix to run on various platforms including CPU, CUDA, ROCm, TPU, NPU, WebGPU, and more.
DeviceType Enum
Device Class
Parameters
DeviceType
required
The type of the device (CPU, CUDA, TPU, etc.).
int
default:"0"
The index of the device (for multiple devices of the same type).
Properties
type
DeviceType
The device type.
index
name
str
Device name string (e.g., “CUDA:0”, “CPU”).
Class Methods
device_count
int
The total number of devices available.
Module Functions
get_device
str
required
String representation of the device (e.g., ‘cpu’, ‘cuda:0’, ‘tpu:1’).
Device
The corresponding device object.
get_device_count
DeviceType
required
The type of device to count.
int
The number of devices of the given type.
get_available_devices
List[Device]
A list of available devices.
Example Usage
Supported Devices
CPU
Standard CPU execution
CUDA
NVIDIA GPU acceleration
ROCm
AMD GPU acceleration
TPU
Google Tensor Processing Units
NPU
Neural Processing Units
WebGPU
Browser-based GPU acceleration
Vulkan
Cross-platform GPU API
OpenCL
Open Computing Language
oneAPI
Intel unified programming model