🐛 [Bug] error: backend='torch_tensorrt' raised: TypeError: pybind11::init(): factory function returned nullptr
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3k
- Forks
- 410
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 78
Description
Bug Description
hi i see the following error - it looks like the torch.compile worked fine but when i invoke the prediction after that it errors out:
[INFO ] W-9001-model_1.0-stdout MODEL_LOG - [05/10/2024-[W] Unable to determine GPU memory usage
[INFO ] W-9001-model_1.0-stdout MODEL_LOG - [05/10/2024-[TRT] [W] Unable to determine GPU memory usage
[INFO ] W-9001-model_1.0-stdout MODEL_LOG - [05/10/2024-[TRT] [I] [MemUsageChange] Init CUDA: CPU +0, GPU +0, now: CPU 1104, GPU 0 (MiB)
[INFO ] W-9001-model_1.0-stdout MODEL_LOG - [05/10/2024-[TRT] [W] CUDA initialization failure with error: 35. Please check your CUDA installation: http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
predict_fn error: backend='torch_tensorrt' raised: TypeError: pybind11::init(): factory function returned nullptr
does pytorch-tensorrt work with a g4dn.xlarge? why i get this: CUDA initialization failure with error: 35?
full log:
tensorrt_torch_error.txt
To Reproduce
Steps to reproduce the behavior:
- build container with tensorrt
# use sagemaker DLC
FROM 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:2.1.0-gpu-py310-cu118-ubuntu20.04-sagemaker
# Install additional dependencies
RUN python -m pip install torch torch-tensorrt tensorrt --extra-index-ur https://download.pytorch.org/whl/cu118
how was the model compiled?
model.model_body[0].auto_model = torch.compile(model.model_body[0].auto_model, backend="torch_tensorrt", dynamic=False,
options={"truncate_long_and_double": True,
"precision": torch.half,
"debug": True,
"min_block_size": 1,
"optimization_level": 4,
"use_python_runtime": False})
to rule out that the issue is somewhere else - i tested with the following torch.compile - this works fine:
model.model_body[0].auto_model = torch.compile(model.model_body[0].auto_model, mode="reduce-overhead")
should i try some other settings for torch.compile(model.model_body[0].auto_model, backend="torch_tensorrt" ?
could the error be related to https://github.com/NVIDIA/TensorRT/issues/308 ?
Expected behavior
no error
Environment
Build information about Torch-TensorRT can be found by turning on debug messages
- Torch-TensorRT Version (e.g. 1.0.0):
- PyTorch Version (e.g. 1.0): 2.1
- CPU Architecture: g4dn.xlarge
- OS (e.g., Linux):
- How you installed PyTorch (
conda,pip,libtorch, source): - Build command you used (if compiling from source):
- Are you using local sources or building from archives:
- Python version:
- CUDA version:
- GPU models and configuration:
- Any other relevant information:
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied container definition, torch.compile configuration, and attached TensorRT log; compare the torch_tensorrt and reduce-overhead reproductions on the g4dn.xlarge environment. Verify the reported CUDA initialization failure and determine whether the prediction path can run successfully with the stated setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- compilers, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100