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

Fix CPU ASR tests #11042

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions nemo/collections/asr/parts/submodules/rnnt_greedy_decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,9 @@ def __init__(
)

self._greedy_decode = RNNTGreedyDecodeCudaGraph(max_symbols_per_step, self)
except (ImportError, ModuleNotFoundError, ValueError) as e:
except (ImportError, ModuleNotFoundError, ValueError, EnvironmentError) as e:
self.use_cuda_graph_decoder = False
logging.warning(f"Cannot use decoder with CUDA graphs, reason: {e.msg}")
logging.warning(f"Cannot use decoder with CUDA graphs, reason: {e}")
self._greedy_decode = self._greedy_decode_blank_as_pad_loop_frames
else:
self._greedy_decode = self._greedy_decode_blank_as_pad_loop_frames
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ def maybe_enable_cuda_graphs(self):
try:
check_cuda_python_cuda_graphs_conditional_nodes_supported()
self.cuda_graphs_mode = self.CudaGraphsMode.FULL_GRAPH
except (ImportError, ModuleNotFoundError) as e:
except (ImportError, ModuleNotFoundError, EnvironmentError) as e:
logging.warning(
"No conditional node support for Cuda.\n"
"Cuda graphs with while loops are disabled, decoding speed will be slower\n"
f"Reason: {e.msg}"
f"Reason: {e}"
)
self.cuda_graphs_mode = self.CudaGraphsMode.NO_WHILE_LOOPS
self.reset_cuda_graphs_state()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ def maybe_enable_cuda_graphs(self):
try:
check_cuda_python_cuda_graphs_conditional_nodes_supported()
self.cuda_graphs_mode = self.CudaGraphsMode.FULL_GRAPH
except (ImportError, ModuleNotFoundError) as e:
except (ImportError, ModuleNotFoundError, EnvironmentError) as e:
logging.warning(
"No conditional node support for Cuda.\n"
"Cuda graphs with while loops are disabled, decoding speed will be slower\n"
f"Reason: {e.msg}"
f"Reason: {e}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reason for the change: EnvironmentError has no attribute msg.

)
self.cuda_graphs_mode = self.CudaGraphsMode.NO_WHILE_LOOPS
self.reset_cuda_graphs_state()
Expand Down
9 changes: 7 additions & 2 deletions nemo/core/utils/cuda_python_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@


def check_cuda_python_cuda_graphs_conditional_nodes_supported():
# for CPU-only environment we need to raise an exception, otherwise cuda-python library will fail
if not torch.cuda.is_available():
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When GPU is unavailable python-cuda library will fail. So, need to throw additional EnvironmentError exception

FYI: @galv

raise EnvironmentError("CUDA is not available")

try:
from cuda import cuda
except ImportError:
Expand Down Expand Up @@ -55,11 +59,12 @@ def skip_cuda_python_test_if_cuda_graphs_conditional_nodes_not_supported():
"""
try:
check_cuda_python_cuda_graphs_conditional_nodes_supported()
except (ImportError, ModuleNotFoundError) as e:
except (ImportError, ModuleNotFoundError, EnvironmentError) as e:
import pytest

pytest.skip(
f"Test using cuda graphs with conditional nodes is being skipped because cuda graphs with conditional nodes aren't supported. Error message: {e}"
"Test using cuda graphs with conditional nodes is being skipped because "
f"cuda graphs with conditional nodes aren't supported. Error message: {e}"
)


Expand Down
Loading