utils
get_cpu_id()
¶
Fetches the CPU ID based on the operating system.
Attempts to get the CPU ID for Windows, Linux, and MacOS. In case of any error or an unsupported OS, returns None.
Returns:
Type | Description |
---|---|
Optional[str]: CPU ID string if available, None otherwise. |
Source code in inference/core/devices/utils.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
get_device_hostname()
¶
Fetches the device's hostname.
Returns:
Name | Type | Description |
---|---|---|
str |
The device's hostname. |
Source code in inference/core/devices/utils.py
106 107 108 109 110 111 112 |
|
get_gpu_id()
¶
Fetches the GPU ID if a GPU is present.
Tries to import and use the GPUtil
module to retrieve the GPU information.
Returns:
Type | Description |
---|---|
Optional[int]: GPU ID if available, None otherwise. |
Source code in inference/core/devices/utils.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
get_inference_server_id()
¶
Fetches a unique device ID.
Tries to get the GPU ID first, then falls back to CPU ID. If the application is running inside Docker, the Docker container ID is appended to the hostname.
Returns:
Name | Type | Description |
---|---|---|
str |
A unique string representing the device. If unable to determine, returns "UNKNOWN". |
Source code in inference/core/devices/utils.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
get_jetson_id()
¶
Fetches the Jetson device's serial number.
Attempts to read the serial number from the device tree. In case of any error, returns None.
Returns:
Type | Description |
---|---|
Optional[str]: Jetson device serial number if available, None otherwise. |
Source code in inference/core/devices/utils.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
is_running_in_docker()
¶
Checks if the current process is running inside a Docker container.
Returns:
Name | Type | Description |
---|---|---|
bool |
True if running inside a Docker container, False otherwise. |
Source code in inference/core/devices/utils.py
10 11 12 13 14 15 16 |
|