grimoire/mmdetection-to-tensorrt

Issue while converting with int8 support

Opened this issue · 3 comments

Describe the bug
Hi! First of all thank you a lot for you great work! But when I try to add int8 support I got some errpor - can you pls help me to understand what needs to be changed?
Traceback (most recent call last): File "convert_to_trt.py", line 39, in <module> device=device) File "/root/space/mmdetection-to-tensorrt/mmdet2trt/mmdet2trt.py", line 147, in mmdet2trt int8_calib_algorithm=int8_calib_algorithm) File "/root/space/torch2trt_dynamic/torch2trt_dynamic/torch2trt_dynamic.py", line 561, in torch2trt_dynamic config.set_calibration_profile(profile) AttributeError: 'tensorrt.tensorrt.IBuilderConfig' object has no attribute 'set_calibration_profile'

To Reproduce
`opt_shape_param = None
config_path = '/user_home/packages_atss_stage2/logs_packages_atss/stage2_packages_atss.py'
model_path = '/user_home/packages_atss_stage2/logs_packages_atss/epoch_10.pth'
result_path = '/user_home/packages_atss_stage2/logs_packages_atss/int8_mmdet_to_trt.pth'

fp16 = False
int8 = True
device = 'cuda:0'
trt_log_level = 'VERBOSE'
return_wrap_model = False
max_workspace_size = 1 << 30 # some module and tactic need large workspace.
trt_model = mmdet2trt(config_path,
model_path,
opt_shape_param=opt_shape_param,
fp16_mode=fp16,
int8_mode=int8,
max_workspace_size=max_workspace_size,
trt_log_level=trt_log_level,
return_wrap_model=return_wrap_model,
device=device)

torch.save(trt_model.state_dict(), result_path)`

enviroment:
Docekr file from repo
Additional context
Add any other context about the problem here.

Hi
Guess It is caused by TRT version. Update TRT 7.1, rebuild mmcv and amirstan_plugin might fix this.
The time when I create the dockfile, mmcv did not have a cuda11 prebuild version, and all images with TRT7.1 (20.06~) are cuda11. I will create a new one this weekend.

Updating to TRT 7.1 even keeping cuda 10.2 (installed before) worked for me. Additionally I just had to re-build amirstan_plugin. mmcv kept as is.

BTW, onto GPU K80 INT8 mode looks has negative effect.
First, while convertion I've noticed the following message
"[TensorRT] WARNING: Int8 support requested on hardware without native Int8 support, performance will be negatively affected."
Then latency test on the detector showed me same processing speed as for FP32 mode (over than FP16).

@vedrusss Cool! Thanks for your report. And It seems that K80 does not support int8. Read support matrix and fp16 slower than fp32 for detail.

@maksimovkonstantin There might be something wrong with the prebuild mmcv-full+cu11, I have report to openmmlab, hope they can solve the problem. It might take some time. You can follow @vedrusss.