Skip to content

Commit

Permalink
improve manifest mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cenit committed Feb 20, 2021
1 parent 9284d02 commit b9d296e
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 101 deletions.
115 changes: 48 additions & 67 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -376,73 +376,54 @@ jobs:
buildWithCMakeArgs: '--target install'


# win-vcpkg-cuda-ninja:
# runs-on: windows-latest
# steps:
# - uses: actions/checkout@v2
# - name: 'Install CUDA'
# run: |
# choco install cuda --version=10.2.89.20191206 -y
# $env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.."
# Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
# refreshenv
# echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# refreshenv
# echo $env:PATH
#
# - uses: lukka/get-cmake@latest
#
# - name: Restore from cache and run vcpkg
# env:
# CUDA_PATH: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2"
# CUDA_PATH_V10_2: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2"
# CUDA_TOOLKIT_ROOT_DIR: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2"
# CUDACXX: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2\\bin\\nvcc.exe"
# uses: lukka/run-vcpkg@v6
# with:
# setupOnly: true
# vcpkgDirectory: '${{ github.workspace }}/vcpkg'
# vcpkgGitCommitId: '865de0c130f3d34174ac7a410789df3c44a27fd2'
# appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}
# vcpkgTriplet: 'x64-windows'
# additionalCachedPaths: ${{ env.buildDir }}/vcpkg_installed
#
# - name: 'Build with CMake and Ninja'
# env:
# CUDA_PATH: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2"
# CUDA_PATH_V10_2: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2"
# CUDA_TOOLKIT_ROOT_DIR: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2"
# CUDACXX: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2\\bin\\nvcc.exe"
# uses: lukka/run-cmake@v3
# with:
# cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
# cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
# useVcpkgToolchainFile: true
# buildDirectory: '${{ runner.workspace }}/buildDirectory'
# cmakeAppendedArgs: "-GNinja -DCMAKE_BUILD_TYPE=Release -DSELECT_OPENCV_MODULES=ON"
# cmakeBuildType: 'Release'
# buildWithCMakeArgs: '--config Release --target install'
#
# - uses: actions/upload-artifact@v2
# with:
# name: darknet-vcpkg-cuda-${{ runner.os }}
# path: cfg
# - uses: actions/upload-artifact@v2
# with:
# name: darknet-vcpkg-cuda-${{ runner.os }}
# path: data
# - uses: actions/upload-artifact@v2
# with:
# name: darknet-vcpkg-cuda-${{ runner.os }}
# path: ${{ github.workspace }}/*dark*
# - uses: actions/upload-artifact@v2
# with:
# name: darknet-vcpkg-cuda-${{ runner.os }}
# path: ${{ runner.workspace }}/buildDirectory/Release/*.dll
# - uses: actions/upload-artifact@v2
# with:
# name: darknet-vcpkg-cuda-${{ runner.os }}
# path: ${{ github.workspace }}/uselib*
win-vcpkg-ninja:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2

- uses: lukka/get-cmake@latest

- name: Restore from cache and run vcpkg
uses: lukka/run-vcpkg@v6
with:
setupOnly: true
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgGitCommitId: '865de0c130f3d34174ac7a410789df3c44a27fd2'
appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}
vcpkgTriplet: 'x64-windows'
additionalCachedPaths: ${{ env.buildDir }}/vcpkg_installed

- name: 'Build with CMake and Ninja'
uses: lukka/run-cmake@v3
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
useVcpkgToolchainFile: true
buildDirectory: '${{ runner.workspace }}/buildDirectory'
cmakeAppendedArgs: "-GNinja -DCMAKE_BUILD_TYPE=Release -DSELECT_OPENCV_MODULES=ON -DENABLE_CUDA=OFF"
cmakeBuildType: 'Release'
buildWithCMakeArgs: '--config Release --target install'

