Merge pull request #410 from madrang/beta

Only default to cpu on auto or current when cuda not available.
This commit is contained in:
cmdr2 2022-10-28 10:43:28 +05:30 committed by GitHub
commit ae553dfed3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,9 +112,12 @@ def device_init(device_selection=None):
thread_data.device = 'cpu'
return
if not torch.cuda.is_available():
if device_selection == 'auto' or device_selection == 'current':
print('WARNING: torch.cuda is not available. Using the CPU, but this will be very slow!')
thread_data.device = 'cpu'
return
else:
raise EnvironmentError('torch.cuda is not available.')
device_count = torch.cuda.device_count()
if device_count <= 1 and device_selection == 'auto':
device_selection = 'current' # Use 'auto' only when there is more than one compatible device found.