Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
risemeup1 committed Aug 10, 2024
1 parent 268de62 commit 46f8049
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 49 deletions.
22 changes: 3 additions & 19 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,8 @@ jobs:
with:
submodules: true

- name: Build on manylinux2014_x86_64
uses: docker://paddlepaddle/paddle:paddle2onnx-python3.9-gcc82
- name: Build paddle2onnx and Run tests
uses: docker://paddlepaddle/paddle:latest-dev-cuda12.3-cudnn9.0-trt8.6-gcc12.2
with:
entrypoint: bash
args: .github/workflows/scripts/entrypoint.sh ${{ matrix.python-version }} manylinux2014_x86_64

- name: Setup Python 3.8
uses: actions/setup-python@v5
with:
python-version: '3.8'

# Install Paddle2ONNX
- name: Install Paddle2ONNX
run: |
python -m pip install dist/*.whl
# Install Test
- name: Run Test
working-directory: ./tests
run: |
bash run.sh python
args: .github/workflows/scripts/entrypoint.sh
12 changes: 12 additions & 0 deletions .github/workflows/scripts/build_and_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

#build protobuf
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init
git checkout v4.22.0
mkdir build_source && cd build_source
cmake ../cmake -DCMAKE_INSTALL_PREFIX=${PWD}/installed_protobuf_lib -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
make -j200
make install
export PATH=${PWD}/installed_protobuf_lib/bin:${PATH}
11 changes: 11 additions & 0 deletions .github/workflows/scripts/build_protobuf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git checkout v4.22.0
mkdir build_source && cd build_source
cmake ../cmake -DCMAKE_INSTALL_PREFIX=${PWD}/installed_protobuf_lib -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
make -j200
make install

# 将编译目录加入环境变量
export PATH=${PWD}/installed_protobuf_lib/bin:${PATH}
99 changes: 70 additions & 29 deletions .github/workflows/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@

set -e -x

# CLI arguments
PY_VERSION=$1
PLAT=$2
SYSTEM_NAME=$3

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
# Compile wheels
# Need to be updated if there is a new Python Version
# declare -A python_map=( ["3.8"]="cp38-cp38" ["3.9"]="cp39-cp39" ["3.10"]="cp310-cp310" ["3.11"]="cp311-cp311" ["3.12"]="cp312-cp312")
# PY_VER=${python_map[$PY_VERSION]}
# PIP_INSTALL_COMMAND="/opt/python/${PY_VER}/bin/pip install --no-cache-dir -q"
PYTHON_COMMAND="/usr/local/bin/python3.8"

# Update pip and install cmake
Expand All @@ -25,24 +14,76 @@ $PYTHON_COMMAND -m pip install cmake
$PYTHON_COMMAND -m pip install build
$PYTHON_COMMAND -m pip install --pre paddlepaddle -i https://www.paddlepaddle.org.cn/packages/nightly/cpu/
# Build protobuf from source
source .github/workflows/scripts/download_protobuf.sh
source .github/workflows/scripts/build_protobuf.sh

export PIP_EXTRA_INDEX_URL="https://www.paddlepaddle.org.cn/packages/nightly/cpu/"
# Build Paddle2ONNX wheels
$PYTHON_COMMAND -m build --wheel || { echo "Building wheels failed."; exit 1; }
# Bundle external shared libraries into the wheels
#find -exec does not preserve failed exit codes, so use an output file for failures
failed_wheels=$PWD/failed-wheels
rm -f "$failed_wheels"
find . -type f -iname "*-linux*.whl" -exec sh -c "auditwheel repair '{}' -w \$(dirname '{}') --plat '${PLAT}' || { echo 'Repairing wheels failed.'; auditwheel show '{}' >> '$failed_wheels'; }" \;

if [[ -f "$failed_wheels" ]]; then
echo "Repairing wheels failed:"
cat failed-wheels
exit 1
fi

# Remove useless *-linux*.whl; only keep manylinux*.whl
rm -f dist/*-linux*.whl

echo "Successfully build wheels:"
find . -type f -iname "*manylinux*.whl"

# Install Paddle2ONNX wheels
$PYTHON_COMMAND -m pip install dist/*.whl

#Run tests
cases=$(find . -name "test*.py" | sort)
ignore="test_auto_scan_multiclass_nms.py
test_auto_scan_roi_align.py \ # need to be rewrite
test_auto_scan_pool_adaptive_max_ops.py \
test_auto_scan_isx_ops.py \
test_auto_scan_masked_select.py \
test_auto_scan_pad2d.py \
test_auto_scan_roll.py \
test_auto_scan_set_value.py \
test_auto_scan_unfold.py \
test_auto_scan_uniform_random_batch_size_like.py \
test_auto_scan_uniform_random.py \
test_auto_scan_dist.py \
test_auto_scan_distribute_fpn_proposals1.py \
test_auto_scan_distribute_fpn_proposals_v2.py \
test_auto_scan_fill_constant_batch_size_like.py \
test_auto_scan_generate_proposals.py \
test_uniform.py \
test_ceil.py \
test_deform_conv2d.py \
test_floor_divide.py \
test_has_nan.py \
test_isfinite.py \
test_isinf.py \
test_isnan.py \
test_mask_select.py \
test_median.py \
test_nn_Conv3DTranspose.py \
test_nn_GroupNorm.py \
test_nn_InstanceNorm3D.py \
test_nn_Upsample.py \
test_normalize.py \
test_scatter_nd_add.py \
test_unsqueeze.py \
test_quantize_model.py \
test_quantize_model_minist.py \
test_quantize_model_speedup.py \
test_resnet_fp16.py"
bug=0

# Install Python Packet
$PYTHON_COMMAND-m pip install pytest
$PYTHON_COMMAND-m pip install onnx onnxruntime tqdm filelock
$PYTHON_COMMAND -m pip install six hypothesis

echo "============ failed cases =============" >> result.txt
for file in ${cases}
do
echo ${file}
if [[ ${ignore} =~ ${file##*/} ]]; then
echo "跳过"
else
$PYTHON_COMMAND -m pytest ${file}
if [ $? -ne 0 ]; then
echo ${file} >> result.txt
bug=`expr ${bug} + 1`
fi
fi
done

echo "total bugs: ${bug}" >> result.txt
cat result.txt
exit "${bug}"
2 changes: 1 addition & 1 deletion tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ ignore="test_auto_scan_multiclass_nms.py
bug=0

# Install Python Packet
export PY_CMD=$1
export PY_CMD=
$PY_CMD -m pip install pytest
$PY_CMD -m pip install onnx onnxruntime tqdm filelock
# $PY_CMD -m pip install paddlepaddle==2.6.0
Expand Down

0 comments on commit 46f8049

Please sign in to comment.