Skip to main content

Overview

The Device 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

Get the type of the device.
DeviceType
The device type.

index

Get the index of the device.

name

Get the name of the device.
str
Device name string (e.g., “CUDA:0”, “CPU”).

Class Methods

device_count

Get the total number of devices available.
int
The total number of devices available.

Module Functions

get_device

Get a device from a string representation.
str
required
String representation of the device (e.g., ‘cpu’, ‘cuda:0’, ‘tpu:1’).
Device
The corresponding device object.

get_device_count

Get the number of devices of the given type.
DeviceType
required
The type of device to count.
int
The number of devices of the given type.

get_available_devices

Get a list of all 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