Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: ensure GPU is available in GPU tests #4191

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions source/tests/pt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import torch

from ..common import (
TEST_DEVICE,
)

torch.set_num_threads(1)
torch.set_num_interop_threads(1)
# testing purposes; device should always be set explicitly
torch.set_default_device("cuda:9999999")

# ensure GPU is used when testing GPU code
if TEST_DEVICE == "cuda":
assert torch.cuda.is_available()
9 changes: 9 additions & 0 deletions source/tests/tf/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from ..common import (
TEST_DEVICE,
)

# ensure GPU is used when testing GPU code
if TEST_DEVICE == "cuda":
import tensorflow as tf

assert tf.test.is_gpu_available()
Loading