我目前正在尝试在我的 arch linux 计算机上构建一个包含 cuda 的 opencv 版本。为此,我使用opencv-cuda-git作为基础版本。此外,我修改了 PKGBUILD 并添加了额外的标志,以进一步使 opencv 适应我的系统。
但是,每次我运行构建过程(makepkg csri)时,它都会失败并显示以下错误消息:
[ 16%] Building CXX object modules/hdf/CMakeFiles/example_hdf_create_groups.dir/samples/create_groups.cpp.o
cd /home/tobias/builds/opencv-cuda-git/src/opencv/build/modules/hdf && /usr/bin/cmake -E cmake_link_script CMakeFiles/example_hdf_create_groups.dir/link.txt --verbose=1
/bin/g++-6 -std=c++11 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-invalid-offsetof -O3 -DNDEBUG -DNDEBUG -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,--gc-sections -rdynamic CMakeFiles/example_hdf_create_groups.dir/samples/create_groups.cpp.o -o ../../bin/example_hdf_create_groups -L/opt/cuda/lib64 ../../lib/libopencv_hdf.so.3.4.0 ../../lib/libopencv_highgui.so.3.4.0 ../../lib/libopencv_videoio.so.3.4.0 ../../lib/libopencv_imgcodecs.so.3.4.0 ../../lib/libopencv_imgproc.so.3.4.0 ../../lib/libopencv_core.so.3.4.0 ../../lib/libopencv_cudev.so.3.4.0
../../lib/libopencv_core.so.3.4.0: undefined reference to `cblas_zgemm'
../../lib/libopencv_core.so.3.4.0: undefined reference to `cblas_sgemm'
../../lib/libopencv_core.so.3.4.0: undefined reference to `cblas_dgemm'
../../lib/libopencv_core.so.3.4.0: undefined reference to `cblas_cgemm'
make[2]: *** [modules/hdf/CMakeFiles/example_hdf_create_groups.dir/build.make:102: bin/example_hdf_create_groups] Error 1
make[2]: Leaving directory '/home/tobias/builds/opencv-cuda-git/src/opencv/build'
make[1]: *** [CMakeFiles/Makefile2:2523: modules/hdf/CMakeFiles/example_hdf_create_groups.dir/all] Error 2
make[1]: Leaving directory '/home/tobias/builds/opencv-cuda-git/src/opencv/build'
make: *** [Makefile:163: all] Error 2
我之前的搜索表明此错误可能是由于 cublas 的链接错误而发生的。因此我尝试添加-L/opt/cuda/lib64和-卢库布拉斯到CMAKE_CXX_FLAGS。这根本没有什么区别。
另一个博客的建议包含使用 gcc-6 而不是 g++-6。然而,这会产生另一个错误:
[ 16%] Linking CXX executable ../../bin/example_hdf_create_groups
cd /home/tobias/builds/opencv-cuda-git/src/opencv/build/modules/hdf && /usr/bin/cmake -E cmake_link_script CMakeFiles/example_hdf_create_groups.dir/link.txt --verbose=1
/bin/gcc-6 -std=c++11 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-invalid-offsetof -O3 -DNDEBUG -DNDEBUG -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,--gc-sections -rdynamic CMakeFiles/example_hdf_create_groups.dir/samples/create_groups.cpp.o -o ../../bin/example_hdf_create_groups -L/opt/cuda/lib64 ../../lib/libopencv_hdf.so.3.4.0 ../../lib/libopencv_highgui.so.3.4.0 ../../lib/libopencv_videoio.so.3.4.0 ../../lib/libopencv_imgcodecs.so.3.4.0 ../../lib/libopencv_imgproc.so.3.4.0 ../../lib/libopencv_core.so.3.4.0 ../../lib/libopencv_cudev.so.3.4.0
ld: CMakeFiles/example_hdf_create_groups.dir/samples/create_groups.cpp.o: undefined reference to symbol '_ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.4'
/usr/lib/libstdc++.so.6: error adding symbols: DSO missing from command line
make[2]: *** [modules/hdf/CMakeFiles/example_hdf_create_groups.dir/build.make:102: bin/example_hdf_create_groups] Error 1
make[2]: Leaving directory '/home/tobias/builds/opencv-cuda-git/src/opencv/build'
make[1]: *** [CMakeFiles/Makefile2:2523: modules/hdf/CMakeFiles/example_hdf_create_groups.dir/all] Error 2
make[1]: Leaving directory '/home/tobias/builds/opencv-cuda-git/src/opencv/build'
make: *** [Makefile:163: all] Error 2
可以找到构建过程的整个输出和定制的 PKGBUILD 文件这里
Cuda 版本 9,nvidia-smi 的输出:
Sun Jan 14 14:44:13 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 387.34 Driver Version: 387.34 | |-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 780 Ti Off | 00000000:01:00.0 N/A | N/A |
| 32% 27C P8 N/A / N/A | 624MiB / 3017MiB | N/A Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 Not Supported |
+-----------------------------------------------------------------------------+
答案1
好的,结束这个问题:
问题是 opencv 需要Lapack
正常使用blas
,cblas
如果您使用的是ceres-solver
.然而,opencv 仅构建 links cublas
,这显然缺乏对 cblas 某些所需功能的支持。
cblas
此问题的一种解决方案是通过添加
CMAKE_EXE_LINKER_FLAGS=-lcblas
到cmake
PKGBUILD 文件中的调用来手动链接。
通过使用强制支持手动构建所有依赖项,可能可以完全规避此问题cublas
。然而,这很乏味,而且并不总是可行,因为cublas
这只是部分端口。
再次感谢菲利浦斯,谁帮我缩小了问题范围。