https://github.com/mvinyard/autodevice
Automatically assign devices in-line with pytorch code
https://github.com/mvinyard/autodevice
hardware python pytorch
Last synced: 3 months ago
JSON representation
Automatically assign devices in-line with pytorch code
- Host: GitHub
- URL: https://github.com/mvinyard/autodevice
- Owner: mvinyard
- License: mit
- Created: 2023-01-03T22:59:08.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-16T21:18:56.000Z (almost 2 years ago)
- Last Synced: 2025-06-01T20:52:33.915Z (4 months ago)
- Topics: hardware, python, pytorch
- Language: Python
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# autodevice
Automatically assign devices in-line with pytorch code
### Usage
```python
from autodevice import AutoDevicex = torch.randn([200, 50]).to(AutoDevice())
```
CUDA/GPU:
```
tensor([[ 2.6905, -0.3037, -0.3607],
[ 0.2258, -0.1755, 0.6599],
[ 1.3046, -0.9389, 0.7358]], device='cuda:0')
```
CPU:
```
tensor([[ 2.6905, -0.3037, -0.3607],
[ 0.2258, -0.1755, 0.6599],
[ 1.3046, -0.9389, 0.7358]])
```
On Apple Silicon (M1, M2):
```
tensor([[ 0.5382, 1.1173, 1.1175],
[-0.0125, -0.2406, 0.2343],
[-0.6067, -0.7728, 0.1697]], device='mps:0')
```
### Installation```
pip install autodevice
```