PaddlePaddle / Paddle

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

Paddle xpu产物编译Paddle-Inference-Demo出现错误 #66180

Closed cmcamdy closed 4 months ago

cmcamdy commented 4 months ago

问题描述 Issue Description

在xpu上使用Paddle编译出来的inference的包编译Paddle-Inference-Demo推理文件的时候出现如下错误:

1. check paddle_inference exists
2. check CMakeLists exists
3. compile
4. cmake
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- The CXX compiler identification is GNU 8.4.0
-- The C compiler identification is GNU 8.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
messageOFF
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /Work/problem/xpu_l3/Paddle-Inference-Demo/c++/xpu/resnet50/build
[ 50%] Building CXX object CMakeFiles/resnet50_test.dir/resnet50_test.cc.o
[100%] Linking CXX executable resnet50_test
/usr/bin/ld: /Work/problem/xpu_l3/Paddle-Inference-Demo/c++/xpu/resnet50/../../lib/paddle_inference/paddle/lib/libpaddle_inference.so: undefined reference to `deflate'
/usr/bin/ld: /Work/problem/xpu_l3/Paddle-Inference-Demo/c++/xpu/resnet50/../../lib/paddle_inference/paddle/lib/libpaddle_inference.so: undefined reference to `deflateEnd'
/usr/bin/ld: /Work/problem/xpu_l3/Paddle-Inference-Demo/c++/xpu/resnet50/../../lib/paddle_inference/paddle/lib/libpaddle_inference.so: undefined reference to `inflateInit2_'
/usr/bin/ld: /Work/problem/xpu_l3/Paddle-Inference-Demo/c++/xpu/resnet50/../../lib/paddle_inference/paddle/lib/libpaddle_inference.so: undefined reference to `deflateInit2_'
/usr/bin/ld: /Work/problem/xpu_l3/Paddle-Inference-Demo/c++/xpu/resnet50/../../lib/paddle_inference/paddle/lib/libpaddle_inference.so: undefined reference to `inflateEnd'
/usr/bin/ld: /Work/problem/xpu_l3/Paddle-Inference-Demo/c++/xpu/resnet50/../../lib/paddle_inference/paddle/lib/libpaddle_inference.so: undefined reference to `inflate'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/resnet50_test.dir/build.make:105: resnet50_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/resnet50_test.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

版本&环境信息 Version & Environment Information

编译的Paddle是develop版本的xpu,环境信息如下:

XCCL /usr/local/lib/python3.10/dist-packages/paddle/base/../libs/libbkcl.so loaded
XPURT /usr/local/lib/python3.10/dist-packages/paddle/base/../libs/libxpurt.so.1 loaded
****************************************
Paddle version: 0.0.0
Paddle With CUDA: False

OS: ubuntu 20.04
GCC version: (Ubuntu 8.4.0-3ubuntu2) 8.4.0
Clang version: N/A
CMake version: version 3.27.7
Libc version: glibc 2.31
Python version: 3.10.13

CUDA version: N/A
cuDNN version: N/A
Nvidia driver version: N/A
Nvidia driver List: N/A
****************************************
No XPU Memory Leak

Paddle本体编译脚本如下:

git submodule sync --recursive && git submodule update --init --recursive

# 这个是从xpu ci中抠出来的,只修改过cmake地址:/opt/cmake-3.27.7/bin/cmake
cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_GPU=OFF -DWITH_SHARED_PHI=ON -DWITH_TENSORRT=ON -DWITH_ROCM=OFF -DWITH_CINN=OFF -DWITH_DISTRIBUTE=ON -DWITH_MKL=ON -DWITH_AVX=OFF -DCUDA_ARCH_NAME=All -DNEW_RELEASE_PYPI=OFF -DNEW_RELEASE_ALL=OFF -DNEW_RELEASE_JIT=OFF -DWITH_PYTHON=ON -DCUDNN_ROOT=/usr/ -DWITH_TESTING=ON -DWITH_COVERAGE=OFF -DWITH_INCREMENTAL_COVERAGE=OFF -DCMAKE_MODULE_PATH=/opt/cmake-3.27.7/bin/cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWITH_INFERENCE_API_TEST=ON -DINFERENCE_DEMO_INSTALL_DIR=/root/.cache/inference_demo -DPY_VERSION=3.10 -DCMAKE_INSTALL_PREFIX=/paddle/build -DWITH_PSCORE=ON -DWITH_PSLIB=OFF -DWITH_GLOO=ON -DWITH_XPU=ON -DWITH_IPU=OFF -DXPU_SDK_ROOT= -DWITH_XPU_BKCL=ON -DWITH_XPU_XRE5=ON -DWITH_ARM=OFF -DWITH_STRIP=ON -DON_INFER=ON -DWITH_HETERPS=OFF -DCUDA_ARCH_BIN= -DWITH_RECORD_BUILDTIME=OFF -DWITH_UNITY_BUILD=OFF -DWITH_ONNXRUNTIME=OFF -DWITH_CUDNN_FRONTEND=OFF -DWITH_CPP_TEST=ON

make -j$(nproc)

然后使用编译产物:build/paddle_inference_install_dir在paddle-inference-demo中进行二次编译,如:

rm -rf /path/to/Paddle-Inference-Demo/c++/lib/paddle_inference
cp -r /path/to/Paddle/build/paddle_inference_install_dir  /path/to/Paddle-Inference-Demo/c++/lib/paddle_inference
cd /path/to/Paddle-Inference-Demo/c++/xpu/resnet50 
./compile.sh
hong19860320 commented 4 months ago

看起来是 libpaddle_inference.so 依赖 zlib 库的符号,但没有找到,尝试在 cmake 里显示加上 -lz ?参考 https://stackoverflow.com/questions/22337896/how-to-fix-undefined-references-to-inflate-deflate-functions