MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / set_device

Function set_device

tools/infer_rec.py:181–190  ·  view source on GitHub ↗
(device, numId=0)

Source from the content-addressed store, hash-verified

179
180
181def set_device(device, numId=0):
182 import torch
183 if device == 'gpu' and torch.cuda.is_available():
184 device = torch.device(f'cuda:{numId}')
185 elif device == 'mps' and torch.backends.mps.is_available():
186 device = torch.device('mps')
187 else:
188 logger.info('GPU is not available, using CPU.')
189 device = torch.device('cpu')
190 return device
191
192
193class OpenRecognizer:

Callers 1

_init_torch_modelMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected