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

Function set_device

tools/infer_det.py:143–150  ·  view source on GitHub ↗
(device, numId=0)

Source from the content-addressed store, hash-verified

141
142
143def set_device(device, numId=0):
144 import torch
145 if device == 'gpu' and torch.cuda.is_available():
146 device = torch.device(f'cuda:{numId}')
147 else:
148 logger.info('GPU is not available, using CPU.')
149 device = torch.device('cpu')
150 return device
151
152
153class OpenDetector(object):

Callers 1

_init_torch_modelMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected