Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

源码编译make遇到的问题 #57

Open
xufabs opened this issue Jun 28, 2024 · 11 comments
Open

源码编译make遇到的问题 #57

xufabs opened this issue Jun 28, 2024 · 11 comments

Comments

@xufabs
Copy link

xufabs commented Jun 28, 2024

请问make的时候出现以下错误是什么问题呢?我想用它进行ONNXRUNTIME C++(CPU) 推理视频和图片

系统是Ubuntu24

onnxruntime是1.17的
opencv是4.5.3
在conda虚拟环境下编译的
g++是13.2.0

图片

/usr/bin/ld: CMakeFiles/YOLOv8.dir/main.cpp.o: in function int yolov8_onnx<Yolov8PoseOnnx>(Yolov8PoseOnnx&, cv::Mat&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': main.cpp:(.text._Z11yolov8_onnxI14Yolov8PoseOnnxEiRT_RN2cv3MatERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_Z11yolov8_onnxI14Yolov8PoseOnnxEiRT_RN2cv3MatERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x56): undefined reference to Yolov8PoseOnnx::ReadModel(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, bool, int, bool)'
/usr/bin/ld: main.cpp:(.text._Z11yolov8_onnxI14Yolov8PoseOnnxEiRT_RN2cv3MatERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_Z11yolov8_onnxI14Yolov8PoseOnnxEiRT_RN2cv3MatERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x1f1): undefined reference to Yolov8PoseOnnx::OnnxDetect(cv::Mat&, std::vector<OutputParams, std::allocator<OutputParams> >&)' /usr/bin/ld: CMakeFiles/YOLOv8.dir/main.cpp.o: in function int video_demo(Yolov8PoseOnnx&, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&)':
main.cpp:(.text._Z10video_demoI14Yolov8PoseOnnxEiRT_RNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_Z10video_demoI14Yolov8PoseOnnxEiRT_RNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x204): undefined reference to Yolov8PoseOnnx::ReadModel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, int, bool)' /usr/bin/ld: main.cpp:(.text._Z10video_demoI14Yolov8PoseOnnxEiRT_RNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_Z10video_demoI14Yolov8PoseOnnxEiRT_RNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x31d): undefined reference to Yolov8PoseOnnx::OnnxDetect(cv::Mat&, std::vector<OutputParams, std::allocator >&)'
/usr/bin/ld: CMakeFiles/YOLOv8.dir/yolov8.cpp.o: in function Yolov8::ReadModel(cv::dnn::dnn4_v20210608::Net&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, bool)': yolov8.cpp:(.text+0x4a): undefined reference to CheckModelPath(std::__cxx11::basic_string<char, std::char_traits, std::allocator >)'
/usr/bin/ld: CMakeFiles/YOLOv8.dir/yolov8_onnx.cpp.o: in function Yolov8Onnx::ReadModel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, int, bool)': yolov8_onnx.cpp:(.text+0x88): undefined reference to CheckModelPath(std::__cxx11::basic_string<char, std::char_traits, std::allocator >)'
/usr/bin/ld: yolov8_onnx.cpp:(.text+0x22e): undefined reference to OrtSessionOptionsAppendExecutionProvider_CUDA' /usr/bin/ld: CMakeFiles/YOLOv8.dir/yolov8_seg.cpp.o: in function Yolov8Seg::ReadModel(cv::dnn::dnn4_v20210608::Net&, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&, bool)':
yolov8_seg.cpp:(.text+0x4a): undefined reference to CheckModelPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' /usr/bin/ld: CMakeFiles/YOLOv8.dir/yolov8_seg_onnx.cpp.o: in function Yolov8SegOnnx::ReadModel(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, bool, int, bool)':
yolov8_seg_onnx.cpp:(.text+0x88): undefined reference to CheckModelPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' /usr/bin/ld: yolov8_seg_onnx.cpp:(.text+0x230): undefined reference to OrtSessionOptionsAppendExecutionProvider_CUDA'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/YOLOv8.dir/build.make:234:YOLOv8] 错误 1
make[1]: *** [CMakeFiles/Makefile2:83:CMakeFiles/YOLOv8.dir/all] 错误 2
make: *** [Makefile:91:all] 错误 2

cmakelist如下

图片

@UNeedCryDear
Copy link
Owner

UNeedCryDear commented Jun 28, 2024

CheckModelPath()

bool CheckModelPath(std::string modelPath) {
这里面用到部分windows的函数(__access),linux下面没有,这个主要是检测模型路径对不对的,linux下面你可以换掉或者保证下模型路径正确的话可以不要

@xufabs
Copy link
Author

xufabs commented Jun 28, 2024

图片
这段我已经注释掉了,还是有上面的问题,是不是其他地方引用了这段函数,需要一并注释掉?

@xufabs
Copy link
Author

xufabs commented Jun 28, 2024

前面的编译我把函数里引用的都注释掉,编译通过了,
但是我把这段解开注释编译又有问题了orz

图片
图片

@UNeedCryDear
Copy link
Owner

如果你不要pose的话,把pose相关的头文件什么的都去掉,包括头文件include之类的,仅仅保留你需要的东西即可(cmake文件也把相关的去掉)

@xufabs
Copy link
Author

xufabs commented Jun 28, 2024

好的,谢谢作者,我在cmakelist里增加上onnxpose.cpp文件就生成了YOLOV8文件了

@xufabs
Copy link
Author

xufabs commented Jun 28, 2024

还有一个问题,如果要推理一段视频,需要将视频文件放在哪里呢?我看video demo 里没有传入视频路径?

@xufabs
Copy link
Author

xufabs commented Jun 29, 2024

我发现那些类里onnx—detect的类是yolov8Poseonnx,无法识别我yolov8n.onnx的文件
图片

所以改用yolov8Onnx这个类,但是推理的效果不太理想,请问是有什么问题?
图片
图片

@xufabs
Copy link
Author

xufabs commented Jun 29, 2024

图片

图片
补充一下,这是我用YOLOV8n POSE.onnx推理的效果
ONNX 1.14
onnxruntime C++ 1.15/1.17我都试过了,没有改善

@xufabs
Copy link
Author

xufabs commented Jul 1, 2024

图片

图片 补充一下,这是我用YOLOV8n POSE.onnx推理的效果 ONNX 1.14 onnxruntime C++ 1.15/1.17我都试过了,没有改善

破案了,我重装了一下yolov8本体的环境就OK了,多谢作者!
之前图方便就conda克隆了yolov10的环境,然后转了onnx模型就出问题了

@zhibin-hong
Copy link

好的,谢谢作者,我在cmakelist里增加上onnxpose.cpp文件就生成了YOLOV8文件了

你好,请问在哪添加呢,我没有看到这个文件呀

@xufabs
Copy link
Author

xufabs commented Jul 4, 2024

好的,谢谢作者,我在cmakelist里增加上onnxpose.cpp文件就生成了YOLOV8文件了

你好,请问在哪添加呢,我没有看到这个文件呀

在cmakelist文件里,那里有一行写了各种cpp和.h文件的,你把漏编译的cpp和.h 文件放进去就好了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants