(device, numId=0)
| 179 | |
| 180 | |
| 181 | def 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 | |
| 193 | class OpenRecognizer: |