• Docs >
  • Utils >
  • torchtnt.utils.device.get_device_from_env
Shortcuts

torchtnt.utils.device.get_device_from_env

torchtnt.utils.device.get_device_from_env() device

Function that gets the torch.device based on the current environment.

This currently supports only CPU and GPU devices. If CUDA is available, this function also sets the CUDA device.

Within a distributed context, this function relies on the LOCAL_RANK environment variable to be made available by the program launcher for setting the appropriate device index.

Raises:RuntimeError – If LOCAL_RANK is outside the range of available GPU devices.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources