AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.73k stars 7.96k forks source link

Try to build on Jetson Nano #6466

Open noahcroit opened 4 years ago

noahcroit commented 4 years ago

Hi, I tried cmake (cmake . and then make) to build on Jetson Nano board and there's error. Here is what I got.


myjetson@myjetson:~/computer_vision/darknet$ cmake . -- The C compiler identification is GNU 7.5.0 -- The CXX compiler identification is GNU 7.5.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Setting build type to 'Release' as none was specified. -- Looking for a CUDA compiler -- Looking for a CUDA compiler - /usr/local/cuda/bin/nvcc -- The CUDA compiler identification is NVIDIA 10.0.326 -- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc -- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc -- works -- Detecting CUDA compiler ABI info -- Detecting CUDA compiler ABI info - done -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda (found version "10.0") -- Autodetected CUDA architecture(s): 5.3 -- Building with CUDA flags: -gencode;arch=compute_53,code=sm_53 -- Your setup does not supports half precision (it requires CC >= 7.0) -- Found OpenCV: /usr/local (found version "4.4.0") -- Found Stb: /home/myjetson/computer_vision/darknet/3rdparty/stb/include
-- Found OpenMP_C: -fopenmp (found version "4.5") -- Found OpenMP_CXX: -fopenmp (found version "4.5") -- Found OpenMP: TRUE (found version "4.5")
-- Found CUDNN: /usr/local/cuda/include (found version "7.6.0") -- CMAKE_CUDA_FLAGS: -gencode arch=compute_53,code=sm_53 --compiler-options " -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -Wno-deprecated-declarations -Wno-write-strings -DGPU -DCUDNN -DOPENCV -fPIC -fopenmp -Ofast " -- ZED SDK not found -- Configuring done -- Generating done -- Build files have been written to: /home/myjetson/computer_vision/darknet

myjetson@myjetson-desktop:~/computer_vision/darknet$ make Scanning dependencies of target dark [ 0%] Building CXX object CMakeFiles/dark.dir/src/yolo_v2_class.cpp.o c++: error: unrecognized command line option ‘-mavx’ c++: error: unrecognized command line option ‘-mavx2’ c++: error: unrecognized command line option ‘-msse3’ c++: error: unrecognized command line option ‘-msse4.1’ c++: error: unrecognized command line option ‘-msse4.2’ c++: error: unrecognized command line option ‘-msse4a’ CMakeFiles/dark.dir/build.make:62: recipe for target 'CMakeFiles/dark.dir/src/yolo_v2_class.cpp.o' failed make[2]: [CMakeFiles/dark.dir/src/yolo_v2_class.cpp.o] Error 1 CMakeFiles/Makefile2:109: recipe for target 'CMakeFiles/dark.dir/all' failed make[1]: [CMakeFiles/dark.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2


I have tried with build.sh too but it has the similar error with gcc which cannot recognized that command. Can you suggest how can I solve this problem?

Tetsujinfr commented 4 years ago

I got the same error on jetson xavier nx, cannot figure out what to do yet. In some threads I see this option maybe x86 specific but not sure. There are perf on jetson platforms all over the place on yolov4, can someone share how it has been built? Do we need to tweak some cmake options to get it built properly? thanks for your help

stephanecharette commented 4 years ago

I've built just fine on my Jetson Nano, though the last time was a few months ago. Which OS/image are you using, and exactly how are you trying to build?

Tetsujinfr commented 4 years ago

Merci Stéphane pour ta réponse.

I managed to get yolov4 built and running properly on the Jetson, but using make instead of cmake. Not sure wy cmake did not work, but I am not an expert so probably some config to tweak in there.

The make file is much simpler to edit and I did change the params I needed, all seems to work fine. The speed though is really slow so I need to investigate further. I am using the Zed camera and it runs @ 1fps right now on detection (and only 4 fps capture), but the input is 1280x720 so pretty large for the little Jetson NX to digest. Still, I do expect more. I even did compile with half precision!

stephanecharette commented 4 years ago

Did you enable the right ARCH= line for your Jetson Nano in the Makefile? See around line 48.

Did you enable CUDA and cuDNN in the Makefile?

Did you enable the right nvpmodel line on your Jetson Nano? Do a google search for nvpmodel. The one you need to get the full power is sudo nvpmodel -m 0 after you set the jumper on J48. Note that it really needs to be 4A. Most 5V adapters are less than 4A.

I don't have a camera on my Jetson Nano, I'm using it to process images obtained on another device, so I really don't know what kind of FPS you should expect.

Tetsujinfr commented 4 years ago

I have a jetson NX so with a volta gpu, I have set up all the makefile options appropriately I think, but I need to check if the inference is using Tensor RT. Also, I do no know how to check if yolo is inferred with tkDNN or not. I need to run the benchmark and compare to those on the git repo to check like for like. I will share my results.

How many fps do you have on your Nano when running on some std res images? Do you use Tensor RT optimization at inference time?

jahwanoh commented 3 years ago

Could you try after removing these in L175-176? -mavx -mavx2 -msse3 -msse4.1 -msse4.2 -msse4a

https://github.com/AlexeyAB/darknet/blob/9db8609e7a07409fe31bf484fb08db385350a5f9/CMakeLists.txt#L175

Ayke commented 3 years ago

Could you try after removing these in L175-176? -mavx -mavx2 -msse3 -msse4.1 -msse4.2 -msse4a

https://github.com/AlexeyAB/darknet/blob/9db8609e7a07409fe31bf484fb08db385350a5f9/CMakeLists.txt#L175

I have tried removing these two lines, it was fine to compile, but after completing the compiling, running the sample file darknet_video.py gives me core dumped. On my desktop, using CMake to install without modifying the cmakelists.txt works perfectly well. I think it is really a support issue on aarch64

Ayke commented 3 years ago

Oops! I found that core dumped was actually because my Jetson TX2 has very limited GPU and the memory ran out! I tried darknet_image.py and it works well!

Therefore, all you need to do is just to remove those two lines in CMakeLists.txt (the twolines that contains 'mavx' etc.)