Skip to content

Commit

Permalink
Merge branch 'dev/alexey/master' into dev/cenit/deprecate_msbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
cenit committed Aug 27, 2023
2 parents 6f975a3 + 538c435 commit f8e3685
Show file tree
Hide file tree
Showing 33 changed files with 616 additions and 239 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Update apt
run: sudo apt update
- name: Install dependencies
run: sudo apt install libopencv-dev
run: sudo apt install libopencv-dev libgles2-mesa-dev

- name: 'Install CUDA'
run: ${{ github.workspace }}/scripts/deploy-cuda.sh
Expand Down Expand Up @@ -293,7 +293,7 @@ jobs:
- name: Update apt
run: sudo apt update
- name: Install dependencies
run: sudo apt install libopencv-dev
run: sudo apt install libopencv-dev libgles2-mesa-dev

- uses: lukka/get-cmake@latest

Expand Down Expand Up @@ -656,9 +656,9 @@ jobs:

- name: 'Build'
env:
CUDA_PATH: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.7"
CUDA_TOOLKIT_ROOT_DIR: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.7"
CUDACXX: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.7\\bin\\nvcc.exe"
CUDA_PATH: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.2"
CUDA_TOOLKIT_ROOT_DIR: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.2"
CUDACXX: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.2\\bin\\nvcc.exe"
shell: pwsh
run: ${{ github.workspace }}/build.ps1 -EnableCUDA -DisableInteractive -DoNotUpdateTOOL

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Update apt
run: sudo apt update
- name: Install dependencies
run: sudo apt install libopencv-dev
run: sudo apt install libopencv-dev libgles2-mesa-dev

- name: 'Install CUDA'
run: ${{ github.workspace }}/scripts/deploy-cuda.sh
Expand Down Expand Up @@ -215,7 +215,7 @@ jobs:
- name: Update apt
run: sudo apt update
- name: Install dependencies
run: sudo apt install libopencv-dev
run: sudo apt install libopencv-dev libgles2-mesa-dev

- uses: lukka/get-cmake@latest

Expand Down Expand Up @@ -408,9 +408,9 @@ jobs:

- name: 'Build'
env:
CUDA_PATH: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.7"
CUDA_TOOLKIT_ROOT_DIR: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.7"
CUDACXX: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.7\\bin\\nvcc.exe"
CUDA_PATH: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.2"
CUDA_TOOLKIT_ROOT_DIR: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.2"
CUDACXX: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.2\\bin\\nvcc.exe"
shell: pwsh
run: ${{ github.workspace }}/build.ps1 -EnableCUDA -DisableInteractive -DoNotUpdateTOOL

Expand Down
20 changes: 18 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ option(BUILD_USELIB_TRACK "Build uselib_track" ON)
option(MANUALLY_EXPORT_TRACK_OPTFLOW "Manually export the TRACK_OPTFLOW=1 define" OFF)
option(ENABLE_OPENCV "Enable OpenCV integration" ON)
option(ENABLE_CUDA "Enable CUDA support" ON)
cmake_dependent_option(ENABLE_CUDA_OPENGL_INTEGRATION "Build darknet with support for running networks straight from OpenGL textures" ON "ENABLE_CUDA" OFF)
option(ENABLE_CUDNN "Enable CUDNN" ON)
option(ENABLE_CUDNN_HALF "Enable CUDNN Half precision" ON)
option(ENABLE_ZED_CAMERA "Enable ZED Camera support" ON)
Expand Down Expand Up @@ -74,8 +75,6 @@ else()
set(IS_X86 FALSE)
endif()

cmake_dependent_option(ENABLE_SSE_AND_AVX_FLAGS "Enable AVX and SSE optimizations (x86-only)" ON "CMAKE_COMPILER_IS_GNUCC_OR_CLANG;IS_X86" OFF)

