forked from zhiqwang/yolort
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (100 loc) · 3.86 KB
/
ci_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Copyright (c) 2020, Zhiqiang Wang. All Rights Reserved.
# GH actions
name: CI testing
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
UnitTest:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.7]
os: [ubuntu-latest]
torch: [1.7.1+cpu, 1.8.1+cpu] # nightly
include:
- torch: 1.7.1+cpu
pip_address: torch==1.7.1+cpu torchvision==0.8.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
unittest_type: --cov=test --cov-report=xml
- torch: 1.8.1+cpu
pip_address: torch==1.8.1+cpu torchvision==0.9.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
unittest_type: --cov=test --cov-report=xml
# - torch: nightly
# pip_address: --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
# unittest_type: test
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
- name: Install PyTorch ${{ matrix.torch }} Version
run: |
python -m pip install --upgrade pip
# requirements for PyTorch and torchvision
pip install numpy pillow scipy
pip install ${{ matrix.pip_address }}
- name: Install dependencies
run: |
# requirements for unittest
pip install flake8 pytest
pip install pytest-cov
# Install other dependencies
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install opencv-python
pip install pycocotools>=2.0.2
pip install onnxruntime
# requirements for ultralytics/yolov5
pip install pandas seaborn thop
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=18 --max-line-length=120 --statistics
- name: Test and Generate coverage report
run: |
PYTORCH_TEST_WITH_SLOW=1 pytest ${{ matrix.unittest_type }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
if: matrix.torch == '1.8.1+cpu'
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
- name: Build TorchVision Cpp ${{ matrix.torch }}
if: matrix.torch == '1.8.1+cpu'
run: |
export TORCH_PATH=$(dirname $(python -c "import torch; print(torch.__file__)"))
cd ..
git clone https://github.com/pytorch/vision.git vision
cd vision
git checkout release/0.9
mkdir build && cd build
cmake .. -DTorch_DIR=$TORCH_PATH/share/cmake/Torch
make -j4
sudo make install
- name: Export torchscript model
if: matrix.torch == '1.8.1+cpu'
run: |
python -m test.tracing.trace_model
- name: Test libtorch tracing
if: matrix.torch == '1.8.1+cpu'
run: |
export TORCH_PATH=$(dirname $(python -c "import torch; print(torch.__file__)"))
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TORCH_PATH/lib/
cd test/tracing
mkdir build && cd build
cmake .. -DTorch_DIR=$TORCH_PATH/share/cmake/Torch
make
mv ../yolov5s.torchscript.pt ./
echo ">> Test libtorch tracing"
./test_tracing