traveller59 / torch2trt

convert torch module to tensorrt network or tvm function
MIT License
89 stars 19 forks source link

tensorRT error #1

Closed muzi2045 closed 5 years ago

muzi2045 commented 5 years ago

when using trt.Builder(TRT_LOGGER) as builder, an error came out:

[TensorRT] ERROR: Cuda initialization failure with error 1. Please check cuda installation:  http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html.
Traceback (most recent call last):
  File "torch2trt.py", line 4, in <module>
    import torch2trt
  File "/home/aisimba/Documents/second.pytorch-v1.6/scripts/torch2trt.py", line 12, in <module>
    with trt.Builder(TRT_LOGGER) as builder, builder.create_network() as trt_net:
TypeError: pybind11::init(): factory function returned nullptr
import torch
import torchvision
import tensorrt as trt 
import torch2trt
TRT_LOGGER = trt.Logger(trt.Logger.INFO)
# trt.Logger(trt.Logger.INFO)

# net = torchvision.models.inception_v3(pretrained=True).eval()
net = torchvision.models.squeezenet1_1(pretrained=True).eval()
inputs = torch.rand(1, 3, 416, 416)

with trt.Builder(TRT_LOGGER) as builder, builder.create_network() as trt_net:
    pass

OS: Ubuntu 16.04 Python3.6 CUDA 10.1 TensorRT 5.1.2-1

traveller59 commented 5 years ago

this looks like a cuda version mismatch problem. make sure your cuda version, torch cuda version (when install by conda install pytorch cudatoolkit=10.0 -c pytorch) and tensorrt cuda version are same.

muzi2045 commented 5 years ago

change pytorch version to 1.1.0 (CUDA10) and reinstall torch2trt with newest repo code new error occured when import torch2trt:

>>> import torch2trt
Traceback (most recent call last):
  File "/home/aisimba/.local/lib/python3.6/site-packages/torch/utils/tensorboard/__init__.py", line 2, in <module>
    from tensorboard.summary.writer.record_writer import RecordWriter  # noqa F401
  File "/home/aisimba/.local/lib/python3.6/site-packages/tensorboard/summary.py", line 24, in <module>
    from tensorboard.plugins.audio import summary as _audio_summary
  File "/home/aisimba/.local/lib/python3.6/site-packages/tensorboard/plugins/audio/summary.py", line 34, in <module>
    import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/aisimba/.local/lib/python3.6/site-packages/torch2trt-1.0.0-py3.6.egg/torch2trt/__init__.py", line 1, in <module>
  File "/home/aisimba/.local/lib/python3.6/site-packages/torch2trt-1.0.0-py3.6.egg/torch2trt/core.py", line 17, in <module>
  File "/home/aisimba/.local/lib/python3.6/site-packages/torch/utils/tensorboard/__init__.py", line 4, in <module>
    raise ImportError('TensorBoard logging requires TensorBoard with Python summary writer installed. '
ImportError: TensorBoard logging requires TensorBoard with Python summary writer installed. This should be available in 1.14 or above.