Skip to content

Commit

Permalink
fix for crash when running #12924 without --device-id
Browse files Browse the repository at this point in the history
  • Loading branch information
AUTOMATIC1111 committed Sep 9, 2023
1 parent 558baff commit 46375f0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def enable_tf32():

# enabling benchmark option seems to enable a range of cards to do fp16 when they otherwise can't
# see https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/4407
device_id = (int(shared.cmd_opts.device_id) if shared.cmd_opts.device_id.isdigit() else 0) or torch.cuda.current_device()
device_id = (int(shared.cmd_opts.device_id) if shared.cmd_opts.device_id is not None and shared.cmd_opts.device_id.isdigit() else 0) or torch.cuda.current_device()
if torch.cuda.get_device_capability(device_id) == (7, 5) and torch.cuda.get_device_name(device_id).startswith("NVIDIA GeForce GTX 16"):
torch.backends.cudnn.benchmark = True

Expand Down

0 comments on commit 46375f0

Please sign in to comment.