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

AttributeError: 'NoneType' object has no attribute 'create_execution_context' #12

Open
wrz57661 opened this issue Nov 13, 2020 · 10 comments

Comments

@wrz57661
Copy link

Hello,SceanAvery! When I run the demo.py,something went wrong.How can I solve it?
File "demo.py", line 23, in main
processor = Processor(model=args['model'])
File "/home/waveshare/yolov5-tensorrt/python/lib/Processor.py", line 19, in init
self.context = engine.create_execution_context()
AttributeError: 'NoneType' object has no attribute 'create_execution_context'

@seanavery
Copy link
Owner

hey @wrz57661 , this is due to differing TRT version from the compiled model.

I have updated the export_tensorrt.py script.

Will work if you recompile.

@seanavery
Copy link
Owner

uploaded new compiled model with trt version 7.1.3.0

@sunanlin13174
Copy link

hi,SeanAvery,i meets the same problem, my jetpack is 4.4, and tensorRT may be 7.1.3.0,i run this demo.py ,and got the same error, did i do some things wrong?

@sunanlin13174
Copy link

yes , my tensorRT verson is 7.1.3.0 ,and i try it in jetson xavier nx devices

@sunanlin13174
Copy link

@seanavery

@seanavery
Copy link
Owner

Thank you for your patience @sunanlin13174 🙏

Have not tried with nx but also using jetpack 4.4

Can you send me full error stack?

@sunanlin13174
Copy link

sunanlin13174 commented Nov 27, 2020

@seanavery ,Thank you for your quick reply. Your work is very useful for me to learn how to use python-tensorRT. Frist,i checked my environment of running,and then i followed your readme file to run demo.py .The error messages is as follows:

`/usr/bin/python3.6 /home/qyg/Desktop/yolov5-tensorrt-master/python/lib/demo.py
trtbin /home/qyg/Desktop/yolov5-tensorrt-master/python/lib/models/yolov5s-simple-32.trt
[TensorRT] ERROR: INVALID_CONFIG: The engine plan file is generated on an incompatible device, expecting compute 7.2 got compute 5.3, please rebuild.
[TensorRT] ERROR: engine.cpp (1546) - Serialization Error in deserialize: 0 (Core engine deserialization failure)
[TensorRT] ERROR: INVALID_STATE: std::exception
[TensorRT] ERROR: INVALID_CONFIG: Deserialize the cuda engine failed.
Traceback (most recent call last):
File "/home/qyg/Desktop/yolov5-tensorrt-master/python/lib/demo.py", line 49, in
main()
File "/home/qyg/Desktop/yolov5-tensorrt-master/python/lib/demo.py", line 21, in main
processor = Processor(model=args['model'])
File "/home/qyg/Desktop/yolov5-tensorrt-master/python/lib/Processor.py", line 19, in init
self.context = engine.create_execution_context()
AttributeError: 'NoneType' object has no attribute 'create_execution_context'

Process finished with exit code 1
`

@sunanlin13174
Copy link

i also meets another little problem. i just run export_tensorrt.py in jetson xavier nx devices,and i got this meassages:

[TensorRT] VERBOSE: *************** Autotuning format combination: Float(1,320,102400,3276800) -> Float(1,320,102400,3276800) *************** [TensorRT] ERROR: /home/jenkins/workspace/TensorRT/helpers/rel-7.1/L1_Nightly_Internal/build/source/rtSafe/resources.h (462) - Cuda Error in loadKernel: 500 (named symbol not found) [TensorRT] WARNING: GPU memory allocation error during getBestTactic: LeakyRelu_42 [TensorRT] VERBOSE: *************** Autotuning format combination: Float(1,320,102400:32,102400) -> Float(1,320,102400:32,102400) ***************
i am sorry for that brought you trouble,if you are not busy, i hope you can give me the solution.

@lnn523716
Copy link

i also meets the problem. i just run demo.py using yolov5s-simple-16.trt in jetson TX2 devices,the result is OK.But, i use yolov5s-simple-32.trt and got this meassages:
trtbin /home/nvidia/Documents/yolov5-tensorrt-master/python/lib/models/yolov5s-simple-32.trt
[TensorRT] ERROR: INVALID_CONFIG: The engine plan file is generated on an incompatible device, expecting compute 6.2 got compute 5.3, please rebuild.
[TensorRT] ERROR: engine.cpp (1546) - Serialization Error in deserialize: 0 (Core engine deserialization failure)
[TensorRT] ERROR: INVALID_STATE: std::exception
[TensorRT] ERROR: INVALID_CONFIG: Deserialize the cuda engine failed.
Traceback (most recent call last):
File "demo_video.py", line 37, in
main()
File "demo_video.py", line 15, in main
processor = Processor(model='yolov5s-simple-32.trt')
File "/home/nvidia/Documents/yolov5-tensorrt-master/python/lib/Processor.py", line 19, in init
self.context = engine.create_execution_context()
AttributeError: 'NoneType' object has no attribute 'create_execution_context'

@naotar
Copy link

naotar commented Sep 8, 2021

It is interesting that we are in 2021 and this error still exists with latest downloads and model.

AttributeErrorTraceback (most recent call last)
in
1 from jetbot import ObjectDetector
2
----> 3 model = ObjectDetector('saved_model.pb')

/usr/local/lib/python3.6/dist-packages/jetbot-0.4.3-py3.6.egg/jetbot/object_detection.py in init(self, engine_path, preprocess_fn)
27 load_plugins()
28 self.trt_model = TRTModel(engine_path, input_names=[TRT_INPUT_NAME],
---> 29 output_names=[TRT_OUTPUT_NAME, TRT_OUTPUT_NAME + '_1'])
30 self.preprocess_fn = preprocess_fn
31

/usr/local/lib/python3.6/dist-packages/jetbot-0.4.3-py3.6.egg/jetbot/tensorrt_model.py in init(self, engine_path, input_names, output_names, final_shapes)
57 with open(engine_path, 'rb') as f:
58 self.engine = self.runtime.deserialize_cuda_engine(f.read())
---> 59 self.context = self.engine.create_execution_context()
60
61 if input_names is None:

AttributeError: 'NoneType' object has no attribute 'create_execution_context'

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

5 participants