if(ENABLE_VCPKG_INTEGRATION AND DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(X_VCPKG_APPLOCAL_DEPS_INSTALL ON)
Expand Down Expand Up @@ -150,6 +149,8 @@ else()
set(CMAKE_COMPILER_IS_CLANG FALSE)
endif()

cmake_dependent_option(ENABLE_SSE_AND_AVX_FLAGS "Enable AVX and SSE optimizations (x86-only)" ON "CMAKE_COMPILER_IS_GNUCC_OR_CLANG;IS_X86" OFF)

set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
Expand Down Expand Up @@ -327,6 +328,11 @@ endif()
if(ENABLE_CUDA)
if(MSVC)
set(ADDITIONAL_CXX_FLAGS "${ADDITIONAL_CXX_FLAGS} /DGPU")

if(ENABLE_CUDA_OPENGL_INTEGRATION)
set(ADDITIONAL_CXX_FLAGS "${ADDITIONAL_CXX_FLAGS} /DCUDA_OPENGL_INTEGRATION")
endif()

if(CUDNN_FOUND)
set(ADDITIONAL_CXX_FLAGS "${ADDITIONAL_CXX_FLAGS} /DCUDNN")
endif()
Expand All @@ -337,6 +343,11 @@ if(ENABLE_CUDA)
set(CUDA_HOST_COMPILER_FLAGS "-Wno-deprecated-declarations -Xcompiler=\"${ADDITIONAL_CXX_FLAGS_COMMA_SEPARATED}\"")
else()
set(ADDITIONAL_CXX_FLAGS "${ADDITIONAL_CXX_FLAGS} -DGPU")

if(ENABLE_CUDA_OPENGL_INTEGRATION)
set(ADDITIONAL_CXX_FLAGS "${ADDITIONAL_CXX_FLAGS} -DCUDA_OPENGL_INTEGRATION")
endif()

if(CUDNN_FOUND)
set(ADDITIONAL_CXX_FLAGS "${ADDITIONAL_CXX_FLAGS} -DCUDNN")
endif()
Expand Down Expand Up @@ -544,6 +555,11 @@ if(ENABLE_CUDA)
target_compile_definitions(dark PUBLIC -DGPU)
endif()

if(ENABLE_CUDA_OPENGL_INTEGRATION)
target_compile_definitions(darknet PRIVATE -DCUDA_OPENGL_INTEGRATION)
target_compile_definitions(dark PUBLIC -DCUDA_OPENGL_INTEGRATION)
endif()

if(USE_INTEGRATED_LIBS AND WIN32)
target_compile_definitions(darknet PRIVATE -D_TIMESPEC_DEFINED)
target_compile_definitions(dark PRIVATE -D_TIMESPEC_DEFINED)
Expand Down
49 changes: 49 additions & 0 deletions Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM ubuntu:latest AS builder

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update -y

RUN apt-get install -y g++ make pkg-config libopencv-dev

COPY . /darknet

WORKDIR /darknet

RUN rm Dockerfile.cpu

RUN rm Dockerfile.gpu

RUN rm Docker-compose.yml

RUN make

FROM ubuntu:latest

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update -y

RUN apt-get install -y sudo libgomp1

RUN useradd -U -m yolo

RUN usermod -aG sudo yolo

RUN usermod --shell /bin/bash yolo

RUN echo "yolo:yolo" | chpasswd

COPY --from=builder /darknet /home/yolo/darknet

RUN cp /home/yolo/darknet/libdarknet.so /usr/local/lib/libdarknet.so || echo "libso not used"

RUN cp /home/yolo/darknet/include/darknet.h /usr/local/include/darknet.h

RUN ldconfig

WORKDIR /home/yolo/darknet

USER yolo


47 changes: 47 additions & 0 deletions Dockerfile.gpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM nvidia/cuda:11.6.0-cudnn8-devel-ubuntu20.04 AS builder

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update -y

RUN apt-get install -y g++ make pkg-config libopencv-dev

COPY . /darknet

WORKDIR /darknet

RUN rm Dockerfile.cpu

RUN rm Dockerfile.gpu

RUN rm Docker-compose.yml

RUN make

FROM nvidia/cuda:11.6.0-cudnn8-devel-ubuntu20.04

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update -y

RUN apt-get install -y sudo libgomp1

RUN useradd -U -m yolo

RUN usermod -aG sudo yolo

RUN usermod --shell /bin/bash yolo

RUN echo "yolo:yolo" | chpasswd

COPY --from=builder /darknet /home/yolo/darknet

RUN cp /home/yolo/darknet/libdarknet.so /usr/local/lib/libdarknet.so || echo "libso not used"

RUN cp /home/yolo/darknet/include/darknet.h /usr/local/include/darknet.h

RUN ldconfig

WORKDIR /home/yolo/darknet

USER yolo
60 changes: 38 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,70 @@ ZED_CAMERA=0
ZED_CAMERA_v2_8=0

# set GPU=1 and CUDNN=1 to speedup on GPU
# set CUDNN_HALF=1 to further speedup 3 x times (Mixed-precision on Tensor Cores) GPU: Volta, Xavier, Turing and higher
# set CUDNN_HALF=1 to further speedup 3 x times (Mixed-precision on Tensor Cores) GPU: Volta, Xavier, Turing, Ampere, Ada and higher
# set AVX=1 and OPENMP=1 to speedup on CPU (if error occurs then set AVX=0)
# set ZED_CAMERA=1 to enable ZED SDK 3.0 and above
# set ZED_CAMERA_v2_8=1 to enable ZED SDK 2.X

USE_CPP=0
DEBUG=0

ARCH= -gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=[sm_50,compute_50] \
ARCH= -gencode arch=compute_50,code=[sm_50,compute_50] \
-gencode arch=compute_52,code=[sm_52,compute_52] \
-gencode arch=compute_61,code=[sm_61,compute_61]

OS := $(shell uname)

# GeForce RTX 3070, 3080, 3090
# ARCH= -gencode arch=compute_86,code=[sm_86,compute_86]
# Naming confusion with recent RTX cards.
# "NVIDIA Quadro RTX x000" and T1000/Tx00 are Turing Architecture Family with Compute Capability of 7.5
# "NVIDIA RTX Ax000" are Ampere Architecture Family with Compute Capability of 8.6
# NVIDIA "RTX x000 Ada" are Ada Lovelace Architecture Family with Compute Capability of 8.9
# Source https://developer.nvidia.com/cuda-gpus

# Kepler GeForce GTX 770, GTX 760, GT 740
# KEPLER, GeForce GTX 770, GTX 760, GT 740
# ARCH= -gencode arch=compute_30,code=sm_30

# Tesla A100 (GA100), DGX-A100, RTX 3080
# ARCH= -gencode arch=compute_80,code=[sm_80,compute_80]
# MAXWELL, GeForce GTX 950, 960, 970, 980, 980 Ti, "GTX" Titan X
# ARCH= -gencode arch=compute_52,code=sm_52

# Jetson TX1, Tegra X1, DRIVE CX, DRIVE PX, Jetson Nano (2GB, 4GB)
# ARCH= -gencode arch=compute_53,code=[sm_53,compute_53]

# GP100/Tesla P100 - DGX-1
# ARCH= -gencode arch=compute_60,code=sm_60

# PASCAL, GTX 10x0, GTX 10x0 Ti, Titan Xp, Tesla P40, Tesla P4
# ARCH= -gencode arch=compute_61,code=[sm_61,compute_61]

# For Jetson TX2, Jetson Nano TX2 or Drive-PX2 uncomment:
# ARCH= -gencode arch=compute_62,code=[sm_62,compute_62]

# Tesla V100
# ARCH= -gencode arch=compute_70,code=[sm_70,compute_70]

# GeForce RTX 2080 Ti, RTX 2080, RTX 2070, Quadro RTX 8000, Quadro RTX 6000, Quadro RTX 5000, Tesla T4, XNOR Tensor Cores
# ARCH= -gencode arch=compute_75,code=[sm_75,compute_75]

# Jetson XAVIER
# Jetson XAVIER, XAVIER NX
# ARCH= -gencode arch=compute_72,code=[sm_72,compute_72]

# GTX 1080, GTX 1070, GTX 1060, GTX 1050, GTX 1030, Titan Xp, Tesla P40, Tesla P4
# ARCH= -gencode arch=compute_61,code=sm_61 -gencode arch=compute_61,code=compute_61
# GeForce Titan RTX, RTX 20x0, RTX 20x0 Ti, Quadro RTX x000, Tesla T4, XNOR Tensor Cores
# ARCH= -gencode arch=compute_75,code=[sm_75,compute_75]

# GP100/Tesla P100 - DGX-1
# ARCH= -gencode arch=compute_60,code=sm_60
# Tesla A100 (GA100), DGX-A100, A30, A100, RTX 3080
# ARCH= -gencode arch=compute_80,code=[sm_80,compute_80]

# For Jetson TX1, Tegra X1, DRIVE CX, DRIVE PX - uncomment:
# ARCH= -gencode arch=compute_53,code=[sm_53,compute_53]
# GeForce RTX 30x0, 30x0 Ti, Tesla GA10x, RTX Axxxx, A2, A10, A16, A40
# ARCH= -gencode arch=compute_86,code=[sm_86,compute_86]

# For Jetson Tx2 or Drive-PX2 uncomment:
# ARCH= -gencode arch=compute_62,code=[sm_62,compute_62]
# NOT TESTED, THEORETICAL
# Jetson ORIN, ORIN NX, ORIN NANO
# ARCH= -gencode arch=compute_87,code=[sm_87,compute_87]

# For Tesla GA10x cards, RTX 3090, RTX 3080, RTX 3070, RTX A6000, RTX A40 uncomment:
# ARCH= -gencode arch=compute_86,code=[sm_86,compute_86]
# NOT TESTED, THEORETICAL
# GeForce RTX 4070 Ti, 4080, 4090, L4, L40
# ARCH= -gencode arch=compute_89,code=[sm_89,compute_89]

# NOT TESTED, THEORETICAL
# Nvidia H100
# ARCH= -gencode arch=compute_90,code=[sm_90,compute_90]

VPATH=./src/
EXEC=darknet
Expand Down
Loading

0 comments on commit f8e3685

Please sign in to comment.