File size: 6,064 Bytes
d7e58f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
version: 2.1
jobs:
  lint:
    docker:
      - image: cimg/python:3.7.4
    steps:
      - checkout
      - run:
          name: Install pre-commit hook
          command: |
            pip install pre-commit
            pre-commit install
      - run:
          name: Linting
          command: pre-commit run --all-files

  build_cpu:
    parameters:
      # The python version must match available image tags in
      # https://circleci.com/developer/images/image/cimg/python
      python:
        type: string
        default: "3.7.0"
      torch:
        type: string
      torchvision:
        type: string
    machine:
      image: ubuntu-2004:202010-01
    resource_class: large
    steps:
      - checkout
      - run:
          name: Install system dependencies
          command: |
            sudo apt-get update
            sudo apt-get install -y ffmpeg libturbojpeg ninja-build
            ffmpeg -version
      - run:
          # https://github.com/pytorch/vision/issues/2921
          name: Install dependency of torchvision when using pyenv
          command: sudo apt-get install -y liblzma-dev
      - run:
          # python3.7 should be re-installed due to the issue https://github.com/pytorch/vision/issues/2921
          name: Select Python
          command: |
            pyenv uninstall -f << parameters.python >>
            pyenv install << parameters.python >>
            pyenv global << parameters.python >>
      - run:
          name: Upgrade pip
          command: |
            python -m pip install pip --upgrade
      - run:
          name: Install PyTorch
          command: python -m pip install torch==<< parameters.torch >>+cpu torchvision==<< parameters.torchvision >>+cpu -f https://download.pytorch.org/whl/torch_stable.html
      - run:
          name: Install psutil
          command: python -m pip install psutil
      - run:
          name: Build and install
          command: |
            rm -rf .eggs
            python setup.py check -m -s
            python -m pip install -e .
          no_output_timeout: 20m
          environment:
            MMCV_WITH_OPS: 1
      - run:
          name: Install dependencies of unit test
          command: |
            python -m pip install -r requirements/test.txt
      - run:
          name: Run unittests and generate coverage report
          command: |
            python -m coverage run --branch --source mmcv -m pytest tests/
            python -m coverage xml
            python -m coverage report -m

  build_cu102:
    machine:
      image: ubuntu-1604-cuda-10.1:201909-23  # the actual version of cuda is 10.2
    resource_class: gpu.nvidia.small
    steps:
      - checkout
      - run:
          name: Set CUDA environment
          command: |
            echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> $BASH_ENV
            echo 'export PATH=/usr/local/cuda/bin:$PATH' >> $BASH_ENV
            echo 'export CUDA_HOME=/usr/local/cuda' >> $BASH_ENV
            source $BASH_ENV
            nvidia-smi
            nvcc --version
            gcc --version
      - run:
          name: Install system dependencies
          command: |
            sudo apt-get update
            sudo apt-get install -y libturbojpeg ninja-build
            # the default version of ffmpeg is 2.8.7, which should be upgraded to 4+
            sudo add-apt-repository -y ppa:jonathonf/ffmpeg-4
            sudo apt-get update
            sudo apt-get install -y ffmpeg
            ffmpeg -version
            sudo add-apt-repository --remove ppa:jonathonf/ffmpeg-4 -y
      - run:
          # https://github.com/pytorch/vision/issues/2921
          name: Install dependency of torchvision when using pyenv
          command: sudo apt-get install -y liblzma-dev
      - run:
          # python3.7 should be re-installed due to the issue https://github.com/pytorch/vision/issues/2921
          name: Select python3.7
          command: |
            pyenv uninstall -f 3.7.0
            pyenv install 3.7.0
            pyenv global 3.7.0
      - run:
          name: Upgrade pip
          command: |
            python -m pip install pip --upgrade
      - run:
          name: Install PyTorch
          command: python -m pip install torch==1.8.1+cu102 torchvision==0.9.1+cu102 -f https://download.pytorch.org/whl/torch_stable.html
      - run:
          name: Install psutil
          command: python -m pip install psutil
      - run:
          name: Download onnxruntime library and install onnxruntime
          command: |
            wget https://github.com/microsoft/onnxruntime/releases/download/v1.8.1/onnxruntime-linux-x64-1.8.1.tgz
            tar -zxvf onnxruntime-linux-x64-1.8.1.tgz
            echo 'export ONNXRUNTIME_DIR=$(pwd)/onnxruntime-linux-x64-1.8.1' >> $BASH_ENV
            echo 'export LD_LIBRARY_PATH=$ONNXRUNTIME_DIR/lib:$LD_LIBRARY_PATH' >> $BASH_ENV
            source $BASH_ENV
            python -m pip install onnxruntime==1.8.1
      - run:
          name: Build and install
          command: |
            rm -rf .eggs
            python setup.py check -m -s
            python -m pip install -e .
          environment:
            MMCV_WITH_OPS: 1
            MMCV_WITH_ORT: 1
      - run:
          name: Install dependencies for unit test
          command: |
            python -m pip install -r requirements/test.txt
      - run:
          name: Run unittests and generate coverage report
          command: |
            python -m coverage run --branch --source mmcv -m pytest tests/
            python -m coverage xml
            python -m coverage report -m
workflows:
  unit_tests:
    jobs:
      - lint
      - build_cpu:
          name: build_py3.8_pt1.9_cpu
          torch: 1.9.0
          torchvision: 0.10.0
          python: "3.8.0"
          requires:
            - lint
      - hold:
          type: approval # <<< This key-value pair will set your workflow to a status of "On Hold"
          requires:
            - build_py3.8_pt1.9_cpu
      - build_cu102:
          requires:
            - hold