improve CUDA setup instructions and templates in scripts

pull/2599/head
Stefano Sinigardi 6 years ago
parent dfa1735a90
commit fefc7ef803
  1. 160
      CMakeSettings.json
  2. 4
      README.md
  3. 42
      build.ps1

@ -20,9 +20,28 @@
"cmakeCommandArgs": "", "cmakeCommandArgs": "",
"configurationType": "Debug", "configurationType": "Debug",
"generator": "Visual Studio 15 2017 Win64", "generator": "Visual Studio 15 2017 Win64",
"name": "x64-Debug", "name": "x64-Debug static",
"variables": [ "variables": [{
"name": "CMAKE_TOOLCHAIN_FILE",
"value": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
},
{
"name": "USE_INTEGRATED_LIBS",
"value": "FALSE"
},
{ {
"name": "VCPKG_TARGET_TRIPLET",
"value": "${env.VCPKG_DEFAULT_TRIPLET}"
}
]
}, {
"buildCommandArgs": "-m -v:minimal",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"cmakeCommandArgs": "",
"configurationType": "Release",
"generator": "Visual Studio 15 2017 Win64",
"name": "x64-Release static",
"variables": [{
"name": "CMAKE_TOOLCHAIN_FILE", "name": "CMAKE_TOOLCHAIN_FILE",
"value": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake" "value": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
}, },
@ -35,16 +54,139 @@
"value": "${env.VCPKG_DEFAULT_TRIPLET}" "value": "${env.VCPKG_DEFAULT_TRIPLET}"
} }
] ]
}, }, {
"buildCommandArgs": "-m -v:minimal",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"cmakeCommandArgs": "",
"configurationType": "Debug",
"generator": "Visual Studio 15 2017 Win64",
"name": "x64-Debug static w/ CUDA",
"variables": [{
"name": "CMAKE_TOOLCHAIN_FILE",
"value": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
},
{
"name": "USE_INTEGRATED_LIBS",
"value": "FALSE"
},
{
"name": "CUDA_COMPUTE_MODEL",
"value": "30"
},
{
"name": "VCPKG_TARGET_TRIPLET",
"value": "${env.VCPKG_DEFAULT_TRIPLET}"
}
]
}, {
"buildCommandArgs": "-m -v:minimal",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"cmakeCommandArgs": "",
"configurationType": "Release",
"generator": "Visual Studio 15 2017 Win64",
"name": "x64-Release static w/ CUDA",
"variables": [{
"name": "CMAKE_TOOLCHAIN_FILE",
"value": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
},
{
"name": "USE_INTEGRATED_LIBS",
"value": "FALSE"
},
{
"name": "CUDA_COMPUTE_MODEL",
"value": "30"
},
{
"name": "VCPKG_TARGET_TRIPLET",
"value": "${env.VCPKG_DEFAULT_TRIPLET}"
}
]
}
{ {
"buildCommandArgs": "-m -v:minimal",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"cmakeCommandArgs": "",
"configurationType": "Debug",
"generator": "Visual Studio 15 2017 Win64",
"name": "x64-Debug dynamic",
"variables": [{
"name": "CMAKE_TOOLCHAIN_FILE",
"value": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
},
{
"name": "USE_INTEGRATED_LIBS",
"value": "FALSE"
},
{
"name": "BUILD_SHARED_LIBS",
"value": "TRUE"
},
{
"name": "VCPKG_TARGET_TRIPLET",
"value": "${env.VCPKG_DEFAULT_TRIPLET}"
}
]
}, {
"buildCommandArgs": "-m -v:minimal", "buildCommandArgs": "-m -v:minimal",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"cmakeCommandArgs": "", "cmakeCommandArgs": "",
"configurationType": "Release", "configurationType": "Release",
"generator": "Visual Studio 15 2017 Win64", "generator": "Visual Studio 15 2017 Win64",
"name": "x64-Release", "name": "x64-Release dynamic",
"variables": [ "variables": [{
"name": "CMAKE_TOOLCHAIN_FILE",
"value": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
},
{
"name": "USE_INTEGRATED_LIBS",
"value": "FALSE"
},
{
"name": "BUILD_SHARED_LIBS",
"value": "TRUE"
},
{
"name": "VCPKG_TARGET_TRIPLET",
"value": "${env.VCPKG_DEFAULT_TRIPLET}"
}
]
}, {
"buildCommandArgs": "-m -v:minimal",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"cmakeCommandArgs": "",
"configurationType": "Debug",
"generator": "Visual Studio 15 2017 Win64",
"name": "x64-Debug dynamic w/ CUDA",
"variables": [{
"name": "CMAKE_TOOLCHAIN_FILE",
"value": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
},
{ {
"name": "USE_INTEGRATED_LIBS",
"value": "FALSE"
},
{
"name": "CUDA_COMPUTE_MODEL",
"value": "30"
},
{
"name": "BUILD_SHARED_LIBS",
"value": "TRUE"
},
{
"name": "VCPKG_TARGET_TRIPLET",
"value": "${env.VCPKG_DEFAULT_TRIPLET}"
}
]
}, {
"buildCommandArgs": "-m -v:minimal",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"cmakeCommandArgs": "",
"configurationType": "Release",
"generator": "Visual Studio 15 2017 Win64",
"name": "x64-Release dynamic w/ CUDA",
"variables": [{
"name": "CMAKE_TOOLCHAIN_FILE", "name": "CMAKE_TOOLCHAIN_FILE",
"value": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake" "value": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
}, },
@ -52,6 +194,14 @@
"name": "USE_INTEGRATED_LIBS", "name": "USE_INTEGRATED_LIBS",
"value": "FALSE" "value": "FALSE"
}, },
{
"name": "CUDA_COMPUTE_MODEL",
"value": "30"
},
{
"name": "BUILD_SHARED_LIBS",
"value": "TRUE"
},
{ {
"name": "VCPKG_TARGET_TRIPLET", "name": "VCPKG_TARGET_TRIPLET",
"value": "${env.VCPKG_DEFAULT_TRIPLET}" "value": "${env.VCPKG_DEFAULT_TRIPLET}"

@ -183,9 +183,9 @@ PS \> cd $env:VCPKG_ROOT
PS Code\vcpkg> .\vcpkg install pthreads opencv #replace with opencv[cuda] in case you want to use cuda-accelerated openCV PS Code\vcpkg> .\vcpkg install pthreads opencv #replace with opencv[cuda] in case you want to use cuda-accelerated openCV
``` ```
8. [necessary only with CUDA] Customize the CMakeLists.txt with the preferred compute capability 8. [necessary only with CUDA] Customize the `build.ps1` script enabling the appropriate `my_cuda_compute_model` line. If not manually defined, CMake toolchain will automatically use the very low 3.0 CUDA compute model
9. Build with the Powershell script `build.ps1` or use the "Open Folder" functionality of Visual Studio 2017. In the first option, if you want to use Visual Studio, you will find a custom solution created for you by CMake after the build containing all the appropriate config flags for your system. 9. Build with the Powershell script `build.ps1`. If you want to use Visual Studio, you will find a custom solution created for you by CMake after the build containing all the appropriate config flags for your system.
### How to compile on Windows (legacy way) ### How to compile on Windows (legacy way)

@ -4,6 +4,18 @@ $number_of_build_workers=8
#$shared_lib="-DBUILD_SHARED_LIBS:BOOL=ON" #$shared_lib="-DBUILD_SHARED_LIBS:BOOL=ON"
$force_using_include_libs=$false $force_using_include_libs=$false
#$my_cuda_compute_model=75 #Compute capability for Tesla T4, RTX 2080
#$my_cuda_compute_model=72 #Compute capability for Jetson Xavier
#$my_cuda_compute_model=70 #Compute capability for Tesla V100
#$my_cuda_compute_model=62 #Compute capability for Jetson TX2
#$my_cuda_compute_model=61 #Compute capability for Tesla P40
#$my_cuda_compute_model=60 #Compute capability for Tesla P100
#$my_cuda_compute_model=53 #Compute capability for Jetson TX1
#$my_cuda_compute_model=52 #Compute capability for Tesla M40/M60
#$my_cuda_compute_model=37 #Compute capability for Tesla K80
#$my_cuda_compute_model=35 #Compute capability for Tesla K20/K40
#$my_cuda_compute_model=30 #Compute capability for Tesla K10, Quadro K4000
if ((Test-Path env:VCPKG_ROOT) -and -not $force_using_include_libs) { if ((Test-Path env:VCPKG_ROOT) -and -not $force_using_include_libs) {
$vcpkg_path = "$env:VCPKG_ROOT" $vcpkg_path = "$env:VCPKG_ROOT"
Write-Host "Found vcpkg in VCPKG_ROOT: $vcpkg_path" Write-Host "Found vcpkg in VCPKG_ROOT: $vcpkg_path"
@ -68,33 +80,39 @@ if (Test-Path env:CUDA_PATH) {
} }
} }
if ($vcpkg_path) { if($my_cuda_compute_model) {
# RELEASE $additional_build_setup = "-DCUDA_COMPUTE_MODEL=${my_cuda_compute_model}"
New-Item -Path .\build_win_release -ItemType directory -Force }
Set-Location build_win_release
cmake -G "Visual Studio 15 2017" -T "host=x64" -A "x64" "-DCMAKE_TOOLCHAIN_FILE=$vcpkg_path\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" "-DCMAKE_BUILD_TYPE=Release" $shared_lib ..
cmake --build . --config Release --parallel ${number_of_build_workers} --target install
Remove-Item DarknetConfig.cmake
Remove-Item DarknetConfigVersion.cmake
Set-Location ..
if ($vcpkg_path) {
# DEBUG # DEBUG
New-Item -Path .\build_win_debug -ItemType directory -Force New-Item -Path .\build_win_debug -ItemType directory -Force
Set-Location build_win_debug Set-Location build_win_debug
cmake -G "Visual Studio 15 2017" -T "host=x64" -A "x64" "-DCMAKE_TOOLCHAIN_FILE=$vcpkg_path\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" "-DCMAKE_BUILD_TYPE=Debug" $shared_lib .. cmake -G "Visual Studio 15 2017" -T "host=x64" -A "x64" "-DCMAKE_TOOLCHAIN_FILE=$vcpkg_path\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" "-DCMAKE_BUILD_TYPE=Debug" $shared_lib $additional_build_setup ..
cmake --build . --config Debug --parallel ${number_of_build_workers} --target install cmake --build . --config Debug --parallel ${number_of_build_workers} --target install
Remove-Item DarknetConfig.cmake Remove-Item DarknetConfig.cmake
Remove-Item DarknetConfigVersion.cmake Remove-Item DarknetConfigVersion.cmake
Set-Location .. Set-Location ..
# RELEASE
New-Item -Path .\build_win_release -ItemType directory -Force
Set-Location build_win_release
cmake -G "Visual Studio 15 2017" -T "host=x64" -A "x64" "-DCMAKE_TOOLCHAIN_FILE=$vcpkg_path\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" "-DCMAKE_BUILD_TYPE=Release" $shared_lib $additional_build_setup ..
cmake --build . --config Release --parallel ${number_of_build_workers} --target install
Remove-Item DarknetConfig.cmake
Remove-Item DarknetConfigVersion.cmake
Copy-Item *.dll ..
Set-Location ..
} }
else { else {
# USE LOCAL PTHREAD LIB, NO VCPKG, ONLY RELEASE # USE LOCAL PTHREAD LIB AND LOCAL STB HEADER, NO VCPKG, ONLY RELEASE MODE SUPPORTED
# if you want to manually force this case, remove VCPKG_ROOT env variable and remember to use "vcpkg integrate remove" in case you had enabled user-wide vcpkg integration # if you want to manually force this case, remove VCPKG_ROOT env variable and remember to use "vcpkg integrate remove" in case you had enabled user-wide vcpkg integration
New-Item -Path .\build_win_release_novcpkg -ItemType directory -Force New-Item -Path .\build_win_release_novcpkg -ItemType directory -Force
Set-Location build_win_release_novcpkg Set-Location build_win_release_novcpkg
cmake -G "Visual Studio 15 2017" -T "host=x64" -A "x64" $shared_lib .. cmake -G "Visual Studio 15 2017" -T "host=x64" -A "x64" $shared_lib $additional_build_setup ..
cmake --build . --config Release --parallel ${number_of_build_workers} --target install cmake --build . --config Release --parallel ${number_of_build_workers} --target install
Remove-Item DarknetConfig.cmake Remove-Item DarknetConfig.cmake
Remove-Item DarknetConfigVersion.cmake Remove-Item DarknetConfigVersion.cmake
Copy-Item ..\3rdparty\pthreads\bin\pthreadVC2.dll ..
Set-Location .. Set-Location ..
} }

Loading…
Cancel
Save