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

Unsupported data for device specification #7523

Closed
KumoLiu opened this issue Mar 8, 2024 · 0 comments · Fixed by #7524
Closed

Unsupported data for device specification #7523

KumoLiu opened this issue Mar 8, 2024 · 0 comments · Fixed by #7524

Comments

@KumoLiu
Copy link
Contributor

KumoLiu commented Mar 8, 2024

======================================================================
ERROR: test_onnx_trt_export_1_fp16 (tests.test_bundle_trt_export.TestTRTExport)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/workspace/MONAI/tests/utils.py", line 809, in command_line_tests
    normal_out = subprocess.run(cmd, env=test_env, check=True, capture_output=True)
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['python', '-m', 'monai.bundle', 'trt_export', 'network_def', '--filepath', '/tmp/tmptbll1a8a/model_trt_fp16.ts', '--meta_file', '/workspace/MONAI/tests/testing_data/metadata.json', '--config_file', "['/workspace/MONAI/tests/testing_data/inference.json','/tmp/tmptbll1a8a/def_args.yaml']", '--ckpt_file', '/tmp/tmptbll1a8a/model.pt', '--args_file', '/tmp/tmptbll1a8a/def_args.yaml', '--precision', 'fp16', '--use_onnx', 'True', '--input_shape', '[1, 1, 96, 96, 96]', '--dynamic_batch', '[1, 4, 8]']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

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 "/workspace/MONAI/tests/test_bundle_trt_export.py", line 126, in test_onnx_trt_export
    command_line_tests(cmd)
  File "/workspace/MONAI/tests/utils.py", line 815, in command_line_tests
    raise RuntimeError(f"subprocess call error {e.returncode}: {errors}, {output}") from e
RuntimeError: subprocess call error 1: b'There is no dynamic batch range. The converted model only takes [1, 1, 96, 96, 96] shape input.
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/workspace/MONAI/monai/bundle/__main__.py", line 31, in <module>
    fire.Fire()
  File "/usr/local/lib/python3.10/dist-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/usr/local/lib/python3.10/dist-packages/fire/core.py", line 475, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/usr/local/lib/python3.10/dist-packages/fire/core.py", line 691, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/workspace/MONAI/monai/bundle/scripts.py", line 1516, in trt_export
    _export(
  File "/workspace/MONAI/monai/bundle/scripts.py", line 1091, in _export
    net = converter(model=net, **kwargs)
  File "/workspace/MONAI/monai/networks/utils.py", line 962, in convert_to_trt
    trt_model = _onnx_trt_compile(
  File "/workspace/MONAI/monai/networks/utils.py", line 852, in _onnx_trt_compile
    trt_model = torch_tensorrt.ts.embed_engine_in_new_module(
  File "/usr/local/lib/python3.10/dist-packages/torch_tensorrt/ts/_compiler.py", line 317, in embed_engine_in_new_module
    _parse_device(device),
  File "/usr/local/lib/python3.10/dist-packages/torch_tensorrt/ts/_compile_spec.py", line 135, in _parse_device
    raise ValueError(
ValueError: Unsupported data for device specification. Expected either a dict, torch_tensorrt.Device or torch.Device

Root cause is that the order of arguments has changed.
https://github.com/pytorch/TensorRT/blob/ad74a735056667726692c49a175a790647ef889e/py/torch_tensorrt/ts/_compiler.py#L279-L283
https://github.com/pytorch/TensorRT/blob/7d1d807731c95ffbaa980a3742e289d4184b7871/py/torch_tensorrt/ts/_compiler.py#L260-L264

f.getvalue(), torch.device(f"cuda:{device}"), input_names, output_names

KumoLiu added a commit to KumoLiu/MONAI that referenced this issue Mar 8, 2024
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
KumoLiu added a commit that referenced this issue Mar 10, 2024
Fixes #7523


### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
juampatronics pushed a commit to juampatronics/MONAI that referenced this issue Mar 25, 2024
Fixes Project-MONAI#7523

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Juan Pablo de la Cruz Gutiérrez <juampatronics@gmail.com>
Yu0610 pushed a commit to Yu0610/MONAI that referenced this issue Apr 11, 2024
Fixes Project-MONAI#7523

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Yu0610 <612410030@alum.ccu.edu.tw>
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 a pull request may close this issue.

1 participant