TensorRT pycuda._driver.LogicError

I’m using TensroRT and I don’t know the cause of the following error Can you please tell me the cause?

File "/home/automatic-inspection/common.py", line 145, in allocate_buffers
    stream = cuda.Stream()
pycuda._driver.LogicError: explicit_context_dependent failed: invalid device context - no currently active context?

Hi @yoshifumi_watanabe_aa,

We recommend you to please share more details of the issue. It would be helpful if you could share us complete script and error logs for better assistance.

We also request you to share following environment details.
TensorRT Version :
GPU Type :
Nvidia Driver Version :
CUDA Version :
CUDNN Version :
Operating System + Version :
Python Version (if applicable) :
TensorFlow Version (if applicable) :
PyTorch Version (if applicable) :
Baremetal or Container (if container which image + tag) :

Thank you.

The DGX Tesla version is 418.
The container uses 20.09 at Frameworks Support Matrix :: NVIDIA Deep Learning Frameworks Documentation.

The errors and installed modules are below

Exception in thread Thread-4:

Traceback (most recent call last):

File “/usr/lib/python3.6/threading.py”, line 916, in _bootstrap_inner

self.run()

File “/usr/lib/python3.6/threading.py”, line 864, in run

self._target(*self._args, **self._kwargs)

File “/home/automatic-inspection/Machines.py”, line 92, in process

data = self.func(data, self) # * lane \u306b\u6d41\u308c\u3066\u304f\u308b\u30ef\u30fc\u30af\u3092\u51e6\u7406\u3059\u308b

File “/home/automatic-inspection/Predictor.py”, line 540, in pred_csv_start

second_class_num)

File “/home/automatic-inspection/Predictor.py”, line 137, in start_pred

first_class_num

File “/home/automatic-inspection/Predictor.py”, line 197, in predict_batch_first

inputs, outputs, bindings, stream = common.allocate_buffers(context.engine) #####Error######

File “/home/automatic-inspection/common.py”, line 145, in allocate_buffers

stream = cuda.Stream()

pycuda._driver.LogicError: explicit_context_dependent failed: invalid device context - no currently active context?

pip3-freeze list

absl-py==0.12.0

appdirs==1.4.4

astunparse==1.6.3

Brotli==1.0.9

cachetools==4.2.1

certifi==2020.12.5

chardet==4.0.0

click==8.0.0

cycler==0.10.0

Cython==0.29.22

dash==1.20.0

dash-core-components==1.16.0

dash-html-components==1.1.3

dash-renderer==1.9.1

dash-table==4.11.3

dataclasses==0.8

decorator==4.4.2

efficientnet==1.1.1

Flask==2.0.0

Flask-Compress==1.9.0

flatbuffers==1.12

future==0.18.2

futures==3.1.1

gast==0.3.3

google-auth==1.27.1

google-auth-oauthlib==0.4.3

google-pasta==0.2.0

grpcio==1.36.1

h5py==2.10.0

idna==2.10

imageio==2.9.0

importlib-metadata==3.7.2

itsdangerous==2.0.0

Jinja2==3.0.0

joblib==1.0.1

Keras-Applications==1.0.8

Keras-Preprocessing==1.1.1

kiwisolver==1.3.1

Mako==1.1.4

Markdown==3.3.4

MarkupSafe==2.0.0

matplotlib==3.3.4

mock==3.0.5

networkx==2.5.1

numpy==1.19.5

oauthlib==3.1.0

onnx==1.8.1

opencv-python==4.5.1.48

opt-einsum==3.3.0

pandas==1.1.5

Pillow==8.1.2

plotly==4.14.3

protobuf==3.15.6

pyasn1==0.4.8

pyasn1-modules==0.2.8

pybind11==2.6.2

pycuda==2020.1

pyparsing==2.4.7

pypylon==1.7.2

python-dateutil==2.8.1

pytools==2021.2

pytz==2021.1

PyWavelets==1.1.1

requests==2.25.1

requests-oauthlib==1.3.0

retrying==1.3.3

rsa==4.7.2

scikit-image==0.16.2

scikit-learn==0.24.1

scipy==1.4.1

six==1.15.0

tensorboard==2.4.1

tensorboard-plugin-wit==1.8.0

tensorflow==2.3.0+nv20.9

tensorflow-estimator==2.3.0

termcolor==1.1.0

tf2onnx==1.8.3

threadpoolctl==2.1.0

typing-extensions==3.7.4.3

urllib3==1.26.3

Werkzeug==2.0.0

wrapt==1.12.1

zipp==3.4.1

Hi @yoshifumi_watanabe_aa,

Thank you for sharing the details. Looks like you have CUDA configuration issue.
We recommend you to please try TenosrRT NGC container.
https://ngc.nvidia.com/containers/nvidia:tensorrt

Thank you.