PaddlePaddle / Paddle

PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)
http://www.paddlepaddle.org/
Apache License 2.0
22.16k stars 5.57k forks source link

Build for mac os on m1 #49076

Closed grinay closed 1 year ago

grinay commented 1 year ago

问题描述 Issue Description

Hello, let me describe the issue I faces. I'm trying to build "paddle inference c" library, we are using it in our OCR solution based on dotnet core. We are using OpenCvSharp4 and custom wrapper for paddle inference c library. There are no problem to use it on windows and linux. I'm trying to make it work on osx with m1 processors. I'm using building flags:

cmake ..  -DWITH_CONTRIB=OFF -DWITH_MKL=OFF -DWITH_MKLDNN=OFF -DWITH_TESTING=OFF -DWITH_SYSTEM_BLAS=ON -DCMAKE_BUILD_TYPE=Release -DWITH_INFERENCE_API_TEST=OFF -DON_INFER=ON -DWITH_PYTHON=OFF -DWITH_GPU=OFF -DWITH_AVX=OFF -DAPPLE=ON -DWITH_ARM=ON
make TARGET=ARMV8 -j4

as a result I have libpaddle_inference_c.dylib But when I trying to use it in a project it throws the error:

ERROR: flag 'flagfile' was defined more than once (in files '/Users/grinay/paddleinference/Paddle/build/third_party/gflags/src/extern_gflags/src/gflags.cc' and '/tmp/gflags-20211021-3963-1mi18ai/gflags-2.2.2/src/gflags.cc').

I think the problem is that OpenCv4.6 uses gflags as well, When you install it with brew install opencv@4 it installs gflags 2.2 as well.

When you build paddle I see it checkout git repository of gflags and build its own version. May you advice how to overcome this issue and make that work ?

版本&环境信息 Version & Environment Information

Macos 12.4 Monterey Python 3.10.8 No GPU CPU m1 Paddle last develop branch

paddle-bot[bot] commented 1 year ago

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档常见问题历史IssueAI社区来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

RichardWooSJTU commented 1 year ago

I think the problem is that OpenCv4.6 uses gflags as well

You can try to uninstall opencv and glog, and then reinstall opencv from the source code

grinay commented 1 year ago

I’ve tried that already, didn’t help. May be there is a way to link existing gflags setup into the building process?

grinay commented 1 year ago

@RichardWooSJTU any advice?

grinay commented 1 year ago

Modified cmake files to reference existing gflags installation. Solved.

wbudd commented 1 year ago

@grinay May I ask you to share the details of how you modified those CMake files? 🙏

I'm trying to reproduce the way you built for M1 (also using the same CMake flags as you), but I'm running into issues including gfortran not being found and other annoyances.

May-Yaha commented 1 year ago

@grinay May I ask you to share the details of how you modified those CMake files? 🙏

I'm trying to reproduce the way you built for M1 (also using the same CMake flags as you), but I'm running into issues including gfortran not being found and other annoyances.

https://github.com/PaddlePaddle/Paddle/pull/50787

ltto commented 1 year ago

@grinay Can you share your. whl

grinay commented 1 year ago

@ltto @May-Yaha @wbudd sorry for long answer, please check diff file, branch is develop at head of d4f43ad4ced51f9eb4979172d6a4be80090ac530 diff_output.txt