- uses: actions/upload-artifact@v2
with:
name: darknet-vcpkg-${{ runner.os }}
path: cfg
- uses: actions/upload-artifact@v2
with:
name: darknet-vcpkg-${{ runner.os }}
path: data
- uses: actions/upload-artifact@v2
with:
name: darknet-vcpkg-${{ runner.os }}
path: ${{ github.workspace }}/*dark*
- uses: actions/upload-artifact@v2
with:
name: darknet-vcpkg-${{ runner.os }}
path: ${{ runner.workspace }}/buildDirectory/Release/*.dll
- uses: actions/upload-artifact@v2
with:
name: darknet-vcpkg-${{ runner.os }}
path: ${{ github.workspace }}/uselib*


win-intlibs:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ submission/
cfg/
build/darknet/*
build_*/
vcpkg_installed/
!build/darknet/YoloWrapper.cs
.fuse*
*.weights
Expand All @@ -33,6 +34,7 @@ build/detect_cuda_compute_capabilities.cu
build/.ninja_deps
build/.ninja_log
build/Makefile
*/vcpkg-manifest-install.log

# OS Generated #
.DS_Store*
Expand Down
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ option(ENABLE_CUDNN_HALF "Enable CUDNN Half precision" ON)
option(ENABLE_ZED_CAMERA "Enable ZED Camera support" ON)
option(ENABLE_VCPKG_INTEGRATION "Enable VCPKG integration" ON)

if(ENABLE_OPENCV AND ENABLE_CUDA AND NOT APPLE)
list(APPEND VCPKG_MANIFEST_FEATURES "opencv-cuda")
elseif(ENABLE_CUDA AND NOT APPLE)
list(APPEND VCPKG_MANIFEST_FEATURES "cuda")
elseif(ENABLE_OPENCV)
list(APPEND VCPKG_MANIFEST_FEATURES "opencv-base")
endif()
if(ENABLE_CUDNN AND NOT APPLE)
list(APPEND VCPKG_MANIFEST_FEATURES "cudnn")
endif()

if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_COMPILER_IS_GNUCC_OR_CLANG TRUE)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
Expand Down Expand Up @@ -49,6 +60,7 @@ if(ENABLE_VCPKG_INTEGRATION AND DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TO
#set(_VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_LIST_DIR}/vcpkg CACHE STRING "") #folder for manifest-installed dependencies
message(STATUS "VCPKG found: $ENV{VCPKG_ROOT}")
message(STATUS "Using VCPKG integration")
message(STATUS "VCPKG_MANIFEST_FEATURES: ${VCPKG_MANIFEST_FEATURES}")
set(USE_INTEGRATED_LIBS "FALSE" CACHE BOOL "Use libs distributed with this repo")
elseif(DEFINED CMAKE_TOOLCHAIN_FILE)
message(STATUS "Using toolchain: ${CMAKE_TOOLCHAIN_FILE}")
Expand Down Expand Up @@ -92,17 +104,13 @@ if(ENABLE_CUDA)
include(CheckLanguage)
check_language(CUDA)
if(NOT CMAKE_CUDA_COMPILER)
message(STATUS "PATH: $ENV{PATH}")
message(STATUS "CUDA_PATH: $ENV{CUDA_PATH}")
message(STATUS "CUDA_TOOLKIT_ROOT_DIR: $ENV{CUDA_TOOLKIT_ROOT_DIR}")
message(STATUS "CUDACXX: $ENV{CUDACXX}")
message(FATAL_ERROR "CUDA not found, please build explicitly with -DENABLE_CUDA=OFF if you do not want CUDA.")
else()
enable_language(CUDA)
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS "9.0")
message(STATUS "PATH: $ENV{PATH}")
message(STATUS "CUDA_PATH: $ENV{CUDA_PATH}")
message(STATUS "CUDA_TOOLKIT_ROOT_DIR: $ENV{CUDA_TOOLKIT_ROOT_DIR}")
message(STATUS "CUDACXX: $ENV{CUDACXX}")
message(FATAL_ERROR "Unsupported CUDA version, please upgrade to CUDA 9+ or disable CUDA with explicitly with -DENABLE_CUDA=OFF")
else()
Expand Down
5 changes: 3 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$number_of_build_workers = 8
$enable_cuda = $true
$use_vcpkg = $true
$use_ninja = $false
$use_ninja = $true
$force_cpp_build = $false

