AlexeyAB / darknet

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

Unable to compile with RTX3070 cuda 11.2 #7628

Open igigod opened 3 years ago

igigod commented 3 years ago

Hello, I'm not able to compile pure darknet. I've installed drivers according to this tutorial: https://medium.com/analytics-vidhya/install-cuda-11-2-cudnn-8-1-0-and-python-3-9-on-rtx3090-for-deep-learning-fcf96c95f7a1

In Makefile I leaved only ARCH= -gencode arch=compute_86,code=[sm_86,compute_86] and comment other stuff with ARCH

How to solve it? Ubuntu 18.04 LTS

.bashrc: export PATH=/usr/local/cuda-11.2/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} export CUDA_HOME=/usr/local/cuda export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

conda .yml file

name: yolov4-gpu-clear

channels:
  - conda-forge
  - defaults

dependencies:
  - python==3.7
  - pip
  - matplotlib
  - opencv
  - pip:
    - tensorflow-gpu==2.4.0

Selection_019

cenit commented 3 years ago

can you please try to install powershell if you do not already have it and build using cmake toolchain (just run ./build.ps1)

stephanecharette commented 3 years ago

@cenit Powershell on Ubuntu?

@igigod Part of the NVIDIA installation is making sure the installed tools are in your path. The NVIDIA CUDA software should be installed in /opt/nvidia/... and /usr/local/cuda/. For example, once installed on my Ubuntu 18.04, it looks like this for me:

> ls -lh /usr/local/
total 36K
drwxrwxr-x  2 root root 4.0K Apr 20 22:33 bin/
lrwxrwxrwx  1 root root   22 Apr 20 22:34 cuda -> /etc/alternatives/cuda/
lrwxrwxrwx  1 root root   25 Apr 20 22:34 cuda-11 -> /etc/alternatives/cuda-11/
drwxr-xr-x 15 root root 4.0K Apr 20 22:33 cuda-11.3/

I didn't create these directories and symbolic links, it should automatically happen if you follow the installation steps for CUDA. The other directories should look like this:

> ls -lh /opt/nvidia/
total 8.0K
drwxr-xr-x 3 root root 4.0K Apr 20 22:33 nsight-compute/
drwxrwxr-x 3 root root 4.0K Apr 20 22:33 nsight-systems/

and:

> ls -lh /opt/nvidia/nsight-compute/2021.1.0/
total 72K
drwxr-xr-x 13 root root 4.0K Apr 20 22:33 docs/
-rw-r--r--  1 root root  33K Mar  8 13:16 EULA.txt
drwxr-xr-x  4 root root 4.0K Apr 20 22:33 extras/
drwxr-xr-x  3 root root 4.0K Apr 20 22:33 host/
...etc...

The only part I change by hand is my path, where I've manually added the following two entries:

You'll note that nvcc is in /usr/local/cuda/bin/:

> which nvcc
/usr/local/cuda/bin/nvcc
cenit commented 3 years ago

yes powershell in ubuntu :)

igigod commented 3 years ago

On my computer it looks like:

$ ls -lh /usr/local/
total 32K
lrwxrwxrwx  1 root root   21 kwi 20 09:00 cuda -> /usr/local/cuda-11.2/
drwxr-xr-x 17 root root 4,0K kwi 20 09:01 cuda-11.2
drwxr-xr-x  2 root root 4,0K lut  3  2020 etc
drwxr-xr-x  2 root root 4,0K lut  3  2020 games
drwxr-xr-x  2 root root 4,0K lut  3  2020 include
drwxr-xr-x  6 root root 4,0K mar 25 14:18 lib
lrwxrwxrwx  1 root root    9 mar  7 19:14 man -> share/man
drwxr-xr-x  2 root root 4,0K lut  3  2020 sbin
drwxr-xr-x  8 root root 4,0K mar  8 21:11 share
drwxr-xr-x  2 root root 4,0K lut  3  2020 src

and:

$ ls -lh /opt/nvidia/
ls: cannot access '/opt/nvidia/': No such file or directory

and:

$ which nvcc
/usr/local/cuda-11.2/bin/nvcc

According to Nvidia docs

9.1.1. Environment Setup The PATH variable needs to include $ export PATH=/usr/local/cuda-11.3/bin${PATH:+:${PATH}}. Nsight Compute has moved to /opt/nvidia/nsight-compute/ only in rpm/deb installation method. When using .run installer it is still located under /usr/local/cuda-11.3/.

