mooch443 / trex

TRex, a fast multi-animal tracking system with markerless identification, and 2D estimation of posture and visual fields.
https://trex.run
GNU General Public License v3.0
81 stars 8 forks source link

Trex freezes when opening video file (.mp4) #208

Closed pepelisu closed 5 months ago

pepelisu commented 1 year ago

Describe the bug Trex freezes when opening video file (.mp4) The terminal does not give any output.

To Reproduce

  1. Install Trex as suggested by the documentation: conda create -n tracking -c trexing trex

  2. Start Trex in the terminal in the activated environment tracking

  3. When video is selected there is no preview.

  4. Open a video from the Convert(Raw) option and click "open"

There is no output when using Trex or tgrab directly in the terminal. for example: tgrab -i video_file.mp4 -o test

Expected behavior (if it is not a simple crash) Some output, progress bar or similar.

Computer (please complete the following information):

Additional context I tried changing several settings in the settings pane, however I have the same output. Video is generated with ffmpeg from a sequence of basler camera tiff images. The output format is mp4 with libx246 and mpg4 codec.

Is there any way to activate a debug mode or similar that can point me to where the problem should be. I suspect that it is something simple.

chiyu1203 commented 1 year ago

I also have similiar problem with tgrabs on Window11

I installed Trex via conda as suggested by the documentation but then when running the tgrabs with the following command tgrabs -i E:\test_20230824_093505\000000.mp4 -s E:\convert_000000.settings -exec E:\track_000000.settings

https://github.com/mooch443/trex/assets/16696523/bdb265e4-635a-4952-946f-d79e45219da6

I saw this freezon screen and the grabbing was not happening. I could remove the setting for -exec, but then the grabbing process will be very very slow. I have not tried trex command yet but I expect it would be similar.... Below is my computer spec.

CPU: AMD Ryzen 7 5800 GPU: NVIDIA RTX3060; CUDA version 11.4; NVIDIA-SMI 472.50 Driver Version: 472.50; cudnn version:8.9.2.26

Please let me knwo if you have any thought.

mooch443 commented 1 year ago

Hey both, first of all I don't think these are related issues :-) One seems to be related to Python (which I would be curious why it is being loaded at all?), and the other one seems to be entirely different/unknown.

@pepelisu: It seems you are using the wrong command. "tgrab" does not exist, while "tgrabs" does. It is supposed to open tgrabs in the background when you click on "open". So please let me know / show a recording or log of what happens when you use the tgrabs command in the terminal. You can also try running

gdb --args tgrabs -i video_file.mp4 -o test

and then type r and press enter to start the program and see whether it crashes. That would be very helpful, thank you!

@chiyu1203, unfortunately the main problem does not seem to be visible in your recording - these are just follow-up errors. Do you have a recording from the very start until they become repetitive?

chiyu1203 commented 1 year ago

@mooch443 Thank you so much for your reply. I have attached the entire video here. I was hoping to do barcode-based tracking and it looked like something went wrong saying "can not run python task while python is not initialised" and then they became repetitive...

https://github.com/mooch443/trex/assets/16696523/6757c5ce-5c8e-456e-a3f7-7f34067b7464

pepelisu commented 1 year ago

Hi, Here is the output of tgrabs, then it hangs there forever.


