Skip to content

Commit

Permalink
fix(//py): Don't crash harshly on import when CUDA is not available
Browse files Browse the repository at this point in the history
Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]>
  • Loading branch information
narendasan committed Oct 20, 2021
1 parent 4a0a918 commit 07e16fd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion py/trtorch/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ def _from_torch_device(cls, torch_dev: torch.device):

@classmethod
def _current_device(cls):
dev = trtorch._C._get_current_device()
try:
dev = trtorch._C._get_current_device()
except RuntimeError:
trtorch.logging.log(trtorch.logging.Level.Error, "Cannot get current device")
return None
return cls(gpu_id=dev.gpu_id)

@staticmethod
Expand Down

0 comments on commit 07e16fd

Please sign in to comment.