So in my case:

$ ls -lh /usr/local/cuda-11.2/nsight-compute-2020.3.1/
total 72K
drwxr-xr-x 13 root root 4,0K kwi 20 09:00 docs
-rw-r--r--  1 root root  33K kwi 20 09:00 EULA.txt
drwxr-xr-x  4 root root 4,0K kwi 20 09:00 extras
drwxr-xr-x  3 root root 4,0K kwi 20 09:00 host
-rwxr-xr-x  1 root root  404 kwi 20 09:00 ncu
-rwxr-xr-x  1 root root  115 kwi 20 09:00 ncu-ui
-rwxr-xr-x  1 root root  115 kwi 20 09:00 nv-nsight-cu
-rwxr-xr-x  1 root root  404 kwi 20 09:00 nv-nsight-cu-cli
drwxr-xr-x  2 root root 4,0K kwi 20 09:00 sections
drwxr-xr-x  6 root root 4,0K kwi 20 09:00 target

Still I have no idea hov to fix it

The only part I change by hand is my path, where I've manually added the following two entries: /opt/nvidia/nsight-compute/2021.1.0 /usr/local/cuda/bin You'll note that nvcc is in /usr/local/cuda/bin/:

I don't know what to do. Could you tell me how to do step by step?

cenit commented 3 years ago

can you please really try to install powershell and then run ./build.ps1? It should be as much automatic as possible. We can try our best to make it work for you if you give any feedback on this procedure

SpongeBab commented 3 years ago

@cenit,I meet this problem again. I remove the build/darknet/ and rebuild it with VScode.It can build darknet.But today I open my vscode and rebuild it ,it remind:

[main] Building folder: darknet 
[main] Configuring folder: darknet 
[proc] Executing command: /usr/local/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_COMPILER:FILEPATH=/bin/gcc-9 -DCMAKE_CXX_COMPILER:FILEPATH=/bin/g++-9 -H/home/xiaopeng/YOLOV4/darknet -B/home/xiaopeng/YOLOV4/darknet/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 9.3.0
[cmake] -- The CXX compiler identification is GNU 9.3.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: /bin/gcc-9 - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: /bin/g++-9 - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Looking for a CUDA compiler
[cmake] -- Looking for a CUDA compiler - NOTFOUND
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "/home/xiaopeng/YOLOV4/darknet/build/CMakeFiles/CMakeOutput.log".
[cmake] See also "/home/xiaopeng/YOLOV4/darknet/build/CMakeFiles/CMakeError.log".
[cmake] CMake Error at CMakeLists.txt:92 (message):
[cmake]   CUDA not found, please build explicitly with -DENABLE_CUDA=OFF if you do
[cmake]   not want CUDA
[cmake] 

AGAIN.... My cuda info:

