select GPU0 if multiple available
This commit is contained in:
@@ -6,7 +6,6 @@ def init_seeds(seed=0):
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.manual_seed(seed)
|
||||
torch.cuda.manual_seed_all(seed)
|
||||
# torch.cuda.set_device(0) # OPTIONAL: Set your GPU if multiple available
|
||||
|
||||
|
||||
def select_device(force_cpu=False):
|
||||
@@ -14,5 +13,11 @@ def select_device(force_cpu=False):
|
||||
device = torch.device('cpu')
|
||||
else:
|
||||
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
||||
|
||||
if torch.cuda.device_count() > 1:
|
||||
print('WARNING Using GPU0 Only. Multi-GPU issue: https://github.com/ultralytics/yolov3/issues/21')
|
||||
torch.cuda.set_device(0) # OPTIONAL: Set your GPU if multiple available
|
||||
# print('Using ', torch.cuda.device_count(), ' GPUs')
|
||||
|
||||
print('Using ' + str(device) + '\n')
|
||||
return device
|
||||
|
||||
Reference in New Issue
Block a user