---
title: "Device"
sidebar_label: "Device"
description: "Kotlin binding reference: Device."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Device](index.md)

# Device

[common]\
data class [Device](index.md)(val api: [ComputeApi](../ComputeApi/index.md), val index: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)) : [Placement](../Placement/index.md)

A compute device: a backend api plus a device index. An accelerator index is zero-based and names one physical device; a CPU index names a SOCKET, with the whole machine at [WHOLE_MACHINE](Companion/WHOLE_MACHINE.md), so [CPU](Companion/CPU-property.md) uses every core and `Device.cpu(0)` confines work to socket 0.

```kotlin
val cpu  = Device.CPU
val gpu0 = Device.parse("cuda:0")
val t    = Tensors.zeros(longArrayOf(2, 3), where = gpu0)
```

## Constructors

| | |
|---|---|
| [Device](Device.md) | [common]<br>constructor(api: [ComputeApi](../ComputeApi/index.md))<br>A backend's default device: the whole machine on CPU, device 0 elsewhere.<br>constructor(api: [ComputeApi](../ComputeApi/index.md), index: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)) |

## Types

| Name | Summary |
|---|---|
| [Companion](Companion/index.md) | [common]<br>object [Companion](Companion/index.md) |

## Properties

| Name | Summary |
|---|---|
| [api](api.md) | [common]<br>val [api](api.md): [ComputeApi](../ComputeApi/index.md) |
| [index](index-property.md) | [common]<br>val [index](index-property.md): [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) |

## Functions

| Name | Summary |
|---|---|
| [currentSeed](currentSeed.md) | [common]<br>fun [currentSeed](currentSeed.md)(): [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)<br>The current seed of this device's generator (0 until seeded). |
| [manualSeed](manualSeed.md) | [common]<br>fun [manualSeed](manualSeed.md)(seed: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html))<br>Seed this device's random-number generator, so later random ops reproduce. |
| [memoryStats](memoryStats.md) | [common]<br>fun [memoryStats](memoryStats.md)(): [MemoryStats](../MemoryStats/index.md)<br>A point-in-time snapshot of this device's memory: the physical figures and the runtime pool's counters. |
| [properties](properties.md) | [common]<br>fun [properties](properties.md)(): [DeviceProperties](../DeviceProperties/index.md)<br>The static capabilities of this device: its name, kind, driver and runtime versions, compute geometry, memory and the dtypes the hardware accelerates. |
| [releaseCachedMemory](releaseCachedMemory.md) | [common]<br>fun [releaseCachedMemory](releaseCachedMemory.md)()<br>Return the runtime pool's idle memory for this device to the driver or the OS. Memory still in use is never touched. A closed model's bytes stay in the pool until this call or memory pressure; the Modelverse binding calls it at a model's close, and a program that closes a model of its own and loads another calls it in between. |
| [resetPeakMemoryStats](resetPeakMemoryStats.md) | [common]<br>fun [resetPeakMemoryStats](resetPeakMemoryStats.md)()<br>Restart the pool's high-water marks from the present occupancy; the measuring idiom's first step. |
| [synchronize](synchronize.md) | [common]<br>fun [synchronize](synchronize.md)()<br>Wait for every operation queued on this device's lanes. |
| [toString](toString.md) | [common]<br>open override fun [toString](toString.md)(): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) |