This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.archlinux.org>
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]                                                                                           
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff547e6c0 (LWP 42814)]                                                                                                 
[New Thread 0x7ffff4c7d6c0 (LWP 42815)]
[New Thread 0x7fffe7fff6c0 (LWP 42816)]
[New Thread 0x7fffe77fe6c0 (LWP 42817)]
[New Thread 0x7fffe6ffd6c0 (LWP 42818)]
[New Thread 0x7fffe67fc6c0 (LWP 42819)]
[New Thread 0x7fffe5ffb6c0 (LWP 42820)]
[New Thread 0x7fffe57fa6c0 (LWP 42821)]
[New Thread 0x7fffe4ff96c0 (LWP 42822)]
[New Thread 0x7fffcffff6c0 (LWP 42823)]
[New Thread 0x7fffcf7fe6c0 (LWP 42824)]
[New Thread 0x7fffceffd6c0 (LWP 42825)]
[New Thread 0x7fffce7fc6c0 (LWP 42826)]
[New Thread 0x7fffcdffb6c0 (LWP 42827)]
[New Thread 0x7fffcd7fa6c0 (LWP 42828)]
[New Thread 0x7fffccff96c0 (LWP 42829)]
[New Thread 0x7fffaffff6c0 (LWP 42830)]
[New Thread 0x7fffaf7fe6c0 (LWP 42831)]
[New Thread 0x7fffaeffd6c0 (LWP 42832)]
[New Thread 0x7fffae7fc6c0 (LWP 42833)]
[New Thread 0x7fffadffb6c0 (LWP 42834)]
[New Thread 0x7fffad7fa6c0 (LWP 42835)]
[New Thread 0x7fffacff96c0 (LWP 42836)]
[New Thread 0x7fff8bfff6c0 (LWP 42837)]
[New Thread 0x7fff8b7fe6c0 (LWP 42838)]
[New Thread 0x7fff8affd6c0 (LWP 42839)]
[New Thread 0x7fff8a7fc6c0 (LWP 42840)]
[New Thread 0x7fff89ffb6c0 (LWP 42841)]
[New Thread 0x7fff897fa6c0 (LWP 42842)]
[New Thread 0x7fff88ff96c0 (LWP 42843)]
[New Thread 0x7fff6bfff6c0 (LWP 42844)]
[New Thread 0x7fff6b7fe6c0 (LWP 42845)]
[New Thread 0x7fff6affd6c0 (LWP 42846)]
[New Thread 0x7fff6a7fc6c0 (LWP 42847)]
[New Thread 0x7fff69ffb6c0 (LWP 42848)]
[New Thread 0x7fff697fa6c0 (LWP 42849)]
[New Thread 0x7fff68ff96c0 (LWP 42850)]
[New Thread 0x7fff53fff6c0 (LWP 42851)]
[New Thread 0x7fff537fe6c0 (LWP 42852)]
[New Thread 0x7fff52ffd6c0 (LWP 42853)]
[New Thread 0x7fff527fc6c0 (LWP 42854)]
[New Thread 0x7fff51ffb6c0 (LWP 42855)]
[New Thread 0x7fff517fa6c0 (LWP 42856)]
[New Thread 0x7fff50ff96c0 (LWP 42857)]
[New Thread 0x7fff27fff6c0 (LWP 42858)]
[New Thread 0x7fff277fe6c0 (LWP 42859)]
[New Thread 0x7fff26ffd6c0 (LWP 42860)]
[New Thread 0x7fff267fc6c0 (LWP 42861)]
[New Thread 0x7fff25ffb6c0 (LWP 42862)]
[New Thread 0x7fff257fa6c0 (LWP 42863)]
[New Thread 0x7fff24ff96c0 (LWP 42864)]
[New Thread 0x7fff0ffff6c0 (LWP 42865)]
[New Thread 0x7fff0f7fe6c0 (LWP 42866)]
[New Thread 0x7fff0effd6c0 (LWP 42867)]
[New Thread 0x7fff0e7fc6c0 (LWP 42868)]
[New Thread 0x7fff0dffb6c0 (LWP 42869)]
[New Thread 0x7fff0d7fa6c0 (LWP 42870)]
[New Thread 0x7fff0cff96c0 (LWP 42871)]
[New Thread 0x7ffeeffff6c0 (LWP 42872)]
[New Thread 0x7ffeef7fe6c0 (LWP 42873)]
[New Thread 0x7ffeeeffd6c0 (LWP 42874)]
[New Thread 0x7ffeee7fc6c0 (LWP 42875)]
[New Thread 0x7ffeedffb6c0 (LWP 42876)]
[New Thread 0x7ffeed7fa6c0 (LWP 42877)]
[New Thread 0x7ffeecff96c0 (LWP 42878)]
[New Thread 0x7ffecffff6c0 (LWP 42879)]
[New Thread 0x7ffecf7fe6c0 (LWP 42880)]
[New Thread 0x7ffeceffd6c0 (LWP 42881)]
[New Thread 0x7ffece7fc6c0 (LWP 42882)]
mooch443 commented 1 year ago

@chiyu1203

@mooch443 Thank you so much for your reply. I have attached the entire video here. I was hoping to do barcode-based tracking and it looked like something went wrong saying "can not run python task while python is not initialised" and then they became repetitive...

frozen_tgrabs_slow_down05.mp4

Hm, it seems the important frames are skipped. Maybe a copy-paste of the entire output from the terminal would be better. The issue seems to be with the python import / initialization. Maybe you can try using the following from the beta channel:

conda create -n beta --override-channels -c trex-beta -c pytorch -c nvidia -c defaults trex pytorch-cuda=11.7
conda activate beta