#$additional_build_setup = " -DCMAKE_CUDA_ARCHITECTURES=30"
Expand All @@ -20,7 +20,8 @@ else {
if ($use_ninja) {
$NINJA_EXE = Get-Command ninja | Select-Object -ExpandProperty Definition
if (-Not $NINJA_EXE) {
throw "Could not find Ninja, please install it"
$use_ninja = $false
Write-Host "Could not find Ninja, using msbuild as a fallback" -ForegroundColor Yellow
}
else {
Write-Host "Using Ninja from ${NINJA_EXE}"
Expand Down
29 changes: 11 additions & 18 deletions scripts/setup.ps1
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
## enable or disable installed components
#!/usr/bin/env pwsh

$install_choco = $true
$install_cuda = $true
$install_cuda = $false

if ($install_cuda -and -not $install_choco) {
Write-Host "If you want to install cuda without letting the script install also choco, be sure Chocolatey is already installed"
}

###########################

# Download and install Chocolatey
Set-ExecutionPolicy unrestricted
if ($install_choco) {
if ($null -eq (Get-Command "choco.exe" -ErrorAction SilentlyContinue)) {
# Download and install Chocolatey
Set-ExecutionPolicy unrestricted -Scope CurrentUser
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Write-Host "Please close and re-open powershell and then re-run setup.ps1 script"
Break
}
choco.exe install -y cmake ninja powershell git vscode
choco-exe install -y visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.CoreBuildTools --includeRecommended --includeOptional --passive --locale en-US --lang en-US"

Start-Process -FilePath "choco" -Verb runAs -ArgumentList " install -y cmake ninja powershell git vscode"
Start-Process -FilePath "choco" -Verb runAs -ArgumentList " install -y visualstudio2019buildtools --package-parameters `"--add Microsoft.VisualStudio.Component.VC.CoreBuildTools --includeRecommended --includeOptional --passive --locale en-US --lang en-US`""

if ($install_cuda) {
choco-exe install -y cuda
Start-Process -FilePath "choco" -Verb runAs -ArgumentList " install -y cuda"
$features = "full"
}
else {
Expand All @@ -30,9 +26,6 @@ else {
}
}

Remove-Item -r $temp_folder
Set-Location ..
Set-Location $vcpkg_folder\
git.exe clone https://github.com/microsoft/vcpkg
Set-Location vcpkg
.\bootstrap-vcpkg.bat -disableMetrics
Expand Down
111 changes: 101 additions & 10 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,110 @@
{
"name": "darknet",
"version-string": "0.2.5.4",
"port-version": 1,
"port-version": 2,
"homepage": "https://github.com/alexeyab/darknet",
"description": "Neural networks for object detection",
"description": "Darknet is an open source neural network framework written in C and CUDA. You only look once (YOLO) is a state-of-the-art, real-time object detection system, best example of darknet functionalities.",
"dependencies": [
"stb",
"pthreads",
{
"name": "opencv",
"features": [ "ffmpeg" ]
"pthreads"
],
"features": {
"cuda": {
"description": "Build darknet with support for CUDA",
"dependencies": [
"cuda"
]
},
{
"name": "cudnn",
"platform": "!osx"
"cudnn": {
"description": "Build darknet with support for cuDNN",
"dependencies": [
"cuda",
"cudnn"
]
},
"opencv-base": {
"description": "Build darknet with support for latest version of OpenCV",
"dependencies": [
{
"name": "opencv",
"features": [
"ffmpeg"
]
}
]
},
"opencv-cuda": {
"description": "Build darknet with support for latest version of CUDA-enabled OpenCV",
"dependencies": [
{
"name": "opencv",
"features": [
"ffmpeg"
]
},
{
"name": "opencv",
"features": [
"cuda"
]
}
]
},
"opencv2-base": {
"description": "Build darknet with support for OpenCV2",
"dependencies": [
{
"name": "opencv2",
"features": [
"ffmpeg"
]
}
]
},
"opencv2-cuda": {
"description": "Build darknet with support for CUDA-enabled OpenCV2",
"dependencies": [
{
"name": "opencv2",
"features": [
"ffmpeg"
]
},
{
"name": "opencv2",
"features": [
"cuda"
]
}
]
},
"opencv3-base": {
"description": "Build darknet with support for OpenCV3",
"dependencies": [
{
"name": "opencv3",
"features": [
"ffmpeg"
]
}
]
},
"opencv3-cuda": {
"description": "Build darknet with support for CUDA-enabled OpenCV3",
"dependencies": [
{
"name": "opencv3",
"features": [
"ffmpeg"
]
},
{
"name": "opencv3",
"features": [
"cuda"
]
}
]
}
]
}
}

0 comments on commit b9d296e

Please sign in to comment.