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博客
✔️主要看这个步骤就行,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
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 6月 6 23:56 libffi.7.so -> libffi.so.8.1.0*
lrwxrwxrwx 1 zxy zxy 15 6月 6 23:56 libffi.8.so -> libffi.so.8.1.0*
-rw-rw-r-- 2 zxy zxy 96886 11月 22 2022 libffi.a
lrwxrwxrwx 1 zxy zxy 15 6月 6 23:56 libffi.so -> libffi.so.8.1.0*
lrwxrwxrwx 1 zxy zxy 15 6月 6 23:56 libffi.so.7 -> libffi.so.8.1.0*
lrwxrwxrwx 1 zxy zxy 15 6月 6 23:56 libffi.so.8 -> libffi.so.8.1.0*
-rwxrwxr-x 2 zxy zxy 72152 11月 22 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: -
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