config.yml 12.6 KB
Newer Older
1
2
3
4
version: 2.1

# How to test the Linux jobs:
#   - Install CircleCI local CLI: https://circleci.com/docs/2.0/local-cli/
Philip Meier's avatar
Philip Meier committed
5
6
#   - circleci config process .circleci/config.yml > gen.yml && circleci local execute -c gen.yml --job binary_win_wheel_py3.8
#     - Replace binary_win_wheel_py3.8 with the name of the job you want to test.
Edward Z. Yang's avatar
Edward Z. Yang committed
7
#       Job names are 'name:' key.
8

9
executors:
10
  windows-cpu:
11
    machine:
12
13
14
15
16
17
18
19
      resource_class: windows.xlarge
      image: windows-server-2019-vs2019:stable
      shell: bash.exe

  windows-gpu:
    machine:
      resource_class: windows.gpu.nvidia.medium
      image: windows-server-2019-nvidia:stable
20
21
      shell: bash.exe

22
23
24
25
26
commands:
  checkout_merge:
    description: "checkout merge branch"
    steps:
      - checkout
27
28
29
30
31
#     - run:
#         name: Checkout merge branch
#         command: |
#           set -ex
#           BRANCH=$(git rev-parse --abbrev-ref HEAD)
32
#           if [[ "$BRANCH" != "main" ]]; then
33
34
35
#             git fetch --force origin ${CIRCLE_BRANCH}/merge:merged/${CIRCLE_BRANCH}
#             git checkout "merged/$CIRCLE_BRANCH"
#           fi
36
37
38
39
40
41
42
43
44
45
46
47
  designate_upload_channel:
    description: "inserts the correct upload channel into ${BASH_ENV}"
    steps:
      - run:
          name: adding UPLOAD_CHANNEL to BASH_ENV
          command: |
            our_upload_channel=nightly
            # On tags upload to test instead
            if [[ -n "${CIRCLE_TAG}" ]]; then
              our_upload_channel=test
            fi
            echo "export UPLOAD_CHANNEL=${our_upload_channel}" >> ${BASH_ENV}
48

Philip Meier's avatar
Philip Meier committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  pip_install:
    parameters:
      args:
        type: string
      descr:
        type: string
        default: ""
      user:
        type: boolean
        default: true
    steps:
      - run:
          name: >
            <<^ parameters.descr >> pip install << parameters.args >> <</ parameters.descr >>
            <<# parameters.descr >> << parameters.descr >>            <</ parameters.descr >>
          command: >
            pip install
            <<# parameters.user >> --user <</ parameters.user >>
            --progress-bar=off
            << parameters.args >>

70
71
binary_common: &binary_common
  parameters:
72
    # Edit these defaults to do a release
73
74
75
76
77
    build_version:
      description: "version number of release binary; by default, build a nightly"
      type: string
      default: ""
    pytorch_version:
78
      description: "PyTorch version to build against; by default, use a nightly"
79
      type: string
80
      default: ""
81
82
    # Don't edit these
    python_version:
83
      description: "Python version to build against (e.g., 3.8)"
84
      type: string
Edward Z. Yang's avatar
Edward Z. Yang committed
85
86
    cu_version:
      description: "CUDA version to build against, in CU format (e.g., cpu or cu100)"
87
      type: string
guyang3532's avatar
guyang3532 committed
88
      default: "cpu"
89
90
91
92
    unicode_abi:
      description: "Python 2.7 wheel only: whether or not we are cp27mu (default: no)"
      type: string
      default: ""
Edward Z. Yang's avatar
Edward Z. Yang committed
93
94
95
    wheel_docker_image:
      description: "Wheel only: what docker image to use"
      type: string
96
      default: ""
97
98
99
100
    conda_docker_image:
      description: "Conda only: what docker image to use"
      type: string
      default: "pytorch/conda-builder:cpu"
101
102
103
104
  environment:
    PYTHON_VERSION: << parameters.python_version >>
    PYTORCH_VERSION: << parameters.pytorch_version >>
    UNICODE_ABI: << parameters.unicode_abi >>
Edward Z. Yang's avatar
Edward Z. Yang committed
105
    CU_VERSION: << parameters.cu_version >>