and then (since you're on Windows apparently), when you're inside the environment:

python -m pip install opencv-python ultralytics 'numpy>=1.23,<1.24' 'tensorflow-gpu>=2,<3'

And see if this problem persists with this version. If something with the pytorch-cuda version doesn't work, try adding a specific release hash:

conda create -n beta --override-channels -c trex-beta -c pytorch -c nvidia -c defaults trex pytorch-cuda=11.7=h67b0de4_1
mooch443 commented 1 year ago

@pepelisu

Hi, Here is the output of tgrabs, then it hangs there forever.


This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.archlinux.org>
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]                                                                                           
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff547e6c0 (LWP 42814)]                                                                                                 
[New Thread 0x7ffff4c7d6c0 (LWP 42815)]
[New Thread 0x7fffe7fff6c0 (LWP 42816)]
[New Thread 0x7fffe77fe6c0 (LWP 42817)]
[New Thread 0x7fffe6ffd6c0 (LWP 42818)]
[New Thread 0x7fffe67fc6c0 (LWP 42819)]
[New Thread 0x7fffe5ffb6c0 (LWP 42820)]
[New Thread 0x7fffe57fa6c0 (LWP 42821)]
[New Thread 0x7fffe4ff96c0 (LWP 42822)]
[New Thread 0x7fffcffff6c0 (LWP 42823)]
[New Thread 0x7fffcf7fe6c0 (LWP 42824)]
[New Thread 0x7fffceffd6c0 (LWP 42825)]
[New Thread 0x7fffce7fc6c0 (LWP 42826)]
[New Thread 0x7fffcdffb6c0 (LWP 42827)]
[New Thread 0x7fffcd7fa6c0 (LWP 42828)]
[New Thread 0x7fffccff96c0 (LWP 42829)]
[New Thread 0x7fffaffff6c0 (LWP 42830)]
[New Thread 0x7fffaf7fe6c0 (LWP 42831)]
[New Thread 0x7fffaeffd6c0 (LWP 42832)]
[New Thread 0x7fffae7fc6c0 (LWP 42833)]
[New Thread 0x7fffadffb6c0 (LWP 42834)]
[New Thread 0x7fffad7fa6c0 (LWP 42835)]
[New Thread 0x7fffacff96c0 (LWP 42836)]
[New Thread 0x7fff8bfff6c0 (LWP 42837)]
[New Thread 0x7fff8b7fe6c0 (LWP 42838)]
[New Thread 0x7fff8affd6c0 (LWP 42839)]
[New Thread 0x7fff8a7fc6c0 (LWP 42840)]
[New Thread 0x7fff89ffb6c0 (LWP 42841)]
[New Thread 0x7fff897fa6c0 (LWP 42842)]
[New Thread 0x7fff88ff96c0 (LWP 42843)]
[New Thread 0x7fff6bfff6c0 (LWP 42844)]
[New Thread 0x7fff6b7fe6c0 (LWP 42845)]
[New Thread 0x7fff6affd6c0 (LWP 42846)]
[New Thread 0x7fff6a7fc6c0 (LWP 42847)]
[New Thread 0x7fff69ffb6c0 (LWP 42848)]
[New Thread 0x7fff697fa6c0 (LWP 42849)]
[New Thread 0x7fff68ff96c0 (LWP 42850)]
[New Thread 0x7fff53fff6c0 (LWP 42851)]
[New Thread 0x7fff537fe6c0 (LWP 42852)]
[New Thread 0x7fff52ffd6c0 (LWP 42853)]
[New Thread 0x7fff527fc6c0 (LWP 42854)]
[New Thread 0x7fff51ffb6c0 (LWP 42855)]
[New Thread 0x7fff517fa6c0 (LWP 42856)]
[New Thread 0x7fff50ff96c0 (LWP 42857)]
[New Thread 0x7fff27fff6c0 (LWP 42858)]
[New Thread 0x7fff277fe6c0 (LWP 42859)]
[New Thread 0x7fff26ffd6c0 (LWP 42860)]
[New Thread 0x7fff267fc6c0 (LWP 42861)]
[New Thread 0x7fff25ffb6c0 (LWP 42862)]
[New Thread 0x7fff257fa6c0 (LWP 42863)]
[New Thread 0x7fff24ff96c0 (LWP 42864)]
[New Thread 0x7fff0ffff6c0 (LWP 42865)]
[New Thread 0x7fff0f7fe6c0 (LWP 42866)]
[New Thread 0x7fff0effd6c0 (LWP 42867)]
[New Thread 0x7fff0e7fc6c0 (LWP 42868)]
[New Thread 0x7fff0dffb6c0 (LWP 42869)]
[New Thread 0x7fff0d7fa6c0 (LWP 42870)]
[New Thread 0x7fff0cff96c0 (LWP 42871)]
[New Thread 0x7ffeeffff6c0 (LWP 42872)]
[New Thread 0x7ffeef7fe6c0 (LWP 42873)]
[New Thread 0x7ffeeeffd6c0 (LWP 42874)]
[New Thread 0x7ffeee7fc6c0 (LWP 42875)]
[New Thread 0x7ffeedffb6c0 (LWP 42876)]
[New Thread 0x7ffeed7fa6c0 (LWP 42877)]
[New Thread 0x7ffeecff96c0 (LWP 42878)]
[New Thread 0x7ffecffff6c0 (LWP 42879)]
[New Thread 0x7ffecf7fe6c0 (LWP 42880)]
[New Thread 0x7ffeceffd6c0 (LWP 42881)]
[New Thread 0x7ffece7fc6c0 (LWP 42882)]

