NVIDIA-AI-IOT / torch2trt

An easy to use PyTorch to TensorRT converter
MIT License
4.6k stars 675 forks source link

Failed to test the converter: attempted relative import with no known parent package #611

Open owoshch opened 3 years ago

owoshch commented 3 years ago

I'm implementing my own converter and I'm trying to figure out the general framework for testing converters in this repository. For example, I'm trying to test Conv2d converter via executing the command torch2trt/torch2trt# python test.py --name converters.Conv2d.test_Conv2d_basic I'm getting this error: Traceback (most recent call last): File "test.py", line 1, in from torch2trt import * File "/workspace/repositories/torch2trt/torch2trt/torch2trt.py", line 9, in from .calibration import ( ImportError: attempted relative import with no known parent package

Could you please assist me with fixing this issue? Thank you!

jaybdub commented 3 years ago

Hi owoshch,

Thanks for reaching out!

The command, from the root of the project is

python3 -m torch2trt.test --name=converters.Conv2d.test_Conv2d_basic

You can use any regex to match the package.module.function name with the --name parameter. For example,

python3 -m torch2trt.test --name=Conv2d_basic

Would work as well. Please let me know if this helps or you run into any issues.

Best, John