Skip to contents

Default torch device

Usage

default_device()

Value

Returns torch::torch_device("cuda") if torch::cuda_is_available(), or torch::torch_device("cpu") otherwise.

Examples

if(backend_is_installed()){
  device <- default_device()
  print(device)
}
#> torch_device(type='cpu')