Maybe you can also try the version from above, although on Linux you do not have to perform the pip step yourself. Just to exclude that it's a bug that is resolved already. And if it does not work, please press CTRL+C and

bt

and press enter, and include the entire thing in the log as well as the command-line you used. You can also include a info threads (i think) for more complete information. Thanks a lot!

chiyu1203 commented 1 year ago

@mooch443 It was my mistake for documenting the error report to you. I am sorry for that. Here I uploaded the error report from the anaconda output under the original virtual environment (for details see attached file: tgrabs_output_original_environment.txt)

I followed your suggestion to install those dependencies. However, I could not created that beta virtual environment (the error message is shown as followed)

Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort. failed UnsatisfiableError:

Therefore, I decided to move on and install those dependencies within the original virtual environment I had (the one created based on Trex docs conda create -n tracking -c trexing trex )

pip install opencv-python ultralytics 
pip install numpy==1.23

And then I installed the following two packages based on the error of compatiblity issue during the installation

pip install keras==2.4 
pip install clang==5.0

Installing tensorflow-gpu was a difficult decision for me as I thought I already have a tensorflow package that combines both cpu and gpu together, so I first ran the same commend without installing tensorflow-gpu. Then it seems that tgrabs can be executed. However, there were some error in the anaconda output such as

[WARNING 20:39:12 GPURecognition.cpp:631] Cannot run python tasks while python is not initialized.

(for details see attached file: tgrabs_output_before_installing_tensorflowGPU.txt) so I moved on to install tensorflow-gpu. While my original virtual environment has tensorflow 2.6, I have manged to use tensorflow 2.8 on other virtual environment in this PC so I installed pip install tensorflow-gpu==2.8 which in fact upgrade installed tensorflow and tensorboard packages. Then I ran tgrabs under this upgraded environment. This time, tgrabs could be executed and no similiar erro in the output
(for details see attached file: tgrabs_output_after_updating_all_packages_without_zlibwapi.txt)
Except for an error about CUDA saying

Could not locate zlibwapi.dll. Please make sure it is in your library path!

Therefore I found a zlibwapi.dll and put it into CUDA folder. This time, no complaint about zlibwapi from CUDA but this GPURecognition error showed up again

[WARNING 21:21:46 GPURecognition.cpp:631] Cannot run python tasks while python is not initialized. (for details see attached file: tgrabs_output_withzlibwapi_inCUDA.txt)

In conclusion, it seems that at this stage, no matter this recognition error showed up or not, I could run tgrabs and GPU seems to be engaged. Not sure if there is any futher adjustment to do and if that zlibwapi.dll in the CUDA folder really matters.

tgrabs_output_after_updating_all_packages_without_zlibwapi.txt tgrabs_output_before_installing_tensorflowGPU.txt tgrabs_output_original_environment.txt.txt tgrabs_output_withzlibwapi_inCUDA.txt

mooch443 commented 1 year ago

@mooch443 It was my mistake for documenting the error report to you. I am sorry for that. Here I uploaded the error report from the anaconda output under the original virtual environment (for details see attached file: tgrabs_output_original_environment.txt)

I followed your suggestion to install those dependencies. However, I could not created that beta virtual environment (the error message is shown as followed)

Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort. failed UnsatisfiableError:

Therefore, I decided to move on and install those dependencies within the original virtual environment I had (the one created based on Trex docs conda create -n tracking -c trexing trex )

Yes, sorry, but I think that will not work (or in a very difficult way). So sorry about this, but this was my mistake actually. I edited the original post with this line that I actually tested (couldn't test it before since I was on a plane :) Please try this one again, if you don't mind:

conda create -n beta --override-channels -c trex-beta -c pytorch -c nvidia -c defaults trex pytorch-cuda=11.7=h67b0de4_1

Very dumb of me to forget the defaults channel after adding --override-channels :-S Thanks a lot for the effort to debug this! I also added the pytorch-cuda line since that was required on one of my computers for some reason. Just to be sure.