Skip to main content

A utility library to select and handle devices (CPU/GPU) seamlessly.

Project description

device-selector

A small Python library to automatically pick the best available PyTorch device.

  • select_best_device()
    Automatically returns one of:

    • "cuda" if an NVIDIA GPU is available via CUDA
    • "mps" if you're on Apple Silicon with Metal Performance Shaders available
    • "cpu" otherwise
  • check_or_select_device(requested_device: Optional[str])

    • If requested_device is None, it behaves like select_best_device().
    • Otherwise, checks if the requested device is actually available and raises an error if not.

Installation

pip install https://github.com/darizae/device-selector/releases/download/v0.1.0/device_selector-0.1.0-py3-none-any.whl

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

device_selector-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

device_selector-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file device_selector-0.1.0.tar.gz.

File metadata

  • Download URL: device_selector-0.1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for device_selector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9a6b52c68bb28cf271e0dbc3b7ee797519a08eaf6167b5f87d2c46b13e38bed6
MD5 91d06e62aee332833cc5f0c9e6be9b15
BLAKE2b-256 6026aa3353b602ec1ca07c8516e1a842948bb8bcf31f9e61063caae126a08694

See more details on using hashes here.

File details

Details for the file device_selector-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for device_selector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9138bd62ee3cc76c67f55e56c4e3aa95191a30c2173fedb4280ee4ec2bfe99b
MD5 a9230b3df20810d822a2c4b5274d1ae3
BLAKE2b-256 4696bfd7039113fdf1d361817bca3e9bc4fdeaa89225bab6afffcff4ba29153d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page