Skip to content

AttributeError: 'torch.device' object has no attribute 'gpu_id' #8017

Closed
@KumoLiu

Description

@KumoLiu
======================================================================
ERROR: test_value_0_fp32 (tests.test_convert_to_trt.TestConvertToTRT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
  File "/tmp/MONAI/tests/test_convert_to_trt.py", line 64, in test_value
    torchscript_model = convert_to_trt(
  File "/tmp/MONAI/monai/networks/utils.py", line 985, in convert_to_trt
    trt_model = torch_tensorrt.compile(
  File "/usr/local/lib/python3.10/dist-packages/torch_tensorrt/_compile.py", line 208, in compile
    compiled_ts_module: torch.jit.ScriptModule = torchscript_compile(
  File "/usr/local/lib/python3.10/dist-packages/torch_tensorrt/ts/_compiler.py", line 154, in compile
    compiled_cpp_mod = _C.compile_graph(module._c, _parse_compile_spec(spec))
  File "/usr/local/lib/python3.10/dist-packages/torch_tensorrt/ts/_compile_spec.py", line 267, in _parse_compile_spec
    info.device = _parse_device(compile_spec["device"])
  File "/usr/local/lib/python3.10/dist-packages/torch_tensorrt/ts/_compile_spec.py", line 90, in _parse_device
    return TorchScriptDevice._from(device_info)._to_internal()
  File "/usr/local/lib/python3.10/dist-packages/torch_tensorrt/ts/_Device.py", line 66, in _from
    gpu_id=d.gpu_id,
AttributeError: 'torch.device' object has no attribute 'gpu_id'

Not work in Pytorch base image 24.08

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions