Skip to content

A little bug in testing_utils.py #45341

@MHRDYN7

Description

@MHRDYN7

System Info

.

Who can help?

I was trying to run integration tests on cpu for a new model addition PR then got hit by an error due to line 3220

@cache
def get_device_properties() -> DeviceProperties:
"""
Get environment device properties.
"""
if IS_CUDA_SYSTEM or IS_ROCM_SYSTEM:
import torch
major, minor = torch.cuda.get_device_capability()
if IS_ROCM_SYSTEM:
return ("rocm", major, minor)
else:
return ("cuda", major, minor)
elif IS_XPU_SYSTEM:
import torch
# To get more info of the architecture meaning and bit allocation, refer to https://github.com/intel/llvm/blob/sycl/sycl/include/sycl/ext/oneapi/experimental/device_architecture.def
arch = torch.xpu.get_device_capability()["architecture"]
gen_mask = 0x000000FF00000000
gen = (arch & gen_mask) >> 32
return ("xpu", gen, None)

The reason is that I have CUDA installed on my system (lightning ai studio), but I did not have any GPU, so

IS_CUDA_SYSTEM = torch.version.cuda is not None

was correctly set to the version and then the error occurred in line 3223

major, minor = torch.cuda.get_device_capability()

as I did not have any gpu.

If this is not the intended behavior, the fix is simply changing line 3220 to if (IS_CUDA_SYSTEM or IS_ROCM_SYSTEM) and torch.cuda.is_available(): . In this case we will also need to remove the import torch inside, which anyway seems redundant to me.

@remi-or I see you worked on this area most recently (10 months ago), otherwise could you please ping the right person

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

.

Expected behavior

.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions