Skip to content

Commit

Permalink
update to cuda 11.7, update pthreads4w cmake module, upgrade ps1 scri…
Browse files Browse the repository at this point in the history
…pts (AlexeyAB#8586)
  • Loading branch information
cenit authored Jul 1, 2022
1 parent eaee506 commit 1ee1944
Show file tree
Hide file tree
Showing 11 changed files with 266 additions and 360 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,9 @@ jobs:

- name: 'Build'
env:
CUDA_PATH: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.6"
CUDA_TOOLKIT_ROOT_DIR: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.6"
CUDACXX: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.6\\bin\\nvcc.exe"
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"
shell: pwsh
run: ${{ github.workspace }}/build.ps1 -EnableCUDA -DisableInteractive -DoNotUpdateDARKNET

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ jobs:

- name: 'Build'
env:
CUDA_PATH: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.6"
CUDA_TOOLKIT_ROOT_DIR: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.6"
CUDACXX: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.6\\bin\\nvcc.exe"
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"
shell: pwsh
run: ${{ github.workspace }}/build.ps1 -EnableCUDA -DisableInteractive -DoNotUpdateDARKNET

Expand Down
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ elseif(WIN32)
set(USE_INTEGRATED_LIBS "TRUE" CACHE BOOL "Use libs distributed with this repo")
else()
message(WARNING "vcpkg not found, toolchain not defined, system not win32 so build might fail")
set(USE_INTEGRATED_LIBS "FALSE" CACHE BOOL "Use libs distributed with this repo")
set(USE_INTEGRATED_LIBS "TRUE" CACHE BOOL "Use libs distributed with this repo")
endif()

project(Darknet VERSION ${Darknet_VERSION})
Expand All @@ -112,7 +112,9 @@ enable_language(C)
enable_language(CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH})
if(USE_INTEGRATED_LIBS)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH})
endif()

if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_COMPILER_IS_GNUCC_OR_CLANG TRUE)
Expand Down Expand Up @@ -193,16 +195,14 @@ endif()

if(USE_INTEGRATED_LIBS)
set(PThreads4W_ROOT ${CMAKE_CURRENT_LIST_DIR}/3rdparty/pthreads CACHE PATH "Path where pthreads for windows can be located")
set(Stb_DIR ${CMAKE_CURRENT_LIST_DIR}/3rdparty/stb CACHE PATH "Path where Stb image library can be located")
endif()
set(Stb_DIR ${CMAKE_CURRENT_LIST_DIR}/3rdparty/stb CACHE PATH "Path where Stb image library can be located")

set(CMAKE_DEBUG_POSTFIX d)
set(CMAKE_THREAD_PREFER_PTHREAD ON)
find_package(Threads REQUIRED)
if(MSVC AND USE_INTEGRATED_LIBS)
if(MSVC)
find_package(PThreads4W REQUIRED)
elseif(MSVC)
find_package(pthreads REQUIRED)
endif()
if(ENABLE_OPENCV)
find_package(OpenCV REQUIRED)
Expand Down Expand Up @@ -476,11 +476,11 @@ if(CMAKE_COMPILER_IS_GNUCC)
endif()

if(MSVC)
target_link_libraries(darknet PRIVATE PThreads_windows::PThreads_windows)
target_link_libraries(darknet PRIVATE PThreads4W::PThreads4W)
target_link_libraries(darknet PRIVATE wsock32)
target_link_libraries(dark PUBLIC PThreads_windows::PThreads_windows)
target_link_libraries(dark PUBLIC PThreads4W::PThreads4W)
target_link_libraries(dark PUBLIC wsock32)
target_link_libraries(uselib PRIVATE PThreads_windows::PThreads_windows)
target_link_libraries(uselib PRIVATE PThreads4W::PThreads4W)
target_compile_definitions(darknet PRIVATE -D_CRT_RAND_S -DNOMINMAX -D_USE_MATH_DEFINES)
target_compile_definitions(dark PRIVATE -D_CRT_RAND_S -DNOMINMAX -D_USE_MATH_DEFINES)
target_compile_definitions(dark PUBLIC -D_CRT_SECURE_NO_WARNINGS)
Expand Down Expand Up @@ -515,7 +515,7 @@ if(ENABLE_CUDA)
target_compile_definitions(dark PUBLIC -DGPU)
endif()

if(USE_INTEGRATED_LIBS)
if(USE_INTEGRATED_LIBS AND WIN32)
target_compile_definitions(darknet PRIVATE -D_TIMESPEC_DEFINED)
target_compile_definitions(dark PRIVATE -D_TIMESPEC_DEFINED)
endif()
Expand All @@ -535,7 +535,7 @@ if(OpenCV_FOUND AND OpenCV_VERSION VERSION_GREATER "3.0" AND BUILD_USELIB_TRACK)
target_compile_definitions(uselib_track PRIVATE -DZED_STEREO)
endif()
if(MSVC)
target_link_libraries(uselib_track PRIVATE PThreads_windows::PThreads_windows)
target_link_libraries(uselib_track PRIVATE PThreads4W::PThreads4W)
target_compile_definitions(uselib_track PRIVATE -D_CRT_RAND_S -DNOMINMAX -D_USE_MATH_DEFINES)
endif()
target_link_libraries(uselib_track PRIVATE Threads::Threads)
Expand Down
6 changes: 1 addition & 5 deletions DarknetConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ set(CMAKE_THREAD_PREFER_PTHREAD ON)
find_dependency(Threads)

if(MSVC)
if(@USE_INTEGRATED_LIBS@)
find_dependency(PThreads4W)
else()
find_dependency(pthreads)
endif()
find_dependency(PThreads4W)
set(CMAKE_CXX_FLAGS "/wd4018 /wd4244 /wd4267 /wd4305 ${CMAKE_CXX_FLAGS}")
endif()

Expand Down
165 changes: 3 additions & 162 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -127,90 +127,15 @@ param (
[string]$AdditionalBuildSetup = "" # "-DCMAKE_CUDA_ARCHITECTURES=30"
)

$build_ps1_version = "1.9.8"
$build_ps1_version = "2.0.0"
Import-Module -Name $PSScriptRoot/scripts/utils.psm1 -Force

$ErrorActionPreference = "SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"
Start-Transcript -Path $PSScriptRoot/build.log

Function MyThrow ($Message) {
if ($DisableInteractive) {
Write-Host $Message -ForegroundColor Red
throw
}
else {
# Check if running in PowerShell ISE
if ($psISE) {
# "ReadKey" not supported in PowerShell ISE.
# Show MessageBox UI
$Shell = New-Object -ComObject "WScript.Shell"
$Shell.Popup($Message, 0, "OK", 0)
throw
}

$Ignore =
16, # Shift (left or right)
17, # Ctrl (left or right)
18, # Alt (left or right)
20, # Caps lock
91, # Windows key (left)
92, # Windows key (right)
93, # Menu key
144, # Num lock
145, # Scroll lock
166, # Back
167, # Forward
168, # Refresh
169, # Stop
170, # Search
171, # Favorites
172, # Start/Home
173, # Mute
174, # Volume Down
175, # Volume Up
176, # Next Track
177, # Previous Track
178, # Stop Media
179, # Play
180, # Mail
181, # Select Media
182, # Application 1
183 # Application 2

Write-Host $Message -ForegroundColor Red
Write-Host -NoNewline "Press any key to continue..."
while (($null -eq $KeyInfo.VirtualKeyCode) -or ($Ignore -contains $KeyInfo.VirtualKeyCode)) {
$KeyInfo = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown")
}
Write-Host ""
throw
}
}

Function DownloadNinja() {
Write-Host "Unable to find Ninja, downloading a portable version on-the-fly" -ForegroundColor Yellow
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue ninja
Remove-Item -Force -ErrorAction SilentlyContinue ninja.zip
if ($IsWindows -or $IsWindowsPowerShell) {
$url = "https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip"
}
elseif ($IsLinux) {
$url = "https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip"
}
elseif ($IsMacOS) {
$url = "https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-mac.zip"
}
else {
MyThrow("Unknown OS, unsupported")
}
Invoke-RestMethod -Uri $url -Method Get -ContentType application/zip -OutFile "ninja.zip"
Expand-Archive -Path ninja.zip
Remove-Item -Force -ErrorAction SilentlyContinue ninja.zip
}


Write-Host "Build script version ${build_ps1_version}"
Write-Host "Build script version ${build_ps1_version}, utils module version ${utils_psm1_version}"

if ((-Not $DisableInteractive) -and (-Not $UseVCPKG)) {
$Result = Read-Host "Enable vcpkg to install dependencies (yes/no)"
Expand Down Expand Up @@ -464,90 +389,6 @@ if (-Not $DoNotUseNinja) {
}
}

function getProgramFiles32bit() {
$out = ${env:PROGRAMFILES(X86)}
if ($null -eq $out) {
$out = ${env:PROGRAMFILES}
}

if ($null -eq $out) {
MyThrow("Could not find [Program Files 32-bit]")
}

return $out
}

function getLatestVisualStudioWithDesktopWorkloadPath() {
$programFiles = getProgramFiles32bit
$vswhereExe = "$programFiles\Microsoft Visual Studio\Installer\vswhere.exe"
if (Test-Path $vswhereExe) {
$output = & $vswhereExe -products * -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -format xml
[xml]$asXml = $output
foreach ($instance in $asXml.instances.instance) {
$installationPath = $instance.InstallationPath -replace "\\$" # Remove potential trailing backslash
}
if (!$installationPath) {
Write-Host "Warning: no full Visual Studio setup has been found, extending search to include also partial installations" -ForegroundColor Yellow
$output = & $vswhereExe -products * -latest -format xml
[xml]$asXml = $output
foreach ($instance in $asXml.instances.instance) {
$installationPath = $instance.InstallationPath -replace "\\$" # Remove potential trailing backslash
}
}
if (!$installationPath) {
Write-Host "Warning: no full Visual Studio setup has been found, extending search to include also pre-release installations" -ForegroundColor Yellow
$output = & $vswhereExe -prerelease -products * -latest -format xml
[xml]$asXml = $output
foreach ($instance in $asXml.instances.instance) {
$installationPath = $instance.InstallationPath -replace "\\$" # Remove potential trailing backslash
}
}
if (!$installationPath) {
MyThrow("Could not locate any installation of Visual Studio")
}
}
else {
MyThrow("Could not locate vswhere at $vswhereExe")
}
return $installationPath
}


function getLatestVisualStudioWithDesktopWorkloadVersion() {
$programFiles = getProgramFiles32bit
$vswhereExe = "$programFiles\Microsoft Visual Studio\Installer\vswhere.exe"
if (Test-Path $vswhereExe) {
$output = & $vswhereExe -products * -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -format xml
[xml]$asXml = $output
foreach ($instance in $asXml.instances.instance) {
$installationVersion = $instance.InstallationVersion
}
if (!$installationVersion) {
Write-Host "Warning: no full Visual Studio setup has been found, extending search to include also partial installations" -ForegroundColor Yellow
$output = & $vswhereExe -products * -latest -format xml
[xml]$asXml = $output
foreach ($instance in $asXml.instances.instance) {
$installationVersion = $instance.installationVersion
}
}
if (!$installationVersion) {
Write-Host "Warning: no full Visual Studio setup has been found, extending search to include also pre-release installations" -ForegroundColor Yellow
$output = & $vswhereExe -prerelease -products * -latest -format xml
[xml]$asXml = $output
foreach ($instance in $asXml.instances.instance) {
$installationVersion = $instance.installationVersion
}
}
if (!$installationVersion) {
MyThrow("Could not locate any installation of Visual Studio")
}
}
else {
MyThrow("Could not locate vswhere at $vswhereExe")
}
return $installationVersion
}

$vcpkg_root_set_by_this_script = $false

if ((Test-Path env:VCPKG_ROOT) -and $UseVCPKG) {
Expand Down
Loading

0 comments on commit 1ee1944

Please sign in to comment.