(base) xiaopeng@xiaopeng-HP-Z800-Workstation:~/Code$ ls -lh /usr/local/
总用量 36K
drwxr-xr-x  2 root root 4.0K 4月  24 20:01 bin
lrwxrwxrwx  1 root root   21 3月  29 08:53 cuda -> /usr/local/cuda-10.1/
drwxrwxrwx 18 root root 4.0K 3月  29 08:53 cuda-10.1
drwxr-xr-x  2 root root 4.0K 8月   1  2020 etc
drwxr-xr-x  2 root root 4.0K 8月   1  2020 games
drwxrwxrwx  3 root root 4.0K 4月  10 15:50 include
drwxr-xr-x  5 root root 4.0K 4月  22 09:05 lib
lrwxrwxrwx  1 root root    9 3月  19 14:33 man -> share/man
drwxr-xr-x  2 root root 4.0K 8月   1  2020 sbin
drwxr-xr-x 10 root root 4.0K 3月  24 10:58 share
drwxr-xr-x  2 root root 4.0K 8月   1  2020 src
(base) xiaopeng@xiaopeng-HP-Z800-Workstation:~/Code$ ls -lh /usr/local/cuda-10.1
总用量 128K
drwxr-xr-x  3 root root 4.0K 3月  29 08:53 bin
drwxr-xr-x  5 root root 4.0K 3月  29 08:53 doc
-rw-r--r--  1 root root  59K 3月  29 08:53 EULA.txt
drwxr-xr-x  6 root root 4.0K 3月  29 08:53 extras
lrwxrwxrwx  1 root root   28 3月  29 08:53 include -> targets/x86_64-linux/include
drwxr-xr-x  5 root root 4.0K 3月  29 08:53 jre
lrwxrwxrwx  1 root root   24 3月  29 08:53 lib64 -> targets/x86_64-linux/lib
drwxr-xr-x  8 root root 4.0K 3月  29 08:53 libnsight
drwxr-xr-x  7 root root 4.0K 3月  29 08:53 libnvvp
drwxr-xr-x  7 root root 4.0K 3月  29 08:53 NsightCompute-2019.1
drwxr-xr-x  2 root root 4.0K 3月  29 08:53 nsightee_plugins
drwxr-xr-x  4 root root 4.0K 3月  29 08:53 NsightSystems-2018.3
drwxr-xr-x  3 root root 4.0K 3月  29 08:53 nvml
drwxr-xr-x  7 root root 4.0K 3月  29 08:53 nvvm
drwxr-xr-x 11 root root 4.0K 3月  29 08:53 samples
drwxr-xr-x  3 root root 4.0K 3月  29 08:53 share
drwxr-xr-x  2 root root 4.0K 3月  29 08:53 src
drwxr-xr-x  3 root root 4.0K 3月  29 08:53 targets
drwxr-xr-x  2 root root 4.0K 3月  29 08:54 tools
-rw-r--r--  1 root root   22 3月  29 08:53 version.txt
(base) xiaopeng@xiaopeng-HP-Z800-Workstation:~/Code$ which nvcc
/usr/local/cuda/bin/nvcc
(base) xiaopeng@xiaopeng-HP-Z800-Workstation:~/Code$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:17_PST_2019
Cuda compilation tools, release 10.1, V10.1.105

when I ./build.ps1:

(base) xiaopeng@xiaopeng-HP-Z800-Workstation:~/YOLOV4/darknet$ ./build.ps1
Get-Command: /home/xiaopeng/YOLOV4/darknet/build.ps1:13
Line |
  13 |  $NINJA_EXE = Get-Command ninja | Select-Object -ExpandProperty Defini …
     |               ~~~~~~~~~~~~~~~~~
     | The term 'ninja' is not recognized as a name of a cmdlet,
     | function, script file, or executable program. Check the
     | spelling of the name, or if a path was included, verify that
     | the path is correct and try again.

Using CMake from /usr/local/bin/cmake
Exception: /home/xiaopeng/YOLOV4/darknet/build.ps1:23
Line |
  23 |    throw "Could not find Ninja, please install it"
     |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Could not find Ninja, please install it
cenit commented 3 years ago

git pull? are you up to date? seems not

SpongeBab commented 3 years ago

@cenit OK,yeah, it is not the latest version.I am training with it.Maybe it is because I am using darknet for training so I cannot rebuild it? I will try git pull later,my train will be finished soon.I will reply you later.

cenit commented 3 years ago

@SpongeBab you might try #7644 and tell me if it's working better for your problem. Please also do not spam this issue which is on another topic

SpongeBab commented 3 years ago

@cenit .OK,I'm sorry.Please allow me to say one more.I found the reason.Maybe you also care about it。 @igigod .I found a reason. I just use the Makefile to make.And then it remind me:

/usr/local/cuda/include/crt/host_config.h:129:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  129 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~

The cuda version and gcc version must correspond. I debugged another program and upgraded my gcc version to gcc9.。You can go to https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.htmlto get more information.Cuda 11.2 is latest,maybe your gcc version is not up to date. I'm using VSCode,and I found change the gcc version in VSCode doesn't work.You must change the gcc version in the terminal with: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 50 In the terminal My gcc version is the gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04).And I change the version by VSCode.Like this. 2021-04-26 09-27-05 的屏幕截图 Then output:

cmake] See also "/home/xiaopeng/YOLOV4/darknet/build/CMakeFiles/CMakeOutput.log".
[cmake] See also "/home/xiaopeng/YOLOV4/darknet/build/CMakeFiles/CMakeError.log".
[cmake] CMake Error at CMakeLists.txt:92 (message):
[cmake]   CUDA not found, please build explicitly with -DENABLE_CUDA=OFF if you do
[cmake]   not want CUDA
[cmake]