106
    MACOSX_DEPLOYMENT_TARGET: 10.9
107

guyang3532's avatar
guyang3532 committed
108
109
110
111
112
smoke_test_common: &smoke_test_common
  <<: *binary_common
  docker:
    - image: torchvision/smoke_test:latest

113
jobs:
114
115
  circleci_consistency:
    docker:
116
      - image: cimg/python:3.8
117
118
    steps:
      - checkout
Philip Meier's avatar
Philip Meier committed
119
120
      - pip_install:
          args: jinja2 pyyaml
121
      - run:
Philip Meier's avatar
Philip Meier committed
122
          name: Check CircleCI config consistency
123
124
125
126
          command: |
            python .circleci/regenerate.py
            git diff --exit-code || (echo ".circleci/config.yml not in sync with config.yml.in! Run .circleci/regenerate.py to update config"; exit 1)

Francisco Massa's avatar
Francisco Massa committed
127
  binary_win_conda:
128
129
    <<: *binary_common
    executor: windows-cpu
130
131
    steps:
      - checkout_merge
132
      - designate_upload_channel
133
134
      - run:
          name: Build conda packages
135
          no_output_timeout: 30m
136
          command: |
137
138
139
140
141
142
143
            set -ex
            source packaging/windows/internal/vc_install_helper.sh
            packaging/windows/internal/cuda_install.bat
            eval "$('/C/tools/miniconda3/Scripts/conda.exe' 'shell.bash' 'hook')"
            conda activate base
            conda install -yq conda-build "conda-package-handling!=1.5.0"
            packaging/build_conda.sh
144
            rm /C/tools/miniconda3/conda-bld/win-64/vs${VC_YEAR}*.tar.bz2
145
      - store_artifacts:
146
          path: C:/tools/miniconda3/conda-bld/win-64
147
      - persist_to_workspace:
148
          root: C:/tools/miniconda3/conda-bld/win-64
149
150
151
152
153
          paths:
            - "*"
      - store_test_results:
          path: build_results/

154
  binary_win_wheel:
155
156
    <<: *binary_common
    executor: windows-cpu
157
158
    steps:
      - checkout_merge
159
      - designate_upload_channel
160
161
      - run:
          name: Build wheel packages
162
          no_output_timeout: 30m
163
          command: |
164
165
166
167
            set -ex
            source packaging/windows/internal/vc_install_helper.sh
            packaging/windows/internal/cuda_install.bat
            packaging/build_wheel.sh
168
      - store_artifacts:
169
          path: dist
170
      - persist_to_workspace:
171
          root: dist
172
173
174
175
176
          paths:
            - "*"
      - store_test_results:
          path: build_results/

177
178
179
  binary_macos_wheel:
    <<: *binary_common
    macos:
180
      xcode: "14.0"
181
    steps:
182
      - checkout_merge
183
      - designate_upload_channel
184
185
186
187
188
189
190
191
192
193
194
      - run:
          # Cannot easily deduplicate this as source'ing activate
          # will set environment variables which we need to propagate
          # to build_wheel.sh
          command: |
            curl -o conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
            sh conda.sh -b
            source $HOME/miniconda3/bin/activate
            packaging/build_wheel.sh
      - store_artifacts:
          path: dist
Edward Z. Yang's avatar
Edward Z. Yang committed
195
196
197
198
      - persist_to_workspace:
          root: dist
          paths:
            - "*"
199
200
201
202

  binary_macos_conda:
    <<: *binary_common
    macos:
203
      xcode: "14.0"
204
    steps:
205
      - checkout_merge
206
      - designate_upload_channel
207
208
209
210
211
212
213
214
215
      - run:
          command: |
            curl -o conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
            sh conda.sh -b
            source $HOME/miniconda3/bin/activate
            conda install -yq conda-build
            packaging/build_conda.sh
      - store_artifacts:
          path: /Users/distiller/miniconda3/conda-bld/osx-64
Edward Z. Yang's avatar
Edward Z. Yang committed
216
217
218
219
      - persist_to_workspace:
          root: /Users/distiller/miniconda3/conda-bld/osx-64
          paths:
            - "*"
220
221
      - store_test_results:
          path: build_results/
