Hello everyone!I’ve met a terrible problem which needs your help urgently.I’m working on a real-time object recognition project.I use timers to realize threads.The detecting thread sometimes uses more time than its timer.So when the timer want to begin the detecting thread, the previous detecting operation is not over yet.Then,my code will be crushed with the invalid memory access.I want to know how to solve this problem.My environment is Ubuntu, qt creator.And the detecting code is cuda source code.Could somebody help me?Thank you for reading!
You can delete an application with kill command.
Ex. delete application topic_1030522.py
1. Find the application ID
ps aux | grep python
nvidia 3400 31.4 2.1 911184 172908 pts/16 R+ 09:12 0:05 python topic_1030522.py
nvidia 3403 0.0 0.0 5524 544 pts/17 S+ 09:13 0:00 grep --color=auto python
sudo kill -9 3400
Sorry,you may misunderstand my problem.I need c++ code in my qt project.The command way may be not suitable.
Hi Sulli_Xue, have you tried the cudaDeviceReset() function?
You may use a semaphore for locking.
When timer fires, the new thread would try to acquire the semaphore in non blocking mode.
If it succeeds, the thread will work and before exiting it will release the semaphore.
If it fails, it means the previous thread hasn’t finished yet. Then you may either :
- call cudaDeviceReset(), then do work and release the semaphore when done.
- cancel the new thread and wait for next timer thread.
If you are interested in the C API of kill:
man -S 2 kill
(for C++ just wrap the declaration in extern “C”)
If your application is a single process with several threads, you may read this http://www.bo-yang.net/2017/11/19/cpp-kill-detached-thread.