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

[BUG FIX]:fix get torch.version.cuda error when cuda is None in rocm #6909

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hj-wei
Copy link

@hj-wei hj-wei commented Dec 24, 2024

HI, I found some error when using deepspeed with rocm-torch

torch_cuda_version = ".".join(torch.version.cuda.split('.')[:2]) 

will raise an AttributeError when torch.version.cuda is None. This occurs because the CUDA version in rocm-torch/version.py is set to always be None, leading to potential runtime errors in environments where ROCm is being used.

@@ -839,7 +839,9 @@ def cxx_args(self):

CPU_ARCH = self.cpu_arch()
SIMD_WIDTH = self.simd_width()
CUDA_ENABLE = self.is_cuda_enable()
CUDA_ENABLE = (
"-D__DISABLE_CUDA__" if self.is_rocm_pytorch() else self.is_cuda_enable()
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for this PR. Can you please help with the following changes to improve the codebase beyond your fix?

  1. Rename the method is_cuda_enable() -> to get_cuda_compile_flag(), which is more meaningful.
  2. Handle self.is_rocm_pytorch() case in get_cuda_compile_flag(), returning -D__DISABLE_CUDA__ as appropriate.

Are you able to help these changes? Thanks!

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants