参考:https://zhuanlan.zhihu.com/p/584600231
https://baijiahao.baidu.com/s?id=1752902449981972686&wfr=spider&for=pc
开源地址:https://github.com/CVCUDA/CV-CUDA
NVIDIA 携手字节跳动机器学习团队开源众多图像预处理算子库CV-CUDA,它们能高效地运行在 GPU 上,算子速度能达到 OpenCV(运行在 CPU)的百倍左右。如果我们使用 CV-CUDA 作为后端替换OpenCV 和 TorchVision,整个推理的吞吐量能达到原来的二十多倍。此外,不仅是速度的提升,同时在效果上 CV-CUDA 在计算精度上已经对齐了OpenCV,因此训练推理能无缝衔接,大大降低工程师的工作量。
下载,编译
报错1,cmake版本不匹配,下载3.22版本,gcc版本不匹配,下载gcc11,升级完报cuda不匹配,升级nvidia驱动版本和cuda版本,nvidia515,cuda11.7
报错2,缺少依赖项,
CMake Error at 3rdparty/CMakeLists.txt:30 (add_subdirectory):
The source directory
CV-CUDA-release_v0.2.x/3rdparty/googletest
does not contain a CMakeLists.txt file.
参考:https://blog.csdn.net/qq_43140627/article/details/119766876
进入CV-CUDA-release_v0.2.x/3rdparty目录,执行:
git clone https://github.com/google/googletest.git
报错3,文件格式不对,
/usr/bin/ld:CV-CUDA-release_v0.2.x/src/util/stubs/libdl-2.17_stub.so: file format not recognized; treating as linker script
/usr/bin/ld:CV-CUDA-release_v0.2.x/src/util/stubs/libdl-2.17_stub.so:1: syntax error
collect2: error: ld returned 1 exit status
src/nvcv_types/CMakeFiles/nvcv_types.dir/build.make:312: recipe for target 'lib/libnvcv_types.so.0.2.0' failed
make[2]: *** [lib/libnvcv_types.so.0.2.0] Error 1
CMakeFiles/Makefile2:743: recipe for target 'src/nvcv_types/CMakeFiles/nvcv_types.dir/all' failed
make[1]: *** [src/nvcv_types/CMakeFiles/nvcv_types.dir/all] Error 2
Makefile:155: recipe for target 'all' failed
make: *** [all] Error 2
参考:https://blog.csdn.net/qq_39093373/article/details/118220195
是原始文件有问题,去小目录重新下载再替换即可。
https://github.com/CVCUDA/CV-CUDA/issues/6
测试了,可用,不过得在https://github.com/CVCUDA/CV-CUDA/tree/release_v0.2.x/src/util/stubs网页端下直接点Download下载,而不能下载全部源码后才在src/util/stubs拿。
报错4,缺少依赖项,
CMake Error at CMakeLists.txt:29 (add_subdirectory):
The source directory
CV-CUDA-release_v0.2.x/3rdparty/pybind11
does not contain a CMakeLists.txt file.
解决:
git clone https://github.com/pybind/pybind11.git
编译
ci/build.sh
(编译build_doc.sh和build_sample.sh报错,暂时跳过)
编译build.sh成功之后修改~/.bashrc文件,参考:
https://github.com/CVCUDA/CV-CUDA/issues/11
然后在base环境运行:
import cvcuda
import nvcv
可以正常导入。
但是在anaconda的env环境导入不成功。需要在env环境重新编译。编译完成后继续在~/.bashrc文件中添加生成的python路径,即可正常导入。
测试文章来源:https://www.toymoban.com/news/detail-450611.html
CV-CUDA-release_v0.2.x$ python tests/cvcuda/python/test_opchannelreorder.py
测试脚本都可以正常运行。
运行测试demo
CV-CUDA-release_v0.2.x/samples/classification/python/inference.py
安装torchnvjpeg库。
https://github.com/itsliupeng/torchnvjpeg
报错:Line 679: ‘’ failed: no kernel image is available for execution on the device
报错同https://github.com/CVCUDA/CV-CUDA/issues/14,暂未看到解决办法,先搁置。文章来源地址https://www.toymoban.com/news/detail-450611.html
到了这里,关于CV-CUDA使用gpu读取并处理图片的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!