我设置了一个名为“mainenv”的 Conda 环境,我正尝试在其中安装支持 GPU 的 OpenCV。我的系统是 Ubuntu 22.04、AMD 7800x3D CPU、Nvidia RTX 4090 GPU,我已经安装了 CUDA 12.1 和 CuDNN 8.9。我一直在尝试按照本网站上的说明进行操作:
https://gist.github.com/raulqf/f42c718a658cddc16f9df07ecc627be7
我已经到了使用以下选项运行 cmake 的地步:
cmake
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_TBB=ON -D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 \
-D WITH_CUDA=ON \
-D BUILD_opencv_cudacodec=OFF \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D CUDA_ARCH_BIN=8.9 \
-D WITH_V4L=ON -D WITH_QT=OFF \
-D WITH_OPENGL=ON \
-D WITH_GSTREAMER=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_PC_FILE_NAME=opencv.pc \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_PYTHON3_INSTALL_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D PYTHON_EXECUTABLE=$(which python3) \
-D OPENCV_EXTRA_MODULES_PATH=~/Downloads/opencv_contrib-4.7.0/modules \
-D INSTALL_PYTHON_EXAMPLES=OFF -D INSTALL_C_EXAMPLES=OFF \
-D BUILD_EXAMPLES=OFF \
-D CUDNN_LIBRARY=/home/(my username)/anaconda3/envs/mainenv/lib/python3.9/site-packages/nvidia/cudnn/lib/libcudnn.so.8 \
-D CUDNN_INCLUDE_DIR=/home/(my username)/anaconda3/envs/mainenv/lib/python3.9/site-packages/nvidia/cudnn/include \
-D CUDNN_VERSION='8.9' ..
配置摘要表明它已正确构建。然而,当我尝试编译它时,出现以下错误:
[ 3%] Building CXX object modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/fundamental_kernel.cc.o
In file included from /usr/include/string.h:535,
from /home/dehavenm/Downloads/opencv-4.7.0/3rdparty/protobuf/src/google/protobuf/stubs/port.h:39,
from /home/dehavenm/Downloads/opencv-4.7.0/3rdparty/protobuf/src/google/protobuf/stubs/common.h:48,
from /home/dehavenm/Downloads/opencv-4.7.0/3rdparty/protobuf/src/google/protobuf/message_lite.h:45,
from /home/dehavenm/Downloads/opencv-4.7.0/3rdparty/protobuf/src/google/protobuf/message_lite.cc:36:
In function ‘void* memcpy(void*, const void*, size_t)’,
inlined from ‘uint8_t* google::protobuf::io::EpsCopyOutputStream::WriteRaw(const void*, int, uint8_t*)’ at /home/dehavenm/Downloads/opencv-4.7.0/3rdparty/protobuf/src/google/protobuf/io/coded_stream.h:706:16,
inlined from ‘virtual uint8_t* google::protobuf::internal::ImplicitWeakMessage::_InternalSerialize(uint8_t*, google::protobuf::io::EpsCopyOutputStream*) const’ at /home/dehavenm/Downloads/opencv-4.7.0/3rdparty/protobuf/src/google/protobuf/implicit_weak_message.h:84:28,
inlined from ‘bool google::protobuf::MessageLite::SerializePartialToZeroCopyStream(google::protobuf::io::ZeroCopyOutputStream*) const’ at /home/dehavenm/Downloads/opencv-4.7.0/3rdparty/protobuf/src/google/protobuf/message_lite.cc:412:30,
inlined from ‘bool google::protobuf::MessageLite::SerializeToZeroCopyStream(google::protobuf::io::ZeroCopyOutputStream*) const’ at /home/dehavenm/Downloads/opencv-4.7.0/3rdparty/protobuf/src/google/protobuf/message_lite.cc:396:42:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: warning: ‘void* __builtin___memcpy_chk(void*, const void*, long unsigned int, long unsigned int)’ specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
29 | return __builtin___memcpy_chk (__dest, __src, __len,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
30 | __glibc_objsize0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘void* memcpy(void*, const void*, size_t)’,
inlined from ‘uint8_t* google::protobuf::io::EpsCopyOutputStream::WriteRaw(const void*, int, uint8_t*)’ at /home/dehavenm/Downloads/opencv-4.7.0/3rdparty/protobuf/src/google/protobuf/io/coded_stream.h:706:16,
inlined from ‘virtual uint8_t* google::protobuf::internal::ImplicitWeakMessage::_InternalSerialize(uint8_t*, google::protobuf::io::EpsCopyOutputStream*) const’ at /home/dehavenm/Downloads/opencv-4.7.0/3rdparty/protobuf/src/google/protobuf/implicit_weak_message.h:84:28,
inlined from ‘bool google::protobuf::MessageLite::SerializePartialToZeroCopyStream(google::protobuf::io::ZeroCopyOutputStream*) const’ at /home/dehavenm/Downloads/opencv-4.7.0/3rdparty/protobuf/src/google/protobuf/message_lite.cc:412:30:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: warning: ‘void* __builtin___memcpy_chk(void*, const void*, long unsigned int, long unsigned int)’ specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
29 | return __builtin___memcpy_chk (__dest, __src, __len,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
30 | __glibc_objsize0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 3%] Linking CXX static library 3rdparty/lib/libade.a
[ 3%] Built target ade
[ 3%] Building C object 3rdparty/ippiw/CMakeFiles/ippiw.dir/src/iw_image_op_swap_channels.c.o
[ 8%] Linking CXX static library ../lib/libIlmImf.a
[ 8%] Built target IlmImf
[ 8%] Linking CXX static library ../lib/liblibprotobuf.a
[ 8%] Built target libprotobuf
[ 8%] Linking CXX static library ../../../../../../lib/libmultiview.a
[ 8%] Built target multiview
make: *** [Makefile:166: all] Error 2
我已将错误插入谷歌,但没有发现任何有用的信息。有谁知道这里可能出了什么问题?谢谢。