Real-Time People Tracking and Counting on Jetson Nano

Code on GitHub: GitHub - JardinRyu/Jetson_Nano_People_Counting: MobileNetV1-SSD + SORT based Real-Time Tracking and Counting on Jetson Nano

This repository provides a real-time people tracking and counting system.
It detects people based on SSD-Mobilenetv1-coco and uses SORT to track and count.

Hope you like the project and feel free to contribute to it!


im having troubles on downloading some stuff from the code. it states i need to download pycuda.

2 Likes contains pycuda installation.

I am having problem running the script, I am getting this error:

~/Jetson_Nano_People_Counting$ python3
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
TrtThread: loading the TRT SSD engine…
frame number 0
Exception in thread Thread-1:
Traceback (most recent call last):
File “/usr/lib/python3.6/”, line 916, in _bootstrap_inner
File “”, line 196, in run
self.trt_ssd = TrtSSD(self.model, INPUT_HW)
File “/home/microstategies/Jetson_Nano_People_Counting/utils/”, line 86, in init
self.engine = self._load_engine()
File “/home/microstategies/Jetson_Nano_People_Counting/utils/”, line 56, in _load_engine
with open(TRTbin, ‘rb’) as f, trt.Runtime(self.trt_logger) as runtime:
FileNotFoundError: [Errno 2] No such file or directory: ‘ssd/TRT_ssd_mobilenet_v1_coco.bin’

Exception ignored in: <bound method TrtSSD.del of <utils.ssd.TrtSSD object at 0x7f7eb287f0>>
Traceback (most recent call last):
File “/home/microstategies/Jetson_Nano_People_Counting/utils/”, line 100, in del
del self.cuda_outputs
AttributeError: cuda_outputs

PyCUDA ERROR: The context stack was not empty upon module cleanup.

A context was still active when the context stack was being
cleaned up. At this point in our execution, CUDA may already
have been deinitialized, so there is no way we can finish
cleanly. The program will be aborted now.
Use Context.pop() to avoid this problem.

Aborted (core dumped)

I think you didn’t create a trt model by referring to the install requirements

1 Like

thanks for the reply, but I can not see any installation requirement document. where is it?


1 Like

I did all the steps with military precision, on multiple attempts on freshly installed jetpack 4.51 and jetpack 4.5 with no success running the usb cam python script. It is simply not working, I wonder if anyone here had any success with it? Can you do it in a docker container?

1 Like

I run and I still get the same error

Same thing, I have done the installation twice, following every step and it does not work

ผมใช้วิธีนี้ แล้วมันสามารถแก้ปัญหาได้ Install PyCUDA on Jetson Nano - Dropout Analytics - Medium

It works for me! Thank you, JardinRyu.

By running the program, I got an error stating “ModuleNotFoundError: No module named 'pycuda”
but I got through this referring to

sudo pip3 install --global-option=build_ext --global-option="-I/usr/local/cuda/include" --global-option="-L/usr/local/cuda/lib64" pycuda

@johnny7 Hi, I have the same issue as yours, did you find any solutions?

I got this running people, there are several steps need to b taken into consideration:

  1. first make sure the sd image for the jetson nano is actually Jetpack 4.5.0 (not 4.6)
  2. Absolutely don’t do the “sudo apt-get upgrade”. Upgrading the libraries and dependencies will bring them to the latest state (jetpack 4.6) and that’s somehow is an issue.
  3. Before starting the installation,check if CUDA is included in the PATH by typing:
    “nvcc --version” if you didn’t get any infos it means it’s not in PATH. In this case add CUDA to your path manually. I know the installation includes that in the install , but it somehow doesn’t work. You can do that with:
    export PATH=$PATH:/usr/local/cuda
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
  4. After the first, you can directly go to /ssd directory and run pycuda script installation by yourself with :
    ./ (this step is also included in the second script but it doesn’t work for some reason).
  5. now you can go ahead and run the second in the ssd directory.
  6. You can go on with the building engines after that with the ./

PS: I did everything using Jetson nano B01 (4g) and with a clean installed image with jetpack 4.5.0

wil be happy to answer any questions !!


Hi. It works for me on an Jetson Xavier NX devkit with JetPack 4.5. However, the perfomance is so bad (image delay and low fps). How could I improve the perfomance?

1 Like

How many FPS are you getting on the Xavier NX?

1 Like

Between 1 and 5 fps.

I tried again on a Jetson Nano with a MIPI CSI camera and the framerate is good. However, the app crashes after 2 hours running. On the Jetson Xavier NX with USB cam i don’t suffer crashes, but still the low framerate. I’m interested on solve the crashes because I find better performance with CSI camera. Any suggestion? Solution could be a different configuration of pipeline?

1 Like

I think the app crashes due to heat problems. You can solve that by adding a fan to the Jetson. Otherwise I can’t think of any other reason at the moment.