pip install opencv-python-headlesspip install imgcat on remote server https://pypi.org/project/imgcat/imshow, install regular opencv-python, set '/etc/ssh/sshd_config' to 'X11Forwarding yes', and connect with 'ssh -X', some authorization and dependencies may need.https://wiki.aleen42.com/qa/opencvonlinux.html
https://www.marearts.com/0-OpenCV-Build-Ubuntu-20-04-OpenCV-4-5-2-CUDA-11-2-4c876d664e84442e82ebec13c23586b3
pre
# check nvidia version and ubuntu version
nvidia-smi
nvcc --version
lsb_release -a
# download source code and create new dir
mkdir opencv_with_cuda && cd opencv_with_cuda
wget -O opencv.zip <https://github.com/opencv/opencv/archive/master.zip>
wget -O opencv_contrib.zip <https://github.com/opencv/opencv_contrib/archive/master.zip>
unzip opencv.zip
unzip opencv_contrib.zip
rm opencv.zip
rm opencv_contrib.zip
mkdir build && cd build
# python env
conda activate python3.8
pip show numpy
pip install --upgrade numpy
https://www.youtube.com/watch?v=HsuKxjQhFU0&t=515s
https://docs.opencv.org/master/db/d05/tutorial_config_reference.html
install NVIDIA CUDA, OpenCV code, CMake as for C++
install Anaconda and set PATH correctly
download OpenCV code,(opencv, opencv_contrib)
CMake Configure:
select the OpenCV source code and target build path, click Configure select os platform, start to build
.cmake 文件里的地址为file:///...。或者把raw.githubusersourcecontent 改为镜像地址,参考:https://www.codenong.com/cs107007432/upgrade NumPy version to newest
check all python paths including the NumPy path,configure again

uncheck OPENCV_GENERATE_SETUPVARS
check these:
OPENCV_EXTRA_MODULES_PATH = path/to/opencv_contrib/modules
configure again
check CUDA_FAST_MATH
choose arch version ( https://en.wikipedia.org/wiki/CUDA, torch.cuda.get_arch_list()), and release config, click ‘Configure’ again
click ‘Generate'
install in prompt
cmake --build "D:\mnvai-alg\cv2_with_gpu\build_win_py" --target INSTALL --config Release
Verify:
import cv2
from cv2 import cuda
cuda.printCudaDeviceInfo(0)