TensorRT
TensorRT copied to clipboard
Error Code 4: Internal Error of TensorRT 9.1.0 when running blip-large on GPU Tesla T4
Description
Followed https://github.com/NVIDIA/TensorRT/blob/release/9.1/demo/HuggingFace/notebooks/blip.ipynb to convert a blip-large model into TensorRT engine.
Points to note about blip-large model: -> original pre-trained model : Salesforce/blip-image-captioning-large
Error obtained while running the jupyter script: "[E] 4: [network.cpp::validate::3640] Error Code 4: Internal Error (image_embeds: for dimension number 2 in profile 0 does not match network definition (got min=768, opt=768, max=768), expected min=opt=max=1024).)"
Points to note about the jupyter script: -> Works as expected when I use a blip-base
Environment
TensorRT Version: 9.1.0
NVIDIA GPU: Tesla T4
NVIDIA Driver Version: 525.85.12
CUDA Version: 12.2
CUDNN Version: 8.9.5.29
Operating System: ubuntu-20.04 (build from ubuntu-20.04.Dockerfile)
Python Version (if applicable): 3.8.10
Tensorflow Version (if applicable): 2.9.1
PyTorch Version (if applicable): 2.0.1+cu118
Baremetal or Container (if so, version): Container (build from ubuntu-20.04.Dockerfile)
Relevant Files
Model link: https://huggingface.co/Salesforce/blip-image-captioning-large/tree/main
Steps To Reproduce
-
I clone the TensorRT repo (https://github.com/NVIDIA/TensorRT.git release/9.1) and run step 1 in "Downloading TensorRT Build" section
-
I build the TensorRT OSS container with "./docker/build.sh --file docker/ubuntu-20.04.Dockerfile --tag tensorrt-ubuntu20.04-cuda12.2"
-
Then, I launch the container with "./docker/launch.sh --tag tensorrt-ubuntu20.04-cuda12.2 --gpus all"
-
Then, I install the requirements from TensorRT/demo/HuggingFace directory with "pip3 install -r requirements.txt"
-
I then copy the model files from the instance into the docker container
-
Then I run the steps in the attached script (blip_test.py) blip_test.py.zip
-
I get the following error at step: "trt_model.models = trt_model.setup_tokenizer_and_model()" Error Message:
[E] 4: [network.cpp::validate::3640] Error Code 4: Internal Error (image_embeds: for dimension number 2 in profile 0 does not match network definition (got min=768, opt=768, max=768), expected min=opt=max=1024).)
[!] Invalid Engine. Please ensure the engine was built correctly
Traceback (most recent call last):
File "blip_test.py", line 80, in
"[E] 4: [network.cpp::validate::3640] Error Code 4: Internal Error (image_embeds: for dimension number 2 in profile 0 does not match network definition (got min=768, opt=768, max=768), expected min=opt=max=1024).)"
It means the dynamic shape you provide is invalid for the network, you can only use min=opt=max=1024
I have the same problem with the Salesforce/blip-image-captioning-large model. Is there any solution?