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

'DataContainer' object is not subscriptable during TensorRT #105

Closed
Auth0rM0rgan opened this issue Jan 25, 2022 · 11 comments
Closed

'DataContainer' object is not subscriptable during TensorRT #105

Auth0rM0rgan opened this issue Jan 25, 2022 · 11 comments
Assignees

Comments

@Auth0rM0rgan
Copy link

Auth0rM0rgan commented Jan 25, 2022

Hello,

Im trying to convert CRNN text recognition model to TensorRT backbone but getting an error. I was able to convert the pytorch model to TensorRT without any issue and also i was able to measure the performance without error. However, when I try to evaluate the model Im facing the following error. Any idea how can I solve the issue??

2022-01-25 11:29:44,658 - mmdeploy - INFO - Sorting the dataset by 'height' and 'width' is not possible.
2022-01-25 11:29:44,783 - mmdeploy - INFO - Successfully loaded tensorrt plugins from /home/Documents/Dev/MMDeploy/build/lib/libmmdeploy_tensorrt_ops.so
2022-01-25 11:29:44,783 - mmdeploy - INFO - Successfully loaded tensorrt plugins from /home/Documents/Dev/MMDeploy/build/lib/libmmdeploy_tensorrt_ops.so
[01/25/2022-11:29:45] [TRT] [W] TensorRT was linked against cuBLAS/cuBLAS LT 11.6.3 but loaded cuBLAS/cuBLAS LT 11.5.1
[01/25/2022-11:29:46] [TRT] [W] TensorRT was linked against cuBLAS/cuBLAS LT 11.6.3 but loaded cuBLAS/cuBLAS LT 11.5.1
[                                                  ] 0/7672, elapsed: 0s, ETA:Traceback (most recent call last):
  File "./tools/test.py", line 140, in <module>
    main()
  File "./tools/test.py", line 133, in main
    args.show_dir)
  File "/home/Documents/Dev/MMDeploy/mmdeploy/codebase/base/task.py", line 138, in single_gpu_test
    out_dir, **kwargs)
  File "/home/Documents/Dev/MMDeploy/mmdeploy/codebase/mmocr/deploy/mmocr.py", line 141, in single_gpu_test
    outputs = single_gpu_test(model, data_loader, show, out_dir, **kwargs)
  File "/home/anaconda3/envs/mmdeploy/lib/python3.7/site-packages/mmdet/apis/test.py", line 32, in single_gpu_test
    if batch_size == 1 and isinstance(data['img'][0], torch.Tensor):
TypeError: 'DataContainer' object is not subscriptable

This is the command I use to evaluate the performance

DEPLOY_CFG="configs/mmocr/text-recognition/text-recognition_tensorrt-fp16_dynamic-1x32x32-1x32x640.py"
MODEL_CFG="/home/Documents/Dev/mmocr/configs/textrecog/crnn/crnn_academic_dataset.py"

python ./tools/test.py ${DEPLOY_CFG} ${MODEL_CFG} --model "/home/Desktop/ocr-tensorRT/end2end.engine" --out /home/Desktop/ocr-tensorRT/out/out_ocr.pkl --show-dir "/home/Desktop/ocr-tensorRT"

Thanks!

@RunningLeon
Copy link
Collaborator

RunningLeon commented Jan 25, 2022

@Auth0rM0rgan Hi, could you post the version of mmocr and mmdet here?

@Auth0rM0rgan
Copy link
Author

@RunningLeon, The command I mentioned works without show-dir however when I specify the --show or --show-dir I get the error I meantioned.

mmocr = '0.4.0'
mmcv = '1.4.4'
mmdeploy = '0.1.0'

@RunningLeon
Copy link
Collaborator

@RunningLeon, The command I mentioned works without show-dir however when I specify the --show or --show-dir I get the error I meantioned.

mmocr = '0.4.0'
mmcv = '1.4.4'
mmdeploy = '0.1.0'

@Auth0rM0rgan Hi, please try with mmocr=0.3.0 as to here:

@Auth0rM0rgan
Copy link
Author

@RunningLeon, You mean I should remove my current mmocr which is version "0.4.0" and compile the version "0.3.0"?

@RunningLeon
Copy link
Collaborator

@RunningLeon, You mean I should remove my current mmocr which is version "0.4.0" and compile the version "0.3.0"?
@Auth0rM0rgan
Hi, could install by pip install mmocr==0.3.0.

@Auth0rM0rgan
Copy link
Author

pip install mmocr==0.3.0

@RunningLeon, No success, Im still getting the same error even with installing mmocr=0.3.0. I also downgrade MMCV to 1.4.0 since mmocr 0.3.0 is not compatible with MMCV 1.4.4. I installed all the basecodes from source.

@RunningLeon
Copy link
Collaborator

pip install mmocr==0.3.0

@RunningLeon, No success, Im still getting the same error even with installing mmocr=0.3.0. I also downgrade MMCV to 1.4.0 since mmocr 0.3.0 is not compatible with MMCV 1.4.4. I installed all the basecodes from source.

@Auth0rM0rgan Thanks for your feedback, we'll look into it.

@Auth0rM0rgan
Copy link
Author

@RunningLeon, Thanks, hope it solve soon. Here is my environment in case you need to reproduce the error.

2022-01-26 09:50:31,796 - mmdeploy - INFO - sys.platform: linux
2022-01-26 09:50:31,796 - mmdeploy - INFO - Python: 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:21) [GCC 9.4.0]
2022-01-26 09:50:31,796 - mmdeploy - INFO - CUDA available: True
2022-01-26 09:50:31,796 - mmdeploy - INFO - GPU 0: NVIDIA GeForce RTX 3080
2022-01-26 09:50:31,796 - mmdeploy - INFO - CUDA_HOME: /usr/local/cuda
2022-01-26 09:50:31,796 - mmdeploy - INFO - NVCC: Build cuda_11.4.r11.4/compiler.30033411_0
2022-01-26 09:50:31,796 - mmdeploy - INFO - GCC: gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
2022-01-26 09:50:31,796 - mmdeploy - INFO - PyTorch: 1.10.1
2022-01-26 09:50:31,796 - mmdeploy - INFO - PyTorch compiling details: PyTorch built with:
  - GCC 7.3
  - C++ Version: 201402
  - Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.2.3 (Git Hash 7336ca9f055cf1bfa13efb658fe15dc9b41f0740)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 11.3
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37
  - CuDNN 8.2
  - Magma 2.5.2
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.3, CUDNN_VERSION=8.2.0, CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/c++, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.10.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, 

2022-01-26 09:50:31,796 - mmdeploy - INFO - TorchVision: 0.11.2
2022-01-26 09:50:31,796 - mmdeploy - INFO - OpenCV: 4.5.5
2022-01-26 09:50:31,796 - mmdeploy - INFO - MMCV: 1.4.0
2022-01-26 09:50:31,796 - mmdeploy - INFO - MMCV Compiler: GCC 9.3
2022-01-26 09:50:31,796 - mmdeploy - INFO - MMCV CUDA Compiler: 11.4
2022-01-26 09:50:31,796 - mmdeploy - INFO - MMDeployment: 0.1.0+c74c41b
2022-01-26 09:50:31,941 - mmdeploy - INFO - onnxruntime: None ops_is_avaliable : False
2022-01-26 09:50:31,941 - mmdeploy - INFO - tensorrt: 8.2.1.8 ops_is_avaliable : True
2022-01-26 09:50:31,941 - mmdeploy - INFO - ncnn: None ops_is_avaliable : False
2022-01-26 09:50:31,941 - mmdeploy - INFO - pplnn_is_avaliable: False
2022-01-26 09:50:31,942 - mmdeploy - INFO - openvino_is_avaliable: False

@RunningLeon
Copy link
Collaborator

@Auth0rM0rgan Hi, this is a bug of upstream repo mmocr, and will be fixed later by maintainers of mmocr.

@Harold-lkk
Copy link

@RunningLeon, The command I mentioned works without show-dir however when I specify the --show or --show-dir I get the error I meantioned.

mmocr = '0.4.0'
mmcv = '1.4.4'
mmdeploy = '0.1.0'

MMOCR has fixed this issue in mmocr = '0.4.1', more detail can be found in https://github.com/open-mmlab/mmocr/releases/tag/v0.4.1. You can install the latest mmocr.

@RunningLeon
Copy link
Collaborator

Feel free to reopen if still have same issue.

hanrui1sensetime pushed a commit to hanrui1sensetime/mmdeploy that referenced this issue Nov 25, 2022
* [Feature] Make docker image smaller (open-mmlab#67)

* [Feature] Make docker image smaller


* Improve doc

* Use Compose directly in BaseMixImageTransform (open-mmlab#71)

* Use 'Compose' directly

Use 'Compose' directly

* avoids some unnecessary calculations

avoids some unnecessary calculations.

* remove whitespace

remove whitespace

* fix resize bug

* fix resize bug

* fix resize bug

* fix

* fix resize bug

* add test letterresize without batchshape

* fix resize bug

Co-authored-by: HinGwenWoong <peterhuang0323@qq.com>
Co-authored-by: jason_w <wongzheng@126.com>
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

No branches or pull requests

4 participants