Edward Z. Yang's avatar
Edward Z. Yang committed
222
223
224
225
226
227
228
229

  # Requires org-member context
  binary_conda_upload:
    docker:
      - image: continuumio/miniconda
    steps:
      - attach_workspace:
          at: ~/workspace
230
      - designate_upload_channel
Edward Z. Yang's avatar
Edward Z. Yang committed
231
232
233
234
235
      - run:
          command: |
            # Prevent credential from leaking
            conda install -yq anaconda-client
            set -x
236
            anaconda  -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/workspace/*.tar.bz2 -u "pytorch-${UPLOAD_CHANNEL}" --label main --no-progress --force
Edward Z. Yang's avatar
Edward Z. Yang committed
237
238
239

  # Requires org-member context
  binary_wheel_upload:
Edward Z. Yang's avatar
Edward Z. Yang committed
240
241
242
243
    parameters:
      subfolder:
        description: "What whl subfolder to upload to, e.g., blank or cu100/ (trailing slash is important)"
        type: string
Edward Z. Yang's avatar
Edward Z. Yang committed
244
    docker:
245
      - image: cimg/python:3.8
Edward Z. Yang's avatar
Edward Z. Yang committed
246
247
248
    steps:
      - attach_workspace:
          at: ~/workspace
249
      - designate_upload_channel
Edward Z. Yang's avatar
Edward Z. Yang committed
250
      - checkout
Philip Meier's avatar
Philip Meier committed
251
252
      - pip_install:
          args: awscli
Edward Z. Yang's avatar
Edward Z. Yang committed
253
254
255
256
257
258
259
260
      - run:
          command: |
            export PATH="$HOME/.local/bin:$PATH"
            # Prevent credential from leaking
            set +x
            export AWS_ACCESS_KEY_ID="${PYTORCH_BINARY_AWS_ACCESS_KEY_ID}"
            export AWS_SECRET_ACCESS_KEY="${PYTORCH_BINARY_AWS_SECRET_ACCESS_KEY}"
            set -x
Edward Z. Yang's avatar
Edward Z. Yang committed
261
            for pkg in ~/workspace/*.whl; do
262
              aws s3 cp "$pkg" "s3://pytorch/whl/${UPLOAD_CHANNEL}/<< parameters.subfolder >>" --acl public-read
Edward Z. Yang's avatar
Edward Z. Yang committed
263
            done
264

guyang3532's avatar
guyang3532 committed
265
266
  smoke_test_docker_image_build:
    machine:
267
      image: ubuntu-2004:202104-01
guyang3532's avatar
guyang3532 committed
268
269
270
271
272
    resource_class: large
    environment:
      image_name: torchvision/smoke_test
    steps:
      - checkout
273
      - designate_upload_channel
guyang3532's avatar
guyang3532 committed
274
275
276
277
278
279
280
281
282
283
284
285
      - run:
          name: Build and push Docker image
          no_output_timeout: "1h"
          command: |
            set +x
            echo "${DOCKER_HUB_TOKEN}" | docker login --username "${DOCKER_HUB_USERNAME}" --password-stdin
            set -x
            cd .circleci/smoke_test/docker && docker build . -t ${image_name}:${CIRCLE_WORKFLOW_ID}
            docker tag ${image_name}:${CIRCLE_WORKFLOW_ID} ${image_name}:latest
            docker push ${image_name}:${CIRCLE_WORKFLOW_ID}
            docker push ${image_name}:latest

286
287
288
  cmake_linux_cpu:
    <<: *binary_common
    docker:
289
      - image: "pytorch/manylinux-cpu"
290
291
292
    resource_class: 2xlarge+
    steps:
      - checkout_merge
293
      - designate_upload_channel
294
295
296
297
298
299
300
301
      - run:
          name: Setup conda
          command: .circleci/unittest/linux/scripts/setup_env.sh
      - run: packaging/build_cmake.sh

  cmake_linux_gpu:
    <<: *binary_common
    machine:
302
      image: ubuntu-2004-cuda-11.4:202110-01
303
    resource_class: gpu.nvidia.small
304
305
    steps:
      - checkout_merge
306
      - designate_upload_channel
307
308
309
310
311
      - run:
          name: Setup conda
          command: docker run -e CU_VERSION -e PYTHON_VERSION -e UNICODE_ABI -e PYTORCH_VERSION -t --gpus all -v $PWD:$PWD -w $PWD << parameters.wheel_docker_image >> .circleci/unittest/linux/scripts/setup_env.sh
      - run:
          name: Build torchvision C++ distribution and test
Andrey Talman's avatar
Andrey Talman committed
312
          no_output_timeout: 30m
313
          command: docker run -e CU_VERSION -e PYTHON_VERSION -e UNICODE_ABI -e PYTORCH_VERSION -e UPLOAD_CHANNEL -t --gpus all -v $PWD:$PWD -w $PWD << parameters.wheel_docker_image >> packaging/build_cmake.sh
314
315
316
317

  cmake_macos_cpu:
    <<: *binary_common
    macos:
318
      xcode: "14.0"
319
320
    steps:
      - checkout_merge
321
      - designate_upload_channel
322
323
324
325
326
      - run:
          command: |
            curl -o conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
            sh conda.sh -b
            source $HOME/miniconda3/bin/activate
327
            conda install -yq conda-build cmake python=<< parameters.python_version >>
328
329
330
331
332
333
334
335
            packaging/build_cmake.sh

  cmake_windows_cpu:
    <<: *binary_common
    executor:
      name: windows-cpu
    steps:
      - checkout_merge
336
      - designate_upload_channel
337
338
339
340
      - run:
          command: |
            set -ex
            source packaging/windows/internal/vc_install_helper.sh
341
342
343
344
            eval "$('/C/tools/miniconda3/Scripts/conda.exe' 'shell.bash' 'hook')"
            conda activate base
            conda create -yn python39 python=3.9
            conda activate python39
345
346
347
348
349
350
351
352
            packaging/build_cmake.sh

  cmake_windows_gpu:
    <<: *binary_common
    executor:
      name: windows-gpu
    steps:
      - checkout_merge
353
      - designate_upload_channel
Andrey Talman's avatar
Andrey Talman committed
354
355
356
      - run:
          name: Update CUDA driver
          command: packaging/windows/internal/driver_update.bat
357
358
359
360
361
      - run:
          command: |
            set -ex
            source packaging/windows/internal/vc_install_helper.sh
            packaging/windows/internal/cuda_install.bat
362
363
364
365
366
            eval "$('/C/tools/miniconda3/Scripts/conda.exe' 'shell.bash' 'hook')"
            conda activate
            conda update -y conda
            conda create -yn python39 python=3.9
            conda activate python39
367
368
            packaging/build_cmake.sh

369

370
workflows:
Philip Meier's avatar
Philip Meier committed
371
  lint:
372
373
    jobs:
      - circleci_consistency
Philip Meier's avatar
Philip Meier committed
374
375
376

  build:
    jobs:
377
      []
Edward Z. Yang's avatar
Edward Z. Yang committed
378

379
380
381
382
383
384
385
  cmake:
    jobs:
      - cmake_linux_cpu:
          cu_version: cpu
          name: cmake_linux_cpu
          python_version: '3.8'
      - cmake_linux_gpu:
386
          cu_version: cu117
387
388
          name: cmake_linux_gpu
          python_version: '3.8'
389
          wheel_docker_image: pytorch/manylinux-cuda117
390
391
392
393
      - cmake_windows_cpu:
          cu_version: cpu
          name: cmake_windows_cpu
          python_version: '3.8'
394
      - cmake_windows_gpu:
395
          cu_version: cu117
396
397
          name: cmake_windows_gpu
          python_version: '3.8'
398
399
400
401
402
      - cmake_macos_cpu:
          cu_version: cpu
          name: cmake_macos_cpu
          python_version: '3.8'

Edward Z. Yang's avatar
Edward Z. Yang committed
403
404
  nightly:
    jobs:
405
      []
guyang3532's avatar
guyang3532 committed
406
407
408
409
410
411
412
  docker_build:
    triggers:
      - schedule:
          cron: "0 10 * * 0"
          filters:
            branches:
              only:
413
                - main
guyang3532's avatar
guyang3532 committed
414
415
    jobs:
      - smoke_test_docker_image_build:
416
          context: org-member