🚀 Feature
Add an option to run GPU tests only, and skip all CPU tests
For example, we can have an environment variable PYTORCH_TEST_GPU_ONLY=1.
Motivation
Usually, when people only want to test GPU functionalities, they can skip CPU tests to save plenty of times.
Pitch
For example, some pytorch tests look like (assuming pytorch built with GPU)
def test_something(self, device):
# do something
At runtime, two tests test_something_cpu and test_something_cuda will be generated. The goal is to skip the test_something_cpu test and only run test_something_cuda.
For example, we can do it like this
PYTORCH_TEST_GPU_ONLY=1 python test/run_test.py
Alternatives
N/A
How to implement
If I understand the code correctly, this feature can be easily implemented like this
-
Add TEST_GPU_ONLY = os.getenv('PYTORCH_TEST_GPU_ONLY', '0') == '1' here
|
TEST_SKIP_FAST = os.getenv('PYTORCH_TEST_SKIP_FAST', '0') == '1' |
|
|
-
Add something like
if TEST_GPU_ONLY:
fullname = self.id().lower()
is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type
if not is_cuda_test:
raise unittest.SkipTest("Test is probably not a GPU test. We disabled it with PYTORCH_TEST_GPU_ONLY")
here in setup of class common_utils.TestCase
|
def setUp(self): |
|
|
|
|
|
if TEST_SKIP_FAST: |
|
if not getattr(self, self._testMethodName).__dict__.get('slow_test', False): |
|
raise unittest.SkipTest("test is fast; we disabled it with PYTORCH_TEST_SKIP_FAST") |
|
check_disabled(str(self)) |
|
|
|
set_rng_seed(SEED) |
Additional context
N/A
cc @mruberry @VitalyFedyunin @ptrblck @ngimel
🚀 Feature
Add an option to run GPU tests only, and skip all CPU tests
For example, we can have an environment variable
PYTORCH_TEST_GPU_ONLY=1.Motivation
Usually, when people only want to test GPU functionalities, they can skip CPU tests to save plenty of times.
Pitch
For example, some pytorch tests look like (assuming pytorch built with GPU)
At runtime, two tests
test_something_cpuandtest_something_cudawill be generated. The goal is to skip thetest_something_cputest and only runtest_something_cuda.For example, we can do it like this
Alternatives
N/A
How to implement
If I understand the code correctly, this feature can be easily implemented like this
Add
TEST_GPU_ONLY = os.getenv('PYTORCH_TEST_GPU_ONLY', '0') == '1'herepytorch/torch/testing/_internal/common_utils.py
Lines 346 to 347 in 665feda
Add something like
here in
setupofclass common_utils.TestCasepytorch/torch/testing/_internal/common_utils.py
Lines 825 to 833 in 665feda
Additional context
N/A
cc @mruberry @VitalyFedyunin @ptrblck @ngimel