I have set up a runner (shell executor) on a Windows server with a lot more power than my own computer. The runner has been successfully registered with an on-premise hosted latest GitLab instance. Both computers have CUDA 12.2 and cuDNN 8.9.5.30 for CUDA 12.2 in place (the cuDNN are copied in the directory of CUDA) incl. PATH
and CUDA_PATH
set accordingly.
My project consists of multiple dependencies which I don’t want to build locally and would like to use CMake and/or Git to download and use. So I have split it into 2 repos – one for my application and one for the dependencies. My ultimate goal is to add automated download of artifacts from the repo with the dependencies in the CMake project of my main application.
One of the dependencies is OpenCV with GPU support. The structure of the Dependencies repo is following:
*
|
+-- REAMDE.md
|
+-- .gitmodules
|
+-- .gitignore
|
+-- .gitlab-ci.yml
|
+-- deps
|
+-- [submodule] opencv
|
+-- [submodule] opencv_contrib
|
+-- [submodules] other depenencies
|
+-- CMakeLists.txt
The .gitsubmodules
looks like
[submodule "deps/opencv"]
path = deps/opencv
url = https://github.com/opencv/opencv.git
branch="4.x"
[submodule "deps/opencv_contrib"]
path = deps/opencv_contrib
url = https://github.com/opencv/opencv_contrib.git
branch="4.x"
The CMakeLists.txt
is
cmake_minimum_required(VERSION 3.22)
project(Dependencies)
# Disable examples, tests and docs
set(BUILD_EXAMPLES OFF)
set(BUILD_TESTS OFF)
set(BUILD_DOCS OFF)
# Disable GUI
set(WITH_QT OFF)
set(WITH_GTK OFF)
set(WITH_WIN32UI OFF)
# Disable video
set(WITH_MSMF OFF)
set(WITH_FFMPEG OFF)
set(WITH_DSHOW OFF)
# Language support
set(BUILD_JAVA OFF)
set(BUILD_opencv_python2 OFF)
set(BUILD_opencv_python3 OFF)
if(BuildOpenCV_CPU_BASE)
add_subdirectory(opencv)
elseif(BuildOpenCV_GPU)
set(OPENCV_ENABLE_NONFREE OFF)
set(WITH_CUDA ON) # Currently using 11.8
set(WITH_CUDNN ON)
set(OPENCV_DNN_CUDA ON)
set(CUDA_ARCH_BIN=6.1)
set(WITH_NVCUVID OFF)
set(WITH_NVCUVENC OFF)
set(OPENCV_EXTRA_MODULES_PATH
"${CMAKE_SOURCE_DIR}/opencv_contrib/modules/cudaarithm"
"${CMAKE_SOURCE_DIR}/opencv_contrib/modules/cudabgsegm"
"${CMAKE_SOURCE_DIR}/opencv_contrib/modules/cudacodec"
"${CMAKE_SOURCE_DIR}/opencv_contrib/modules/cudafeatures2d"
"${CMAKE_SOURCE_DIR}/opencv_contrib/modules/cudafilters"
"${CMAKE_SOURCE_DIR}/opencv_contrib/modules/cudaimgproc"
"${CMAKE_SOURCE_DIR}/opencv_contrib/modules/cudalegacy"
"${CMAKE_SOURCE_DIR}/opencv_contrib/modules/cudaobjdetect"
#"${CMAKE_SOURCE_DIR}/opencv_contrib/modules/cudaoptflow"
"${CMAKE_SOURCE_DIR}/opencv_contrib/modules/cudastereo"
"${CMAKE_SOURCE_DIR}/opencv_contrib/modules/cudawarping"
"${CMAKE_SOURCE_DIR}/opencv_contrib/modules/cudev"
)
add_subdirectory(opencv)
endif()
while my .gitlab-ci.yml
is
stages:
- build
build-4.x-gpu-release:
stage: build
tags:
- srv
variables:
GIT_SUBMODULE_STRATEGY: recursive
GIT_SUBMODULE_PATHS: deps/*
artifacts:
paths:
- buildbinRelease*.dll
script:
- echo "build-4.x-gpu-release"
- cd deps
- cmake -Bbuild -G "Visual Studio 16 2019" -DBuildOpenCV_GPU=ON
- cmake.exe --build build --target ALL_BUILD --config Release
On my local computer, when I repeat the steps seen in the CI
job’s script
, I am able to configure the project and even compile it. On the server my runner reports (in the GitLab WebUI) that OpenCV GPU build requires enabled cudev
module from the contrib modules. I have also tried specifying the source directory using the -S
parameter of cmake
so that I would perhaps prevent some confusion with changing the directory in my CI job.
I can see in the logs that both cuDNN and CUDA are detected correctly:
Found CUDNN: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/lib/x64/cudnn.lib (found suitable version "8.9.5", minimum required is "7.5")
-- CUDA detected: 12.2
I can also see (through an extra debug message that prints out OPENCV_EXTRA_MODULES_PATH
inside my own CMakeLists.txt
that all modules I have selected are detected properly, in particular cudev
can be found at
D:/GITLAB/builds/6LxqbndAy/5/gitlab-srv/user/srv/dependencies/deps/opencv_contrib/modules/cudev
where D:/GITLAB/build
is the directory where the Windows runner (shell executor) is running all CI jobs.