device
getDevice(device=None)
¶
Get CPU, GPU (CUDA), or MPS device for training.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device |
str
|
Device for training. If None or “auto”, the device is selected automatically based on availability. |
None
|
Returns:
Name | Type | Description |
---|---|---|
device |
str
|
Device for training. |
Raises:
Type | Description |
---|---|
ValueError
|
If the requested device is not recognized or available. |
Examples:
>>> from spotpython.utils.device import getDevice
getDevice()
'cuda:0'
Source code in spotpython/utils/device.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|