Skip to content

Commit

Permalink
only run torchvision sanity check command test if GPU is present
Browse files Browse the repository at this point in the history
  • Loading branch information
jfgrimm committed Feb 28, 2024
1 parent a2864e7 commit 454c5ee
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions easybuild/easyblocks/t/torchvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ def sanity_check_step(self):
# the-cuda-backend-this-could-be-because-the-operator-doesnt-exist-for-this-backend/132352/4
if self.with_cuda:
custom_commands = []
python_code = '; '.join([
python_code = '\n'.join([
"import torch, torchvision",
"boxes = torch.tensor([[0., 1., 2., 3.]]).to('cuda')",
"scores = torch.randn(1).to('cuda')",
"print(torchvision.ops.nms(boxes, scores, 0.5))",
"if torch.cuda.device_count():",
" boxes = torch.tensor([[0., 1., 2., 3.]]).to('cuda')",
" scores = torch.randn(1).to('cuda')",
" print(torchvision.ops.nms(boxes, scores, 0.5))",
])
custom_commands.append('python -c "%s"' % python_code)
custom_paths = {
Expand Down

0 comments on commit 454c5ee

Please sign in to comment.