Skip to content

Conversation

@mruberry
Copy link
Collaborator

  • Creates @skipCUDAIfNoCudnn, @skipCUDAIfCudnnVersionLessThan decorators
  • Makes several test_nn.py tests generic

Many tests in test_nn.py test cuDNN. These tests are guarded on various conditionals using TEST_CUDNN and TEST_CUDNN_VERSION imported from common_cuda.py and custom error messages like 'CUDNN not available' and 'needs cudnn.'

This PR suggests using the CUDA base test class instead of common_cuda.py to test cuDNN's availability, at least on generic tests. The CUDA base test class is preferable to common_cuda.py since it only creates a CUDA context if its tests are run. Importing from common_cuda.py, on the other hand, always creates a CUDA context. Using the CUDA base test class is also consistent with how other generic tests are guarded and provides consistent skip messages.

One quirk to this approach is that it makes use of the self argument to the test functions to check for cuDNN availability during a test. See test_rnn_retain_variables. The self argument could also be used to check the device type instead of the more verbose torch.device(device).type == 'cuda'.

An alternative approach to making test_nn.py generic would be to continue to use common_cuda.py imports, try to keep their skip messages consistent, and not worry about creating unnecessary CUDA contexts. This would preclude writing generic tests that can only run on CUDA if cuDNN is available, however, so tests like "_test_RNN_cpu_vs_cudnn" would require additional changes to make into device generic precision tests like "_test_RNN_cpu_vs_xla."

For consistency, simplicity, and ease of use, I recommend we adopt the proposed decorators and make use of the self argument when productive.

@pytorchbot pytorchbot added the module: nn Related to torch.nn label Sep 25, 2019
@mruberry mruberry requested a review from gchanan September 25, 2019 08:35
facebook-github-bot pushed a commit that referenced this pull request Sep 30, 2019
Summary:
Make cudnn rnn respect current stream. After this lands, non-default test stream can be reenabled in #26791
Pull Request resolved: #27026

Test Plan: default stream functionality is tested in existing tests, stream safety tests will be added in #26791

Differential Revision: D17656967

Pulled By: ngimel

fbshipit-source-id: 8b051aedd1df089b21f666ec553a5acefffdac88
zdevito pushed a commit to zdevito/ATen that referenced this pull request Sep 30, 2019
Summary:
Make cudnn rnn respect current stream. After this lands, non-default test stream can be reenabled in pytorch/pytorch#26791
Pull Request resolved: pytorch/pytorch#27026

Test Plan: default stream functionality is tested in existing tests, stream safety tests will be added in pytorch/pytorch#26791

Differential Revision: D17656967

Pulled By: ngimel

fbshipit-source-id: 8b051aedd1df089b21f666ec553a5acefffdac88
@mruberry mruberry requested review from ngimel and removed request for gchanan September 30, 2019 16:24
@mruberry
Copy link
Collaborator Author

@pytorchbot rebase this please.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@mruberry mruberry force-pushed the test_nn_generic_expansion branch from 96d3781 to b52e32c Compare October 1, 2019 00:23
@mruberry
Copy link
Collaborator Author

mruberry commented Oct 1, 2019

@pytorchbot rebase this please

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mruberry is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@mruberry mruberry deleted the test_nn_generic_expansion branch October 1, 2019 09:37
@facebook-github-bot
Copy link
Contributor

@mruberry merged this pull request in 3099732.

pdlive215 pushed a commit to pdlive215/pytorch that referenced this pull request Nov 27, 2019
Summary:
Make cudnn rnn respect current stream. After this lands, non-default test stream can be reenabled in pytorch#26791
Pull Request resolved: pytorch#27026

Test Plan: default stream functionality is tested in existing tests, stream safety tests will be added in pytorch#26791

Differential Revision: D17656967

Pulled By: ngimel

fbshipit-source-id: 8b051aedd1df089b21f666ec553a5acefffdac88
pdlive215 pushed a commit to pdlive215/pytorch that referenced this pull request Nov 27, 2019
Summary:
- Creates skipCUDAIfNoCudnn, skipCUDAIfCudnnVersionLessThan decorators
- Makes several test_nn.py tests generic

Many tests in test_nn.py test cuDNN. These tests are guarded on various conditionals using TEST_CUDNN and TEST_CUDNN_VERSION imported from common_cuda.py and custom error messages like 'CUDNN not available' and 'needs cudnn.'

This PR suggests using the CUDA base test class instead of common_cuda.py to test cuDNN's availability, at least on generic tests. The CUDA base test class is preferable to common_cuda.py since it only creates a CUDA context if its tests are run. Importing from common_cuda.py, on the other hand, always creates a CUDA context. Using the CUDA base test class is also consistent with how other generic tests are guarded and provides consistent skip messages.

One quirk to this approach is that it makes use of the self argument to the test functions to check for cuDNN availability during a test. See test_rnn_retain_variables. The self argument could also be used to check the device type instead of the more verbose torch.device(device).type == 'cuda'.

An alternative approach to making test_nn.py generic would be to continue to use common_cuda.py imports, try to keep their skip messages consistent, and not worry about creating unnecessary CUDA contexts. This would preclude writing generic tests that can only run on CUDA if cuDNN is available, however, so tests like "_test_RNN_cpu_vs_cudnn" would require additional changes to make into device generic precision tests like "_test_RNN_cpu_vs_xla."

For consistency, simplicity, and ease of use, I recommend we adopt the proposed decorators and make use of the self argument when productive.
Pull Request resolved: pytorch#26791

Differential Revision: D17678325

Pulled By: mruberry

fbshipit-source-id: 1794735ede9bc9f36856e72b3804b136ad3e0de2
thiagocrepaldi pushed a commit to thiagocrepaldi/pytorch that referenced this pull request Feb 4, 2020
Summary:
- Creates skipCUDAIfNoCudnn, skipCUDAIfCudnnVersionLessThan decorators
- Makes several test_nn.py tests generic

Many tests in test_nn.py test cuDNN. These tests are guarded on various conditionals using TEST_CUDNN and TEST_CUDNN_VERSION imported from common_cuda.py and custom error messages like 'CUDNN not available' and 'needs cudnn.'

This PR suggests using the CUDA base test class instead of common_cuda.py to test cuDNN's availability, at least on generic tests. The CUDA base test class is preferable to common_cuda.py since it only creates a CUDA context if its tests are run. Importing from common_cuda.py, on the other hand, always creates a CUDA context. Using the CUDA base test class is also consistent with how other generic tests are guarded and provides consistent skip messages.

One quirk to this approach is that it makes use of the self argument to the test functions to check for cuDNN availability during a test. See test_rnn_retain_variables. The self argument could also be used to check the device type instead of the more verbose torch.device(device).type == 'cuda'.

An alternative approach to making test_nn.py generic would be to continue to use common_cuda.py imports, try to keep their skip messages consistent, and not worry about creating unnecessary CUDA contexts. This would preclude writing generic tests that can only run on CUDA if cuDNN is available, however, so tests like "_test_RNN_cpu_vs_cudnn" would require additional changes to make into device generic precision tests like "_test_RNN_cpu_vs_xla."

For consistency, simplicity, and ease of use, I recommend we adopt the proposed decorators and make use of the self argument when productive.
Pull Request resolved: pytorch#26791

Differential Revision: D17678325

Pulled By: mruberry

fbshipit-source-id: 1794735ede9bc9f36856e72b3804b136ad3e0de2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: nn Related to torch.nn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants