-
Notifications
You must be signed in to change notification settings - Fork 739
Closed
Description
We use skipIfNoCuda decorator to skip CUDA tests when CUDA is not available. This is nice but in CI with GPUs we should raise an error if CUDA is not available. We should update the decorator, so that we can provide further option to fail.
Setup
Please refer to the CONTRIBUTING.md for setting up torchaudio development environment.
Steps
- Update the decorator to something like the following:
def skipIfNoCuda(test_item):
if torch.cuda.is_available():
return test_item
force_cuda_test = os.environ.get('TORCHAUDIO_TEST_FORCE_CUDA', '0')
if force_cuda_test not in ['0', '1']:
raise ValueError('"TORCHAUDIO_TEST_FORCE_CUDA" must be either "0" or "1".')
if force_cuda_test == '1':
raise RuntimeError('"TORCHAUDIO_TEST_FORCE_CUDA" is set but CUDA is not available.')
return unittest.skip('CUDA is not available.')(test_item)- Update CI to device
TORCHAUDIO_TEST_FORCE_CUDAenvironment variable- Add the definition here and here
- Run
.circleci/regenerate.py, so that.circleci/config.ymlis updated. - Use CircleCI CLI to verify that the
config.ymlis valid. (circleci config validate)
Test
- local test
This should work
CUDA_VISIBLE_DEVICES=0 TORCHAUDIO_TEST_FORCE_CUDA=0 pytest test/torchaudio_unittest/functional/torchscript_consistency_cuda_test.py
This should fail
CUDA_VISIBLE_DEVICES=0 TORCHAUDIO_TEST_FORCE_CUDA=1 pytest test/torchaudio_unittest/functional/torchscript_consistency_cuda_test.py
- CI test
Please make a draft PR and see if the GPU tests pass.