Ubuntu编译OpenCV-GPU问题合集

docker环境编译+GT 730+cuda-11.4

⚠️一开始在docker里配环境,得装nvidia-docker2,并且运行容器时需要加docker run --gpus all -it IMAGE

🤣事实上不需要在docker里装,wsl虚拟环境就足够用了(况且wsl里挂docker容器实在是卡爆了)

在DOCKER中linux系统编译安装GPU(CUDA)版本opencv4.5.4_docker配置opencv_WenZhaoYang123468的博客-CSDN博客

docker入门:CUDA环境

✔️主要看这个步骤就行,wsl环境里已经配好了cuda和驱动,再装一个cudnn就可以开始编译了

七、ubuntu20.04下opencv编译(GPU)+python+conda+ffmpeg_ubuntu 安装cv2-CSDN博客

查看gpu算力:

NVIDIA CUDA GPUs - Compute Capability

🚨加cudnn模块编译老是报错,索性去掉了。。

🤣跑程序发现pytorch不支持如此低的算力(3.5),可能要降到1.2版本才能用,但python版本也要随着降低,参考以下:

/home/rthete/venv/crack/lib/python3.8/site-packages/torch/cuda/__init__.py:125: UserWarning: 
NVIDIA GeForce GT 730 with CUDA capability sm_35 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70 sm_75.
If you want to use the NVIDIA GeForce GT 730 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/

RuntimeError: CUDA error: no kernel image is available for execution on the device

pytorch 报错 RuntimeError: CUDA error: no kernel image is available for execution on the device_可豌豆的博客-CSDN博客

PyTorch安装成功,但不能使用GPU功能:PyTorch no longer supports this GPU. CUDA error: no kernel image is available_found gpu%d %s which is of cuda capability %d.%d. _Atletico_zxs的博客-CSDN博客

Ubuntu-20.04+3090+cuda-12.0

由于之前的环境用不了pytorch换了3090的服务器来做

😴服务器上编译opencv报链接错误

/usr/bin/ld: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined reference to `ffi_type_uint32@LIBFFI_BASE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined reference to `ffi_type_sint32@LIBFFI_BASE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined reference to `ffi_type_pointer@LIBFFI_BASE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined reference to `ffi_type_void@LIBFFI_BASE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined reference to `ffi_prep_cif@LIBFFI_BASE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined reference to `ffi_call@LIBFFI_BASE_7.0'

【已解决】Ubuntu 20.04 编译OpenCV 动态链接库指向版本不一致导致出错-CSDN博客

(crack) zxy@ubuntu:~/opencv-gpu/opencv-4.7.0/build$ ldd /lib/x86_64-linux-gnu/libwayland-client.so.0 | grep ffi
        libffi.so.7 => /lib/x86_64-linux-gnu/libffi.so.7 (0x00007f56ee43d000)

zxy@ubuntu:~/opencv-gpu/opencv-4.7.0/build$ ll /home/zxy/anaconda3/lib/ | grep ffi
lrwxrwxrwx   1 zxy zxy        15 66 23:56 libffi.7.so -> libffi.so.8.1.0*
lrwxrwxrwx   1 zxy zxy        15 66 23:56 libffi.8.so -> libffi.so.8.1.0*
-rw-rw-r--   2 zxy zxy     96886 1122  2022 libffi.a
lrwxrwxrwx   1 zxy zxy        15 66 23:56 libffi.so -> libffi.so.8.1.0*
lrwxrwxrwx   1 zxy zxy        15 66 23:56 libffi.so.7 -> libffi.so.8.1.0*
lrwxrwxrwx   1 zxy zxy        15 66 23:56 libffi.so.8 -> libffi.so.8.1.0*
-rwxrwxr-x   2 zxy zxy     72152 1122  2022 libffi.so.8.1.0*

😇服务器编opencv网络问题下载超时

ubuntu编译opencv解决ade下载超时及cmake问题-CSDN博客

😢服务器编opencv与Anaconda链接冲突

CMake 编译出错 hidden by files-CSDN博客

😭服务器编opencv找不到python

--   Python 3:
--     Interpreter:                 /home/zxy/venv/crack_1/bin/python3 (ver 3.10.9)
--     Libraries:                   NO
--     numpy:                       /home/zxy/venv/crack_1/lib/python3.8/site-packages/numpy/core/include (ver 1.26.2)
--     install path:                -

记录ubuntu下编译openCV4 + cuda + python3 踩坑(C++11 python相关报错)_opencv 4.x+ requires enabled c++11 support-CSDN博客

cmake时少加了PYTHON3_INCLUDE_PATH

-D PYTHON_DEFAULT_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") \
-D PYTHON3_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") \
-D PYTHON3_NUMPY_INCLUDE_DIRS=$(python3 -c "import numpy; print (numpy.get_include())") \
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
# 加上这句之后就能找到了
-D PYTHON3_INCLUDE_PATH=/usr/include/python3.8
Python 3:
--     Interpreter:                 /home/zxy/venv/crack_1/bin/python3 (ver 3.10.9)
--     Libraries:                   /usr/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.so
--     numpy:                       /home/zxy/venv/crack_1/lib/python3.8/site-packages/numpy/core/include (ver 1.26.2)
--     install path:                /home/zxy/venv/crack_1/lib/python3.8/site-packages

😆终于编完了

在这里插入图片描述

验证也很完美

(crack_1) zxy@ubuntu:~/opencv-gpu/opencv-4.7.0/build$ python3
Python 3.8.10 (default, Nov 22 2023, 10:22:35) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.cuda.getCudaEnabledDeviceCount()
2
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值