• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @generated DO NOT EDIT MANUALLY
2
3# Template is at:    .github/templates/windows_binary_build_workflow.yml.j2
4# Generation script: .github/scripts/generate_ci_workflows.py
5name: windows-binary-libtorch-debug
6
7on:
8  push:
9    # NOTE: Meta Employees can trigger new nightlies using: https://fburl.com/trigger_pytorch_nightly_build
10    branches:
11      - nightly
12    tags:
13      # NOTE: Binary build pipelines should only get triggered on release candidate builds
14      # Release candidate tags look like: v1.11.0-rc1
15      - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
16      - 'ciflow/binaries/*'
17      - 'ciflow/binaries_libtorch/*'
18  workflow_dispatch:
19
20env:
21  # Needed for conda builds
22  ALPINE_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/tool/alpine"
23  ANACONDA_USER: pytorch
24  AWS_DEFAULT_REGION: us-east-1
25  BUILD_ENVIRONMENT: windows-binary-libtorch-debug
26  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27  PR_NUMBER: ${{ github.event.pull_request.number }}
28  SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
29  SKIP_ALL_TESTS: 1
30concurrency:
31  group: windows-binary-libtorch-debug-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
32  cancel-in-progress: true
33
34jobs:
35  libtorch-cpu-shared-with-deps-debug-build:
36    if: ${{ github.repository_owner == 'pytorch' }}
37    runs-on: windows.4xlarge
38    timeout-minutes: 240
39    env:
40      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
41      BUILDER_ROOT: ${{ github.workspace }}/builder
42      PACKAGE_TYPE: libtorch
43      # TODO: This is a legacy variable that we eventually want to get rid of in
44      #       favor of GPU_ARCH_VERSION
45      DESIRED_CUDA: cpu
46      GPU_ARCH_TYPE: cpu
47      SKIP_ALL_TESTS: 1
48      LIBTORCH_CONFIG: debug
49      LIBTORCH_VARIANT: shared-with-deps
50      # This is a dummy value for libtorch to work correctly with our batch scripts
51      # without this value pip does not get installed for some reason
52      DESIRED_PYTHON: "3.8"
53    steps:
54      - name: Display EC2 information
55        shell: bash
56        run: |
57          set -euo pipefail
58          function get_ec2_metadata() {
59            # Pulled from instance metadata endpoint for EC2
60            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
61            category=$1
62            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
63          }
64          echo "ami-id: $(get_ec2_metadata ami-id)"
65          echo "instance-id: $(get_ec2_metadata instance-id)"
66          echo "instance-type: $(get_ec2_metadata instance-type)"
67          echo "system info $(uname -a)"
68      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
69        uses: pytorch/test-infra/.github/actions/setup-ssh@main
70        continue-on-error: true
71        with:
72          github-secret: ${{ secrets.GITHUB_TOKEN }}
73      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
74      - name: Enable long paths on Windows
75        shell: powershell
76        run: |
77          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
78      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
79      # removed once Windows Defender is removed from the AMI
80      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
81        continue-on-error: true
82        shell: powershell
83        run: |
84          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
85          # Let's both exclude the path and disable Windows Defender completely just to be sure
86          # that it doesn't interfere
87          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
88      # NOTE: These environment variables are put here so that they can be applied on every job equally
89      #       They are also here because setting them at a workflow level doesn't give us access to the
90      #       runner.temp variable, which we need.
91      - name: Populate binary env
92        shell: bash
93        run: |
94          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
95          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
96          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
97      - name: Checkout PyTorch
98        uses: malfet/checkout@silent-checkout
99        with:
100          submodules: recursive
101          path: pytorch
102          quiet-checkout: true
103      - name: Clean PyTorch checkout
104        run: |
105          # Remove any artifacts from the previous checkouts
106          git clean -fxd
107        working-directory: pytorch
108      - name: Checkout pytorch/builder
109        uses: malfet/checkout@silent-checkout
110        with:
111          ref: release/2.4
112          submodules: recursive
113          repository: pytorch/builder
114          path: builder
115          quiet-checkout: true
116      - name: Clean pytorch/builder checkout
117        run: |
118          # Remove any artifacts from the previous checkouts
119          git clean -fxd
120        working-directory: builder
121      - name: Populate binary env
122        shell: bash
123        run: |
124          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
125      - name: Build PyTorch binary
126        shell: bash
127        run: |
128          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
129      - uses: actions/upload-artifact@v3
130        if: always()
131        with:
132          name: libtorch-cpu-shared-with-deps-debug
133          retention-days: 14
134          if-no-files-found: error
135          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
136      - name: Wait until all sessions have drained
137        shell: powershell
138        working-directory: pytorch
139        if: always()
140        timeout-minutes: 120
141        run: |
142          .github\scripts\wait_for_ssh_to_drain.ps1
143      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
144        shell: powershell
145        working-directory: pytorch
146        if: always()
147        run: |
148          .github\scripts\kill_active_ssh_sessions.ps1
149  libtorch-cpu-shared-with-deps-debug-test:  # Testing
150    if: ${{ github.repository_owner == 'pytorch' }}
151    needs: libtorch-cpu-shared-with-deps-debug-build
152    runs-on: windows.4xlarge.nonephemeral
153    timeout-minutes: 240
154    env:
155      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
156      BUILDER_ROOT: ${{ github.workspace }}/builder
157      PACKAGE_TYPE: libtorch
158      # TODO: This is a legacy variable that we eventually want to get rid of in
159      #       favor of GPU_ARCH_VERSION
160      DESIRED_CUDA: cpu
161      GPU_ARCH_TYPE: cpu
162      SKIP_ALL_TESTS: 1
163      LIBTORCH_CONFIG: debug
164      LIBTORCH_VARIANT: shared-with-deps
165      # This is a dummy value for libtorch to work correctly with our batch scripts
166      # without this value pip does not get installed for some reason
167      DESIRED_PYTHON: "3.8"
168    steps:
169      - name: Display EC2 information
170        shell: bash
171        run: |
172          set -euo pipefail
173          function get_ec2_metadata() {
174            # Pulled from instance metadata endpoint for EC2
175            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
176            category=$1
177            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
178          }
179          echo "ami-id: $(get_ec2_metadata ami-id)"
180          echo "instance-id: $(get_ec2_metadata instance-id)"
181          echo "instance-type: $(get_ec2_metadata instance-type)"
182          echo "system info $(uname -a)"
183      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
184        uses: pytorch/test-infra/.github/actions/setup-ssh@main
185        continue-on-error: true
186        with:
187          github-secret: ${{ secrets.GITHUB_TOKEN }}
188      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
189      - name: Enable long paths on Windows
190        shell: powershell
191        run: |
192          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
193      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
194      # removed once Windows Defender is removed from the AMI
195      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
196        continue-on-error: true
197        shell: powershell
198        run: |
199          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
200          # Let's both exclude the path and disable Windows Defender completely just to be sure
201          # that it doesn't interfere
202          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
203      # NOTE: These environment variables are put here so that they can be applied on every job equally
204      #       They are also here because setting them at a workflow level doesn't give us access to the
205      #       runner.temp variable, which we need.
206      - name: Populate binary env
207        shell: bash
208        run: |
209          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
210          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
211          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
212      - uses: actions/download-artifact@v3
213        name: Download Build Artifacts
214        with:
215          name: libtorch-cpu-shared-with-deps-debug
216          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
217      - name: Checkout PyTorch
218        uses: malfet/checkout@silent-checkout
219        with:
220          submodules: recursive
221          path: pytorch
222          quiet-checkout: true
223      - name: Clean PyTorch checkout
224        run: |
225          # Remove any artifacts from the previous checkouts
226          git clean -fxd
227        working-directory: pytorch
228      - name: Checkout pytorch/builder
229        uses: malfet/checkout@silent-checkout
230        with:
231          ref: release/2.4
232          submodules: recursive
233          repository: pytorch/builder
234          path: builder
235          quiet-checkout: true
236      - name: Clean pytorch/builder checkout
237        run: |
238          # Remove any artifacts from the previous checkouts
239          git clean -fxd
240        working-directory: builder
241      - name: Populate binary env
242        shell: bash
243        run: |
244          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
245      - name: Test PyTorch binary
246        shell: bash
247        run: |
248          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
249      - name: Wait until all sessions have drained
250        shell: powershell
251        working-directory: pytorch
252        if: always()
253        timeout-minutes: 120
254        run: |
255          .github\scripts\wait_for_ssh_to_drain.ps1
256      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
257        shell: powershell
258        working-directory: pytorch
259        if: always()
260        run: |
261          .github\scripts\kill_active_ssh_sessions.ps1
262  libtorch-cpu-shared-with-deps-debug-upload:  # Uploading
263    if: ${{ github.repository_owner == 'pytorch' }}
264    permissions:
265      id-token: write
266      contents: read
267    needs: libtorch-cpu-shared-with-deps-debug-test
268    with:
269      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
270      BUILDER_ROOT: ${{ github.workspace }}/builder
271      PACKAGE_TYPE: libtorch
272      # TODO: This is a legacy variable that we eventually want to get rid of in
273      #       favor of GPU_ARCH_VERSION
274      DESIRED_CUDA: cpu
275      GPU_ARCH_TYPE: cpu
276      LIBTORCH_CONFIG: debug
277      LIBTORCH_VARIANT: shared-with-deps
278      # This is a dummy value for libtorch to work correctly with our batch scripts
279      # without this value pip does not get installed for some reason
280      DESIRED_PYTHON: "3.8"
281      build_name: libtorch-cpu-shared-with-deps-debug
282    secrets:
283      github-token: ${{ secrets.GITHUB_TOKEN }}
284      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
285      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
286    uses: ./.github/workflows/_binary-upload.yml
287  libtorch-cuda11_8-shared-with-deps-debug-build:
288    if: ${{ github.repository_owner == 'pytorch' }}
289    runs-on: windows.4xlarge
290    timeout-minutes: 240
291    env:
292      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
293      BUILDER_ROOT: ${{ github.workspace }}/builder
294      PACKAGE_TYPE: libtorch
295      # TODO: This is a legacy variable that we eventually want to get rid of in
296      #       favor of GPU_ARCH_VERSION
297      DESIRED_CUDA: cu118
298      GPU_ARCH_VERSION: 11.8
299      GPU_ARCH_TYPE: cuda
300      SKIP_ALL_TESTS: 1
301      LIBTORCH_CONFIG: debug
302      LIBTORCH_VARIANT: shared-with-deps
303      # This is a dummy value for libtorch to work correctly with our batch scripts
304      # without this value pip does not get installed for some reason
305      DESIRED_PYTHON: "3.8"
306    steps:
307      - name: Display EC2 information
308        shell: bash
309        run: |
310          set -euo pipefail
311          function get_ec2_metadata() {
312            # Pulled from instance metadata endpoint for EC2
313            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
314            category=$1
315            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
316          }
317          echo "ami-id: $(get_ec2_metadata ami-id)"
318          echo "instance-id: $(get_ec2_metadata instance-id)"
319          echo "instance-type: $(get_ec2_metadata instance-type)"
320          echo "system info $(uname -a)"
321      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
322        uses: pytorch/test-infra/.github/actions/setup-ssh@main
323        continue-on-error: true
324        with:
325          github-secret: ${{ secrets.GITHUB_TOKEN }}
326      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
327      - name: Enable long paths on Windows
328        shell: powershell
329        run: |
330          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
331      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
332      # removed once Windows Defender is removed from the AMI
333      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
334        continue-on-error: true
335        shell: powershell
336        run: |
337          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
338          # Let's both exclude the path and disable Windows Defender completely just to be sure
339          # that it doesn't interfere
340          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
341      # NOTE: These environment variables are put here so that they can be applied on every job equally
342      #       They are also here because setting them at a workflow level doesn't give us access to the
343      #       runner.temp variable, which we need.
344      - name: Populate binary env
345        shell: bash
346        run: |
347          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
348          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
349          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
350      - name: Checkout PyTorch
351        uses: malfet/checkout@silent-checkout
352        with:
353          submodules: recursive
354          path: pytorch
355          quiet-checkout: true
356      - name: Clean PyTorch checkout
357        run: |
358          # Remove any artifacts from the previous checkouts
359          git clean -fxd
360        working-directory: pytorch
361      - name: Checkout pytorch/builder
362        uses: malfet/checkout@silent-checkout
363        with:
364          ref: release/2.4
365          submodules: recursive
366          repository: pytorch/builder
367          path: builder
368          quiet-checkout: true
369      - name: Clean pytorch/builder checkout
370        run: |
371          # Remove any artifacts from the previous checkouts
372          git clean -fxd
373        working-directory: builder
374      - name: Populate binary env
375        shell: bash
376        run: |
377          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
378      - name: Build PyTorch binary
379        shell: bash
380        run: |
381          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
382      - uses: actions/upload-artifact@v3
383        if: always()
384        with:
385          name: libtorch-cuda11_8-shared-with-deps-debug
386          retention-days: 14
387          if-no-files-found: error
388          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
389      - name: Wait until all sessions have drained
390        shell: powershell
391        working-directory: pytorch
392        if: always()
393        timeout-minutes: 120
394        run: |
395          .github\scripts\wait_for_ssh_to_drain.ps1
396      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
397        shell: powershell
398        working-directory: pytorch
399        if: always()
400        run: |
401          .github\scripts\kill_active_ssh_sessions.ps1
402  libtorch-cuda11_8-shared-with-deps-debug-test:  # Testing
403    if: ${{ github.repository_owner == 'pytorch' }}
404    needs: libtorch-cuda11_8-shared-with-deps-debug-build
405    runs-on: windows.8xlarge.nvidia.gpu
406    timeout-minutes: 240
407    env:
408      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
409      BUILDER_ROOT: ${{ github.workspace }}/builder
410      PACKAGE_TYPE: libtorch
411      # TODO: This is a legacy variable that we eventually want to get rid of in
412      #       favor of GPU_ARCH_VERSION
413      DESIRED_CUDA: cu118
414      GPU_ARCH_VERSION: 11.8
415      GPU_ARCH_TYPE: cuda
416      SKIP_ALL_TESTS: 1
417      LIBTORCH_CONFIG: debug
418      LIBTORCH_VARIANT: shared-with-deps
419      # This is a dummy value for libtorch to work correctly with our batch scripts
420      # without this value pip does not get installed for some reason
421      DESIRED_PYTHON: "3.8"
422    steps:
423      - name: Display EC2 information
424        shell: bash
425        run: |
426          set -euo pipefail
427          function get_ec2_metadata() {
428            # Pulled from instance metadata endpoint for EC2
429            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
430            category=$1
431            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
432          }
433          echo "ami-id: $(get_ec2_metadata ami-id)"
434          echo "instance-id: $(get_ec2_metadata instance-id)"
435          echo "instance-type: $(get_ec2_metadata instance-type)"
436          echo "system info $(uname -a)"
437      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
438        uses: pytorch/test-infra/.github/actions/setup-ssh@main
439        continue-on-error: true
440        with:
441          github-secret: ${{ secrets.GITHUB_TOKEN }}
442      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
443      - name: Enable long paths on Windows
444        shell: powershell
445        run: |
446          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
447      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
448      # removed once Windows Defender is removed from the AMI
449      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
450        continue-on-error: true
451        shell: powershell
452        run: |
453          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
454          # Let's both exclude the path and disable Windows Defender completely just to be sure
455          # that it doesn't interfere
456          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
457      # NOTE: These environment variables are put here so that they can be applied on every job equally
458      #       They are also here because setting them at a workflow level doesn't give us access to the
459      #       runner.temp variable, which we need.
460      - name: Populate binary env
461        shell: bash
462        run: |
463          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
464          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
465          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
466      - uses: actions/download-artifact@v3
467        name: Download Build Artifacts
468        with:
469          name: libtorch-cuda11_8-shared-with-deps-debug
470          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
471      - name: Checkout PyTorch
472        uses: malfet/checkout@silent-checkout
473        with:
474          submodules: recursive
475          path: pytorch
476          quiet-checkout: true
477      - name: Clean PyTorch checkout
478        run: |
479          # Remove any artifacts from the previous checkouts
480          git clean -fxd
481        working-directory: pytorch
482      - name: Checkout pytorch/builder
483        uses: malfet/checkout@silent-checkout
484        with:
485          ref: release/2.4
486          submodules: recursive
487          repository: pytorch/builder
488          path: builder
489          quiet-checkout: true
490      - name: Clean pytorch/builder checkout
491        run: |
492          # Remove any artifacts from the previous checkouts
493          git clean -fxd
494        working-directory: builder
495      - name: Populate binary env
496        shell: bash
497        run: |
498          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
499      - name: Test PyTorch binary
500        shell: bash
501        run: |
502          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
503      - name: Wait until all sessions have drained
504        shell: powershell
505        working-directory: pytorch
506        if: always()
507        timeout-minutes: 120
508        run: |
509          .github\scripts\wait_for_ssh_to_drain.ps1
510      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
511        shell: powershell
512        working-directory: pytorch
513        if: always()
514        run: |
515          .github\scripts\kill_active_ssh_sessions.ps1
516  libtorch-cuda11_8-shared-with-deps-debug-upload:  # Uploading
517    if: ${{ github.repository_owner == 'pytorch' }}
518    permissions:
519      id-token: write
520      contents: read
521    needs: libtorch-cuda11_8-shared-with-deps-debug-test
522    with:
523      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
524      BUILDER_ROOT: ${{ github.workspace }}/builder
525      PACKAGE_TYPE: libtorch
526      # TODO: This is a legacy variable that we eventually want to get rid of in
527      #       favor of GPU_ARCH_VERSION
528      DESIRED_CUDA: cu118
529      GPU_ARCH_VERSION: 11.8
530      GPU_ARCH_TYPE: cuda
531      LIBTORCH_CONFIG: debug
532      LIBTORCH_VARIANT: shared-with-deps
533      # This is a dummy value for libtorch to work correctly with our batch scripts
534      # without this value pip does not get installed for some reason
535      DESIRED_PYTHON: "3.8"
536      build_name: libtorch-cuda11_8-shared-with-deps-debug
537    secrets:
538      github-token: ${{ secrets.GITHUB_TOKEN }}
539      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
540      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
541    uses: ./.github/workflows/_binary-upload.yml
542  libtorch-cuda12_1-shared-with-deps-debug-build:
543    if: ${{ github.repository_owner == 'pytorch' }}
544    runs-on: windows.4xlarge
545    timeout-minutes: 240
546    env:
547      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
548      BUILDER_ROOT: ${{ github.workspace }}/builder
549      PACKAGE_TYPE: libtorch
550      # TODO: This is a legacy variable that we eventually want to get rid of in
551      #       favor of GPU_ARCH_VERSION
552      DESIRED_CUDA: cu121
553      GPU_ARCH_VERSION: 12.1
554      GPU_ARCH_TYPE: cuda
555      SKIP_ALL_TESTS: 1
556      LIBTORCH_CONFIG: debug
557      LIBTORCH_VARIANT: shared-with-deps
558      # This is a dummy value for libtorch to work correctly with our batch scripts
559      # without this value pip does not get installed for some reason
560      DESIRED_PYTHON: "3.8"
561    steps:
562      - name: Display EC2 information
563        shell: bash
564        run: |
565          set -euo pipefail
566          function get_ec2_metadata() {
567            # Pulled from instance metadata endpoint for EC2
568            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
569            category=$1
570            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
571          }
572          echo "ami-id: $(get_ec2_metadata ami-id)"
573          echo "instance-id: $(get_ec2_metadata instance-id)"
574          echo "instance-type: $(get_ec2_metadata instance-type)"
575          echo "system info $(uname -a)"
576      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
577        uses: pytorch/test-infra/.github/actions/setup-ssh@main
578        continue-on-error: true
579        with:
580          github-secret: ${{ secrets.GITHUB_TOKEN }}
581      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
582      - name: Enable long paths on Windows
583        shell: powershell
584        run: |
585          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
586      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
587      # removed once Windows Defender is removed from the AMI
588      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
589        continue-on-error: true
590        shell: powershell
591        run: |
592          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
593          # Let's both exclude the path and disable Windows Defender completely just to be sure
594          # that it doesn't interfere
595          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
596      # NOTE: These environment variables are put here so that they can be applied on every job equally
597      #       They are also here because setting them at a workflow level doesn't give us access to the
598      #       runner.temp variable, which we need.
599      - name: Populate binary env
600        shell: bash
601        run: |
602          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
603          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
604          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
605      - name: Checkout PyTorch
606        uses: malfet/checkout@silent-checkout
607        with:
608          submodules: recursive
609          path: pytorch
610          quiet-checkout: true
611      - name: Clean PyTorch checkout
612        run: |
613          # Remove any artifacts from the previous checkouts
614          git clean -fxd
615        working-directory: pytorch
616      - name: Checkout pytorch/builder
617        uses: malfet/checkout@silent-checkout
618        with:
619          ref: release/2.4
620          submodules: recursive
621          repository: pytorch/builder
622          path: builder
623          quiet-checkout: true
624      - name: Clean pytorch/builder checkout
625        run: |
626          # Remove any artifacts from the previous checkouts
627          git clean -fxd
628        working-directory: builder
629      - name: Populate binary env
630        shell: bash
631        run: |
632          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
633      - name: Build PyTorch binary
634        shell: bash
635        run: |
636          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
637      - uses: actions/upload-artifact@v3
638        if: always()
639        with:
640          name: libtorch-cuda12_1-shared-with-deps-debug
641          retention-days: 14
642          if-no-files-found: error
643          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
644      - name: Wait until all sessions have drained
645        shell: powershell
646        working-directory: pytorch
647        if: always()
648        timeout-minutes: 120
649        run: |
650          .github\scripts\wait_for_ssh_to_drain.ps1
651      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
652        shell: powershell
653        working-directory: pytorch
654        if: always()
655        run: |
656          .github\scripts\kill_active_ssh_sessions.ps1
657  libtorch-cuda12_1-shared-with-deps-debug-test:  # Testing
658    if: ${{ github.repository_owner == 'pytorch' }}
659    needs: libtorch-cuda12_1-shared-with-deps-debug-build
660    runs-on: windows.8xlarge.nvidia.gpu
661    timeout-minutes: 240
662    env:
663      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
664      BUILDER_ROOT: ${{ github.workspace }}/builder
665      PACKAGE_TYPE: libtorch
666      # TODO: This is a legacy variable that we eventually want to get rid of in
667      #       favor of GPU_ARCH_VERSION
668      DESIRED_CUDA: cu121
669      GPU_ARCH_VERSION: 12.1
670      GPU_ARCH_TYPE: cuda
671      SKIP_ALL_TESTS: 1
672      LIBTORCH_CONFIG: debug
673      LIBTORCH_VARIANT: shared-with-deps
674      # This is a dummy value for libtorch to work correctly with our batch scripts
675      # without this value pip does not get installed for some reason
676      DESIRED_PYTHON: "3.8"
677    steps:
678      - name: Display EC2 information
679        shell: bash
680        run: |
681          set -euo pipefail
682          function get_ec2_metadata() {
683            # Pulled from instance metadata endpoint for EC2
684            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
685            category=$1
686            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
687          }
688          echo "ami-id: $(get_ec2_metadata ami-id)"
689          echo "instance-id: $(get_ec2_metadata instance-id)"
690          echo "instance-type: $(get_ec2_metadata instance-type)"
691          echo "system info $(uname -a)"
692      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
693        uses: pytorch/test-infra/.github/actions/setup-ssh@main
694        continue-on-error: true
695        with:
696          github-secret: ${{ secrets.GITHUB_TOKEN }}
697      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
698      - name: Enable long paths on Windows
699        shell: powershell
700        run: |
701          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
702      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
703      # removed once Windows Defender is removed from the AMI
704      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
705        continue-on-error: true
706        shell: powershell
707        run: |
708          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
709          # Let's both exclude the path and disable Windows Defender completely just to be sure
710          # that it doesn't interfere
711          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
712      # NOTE: These environment variables are put here so that they can be applied on every job equally
713      #       They are also here because setting them at a workflow level doesn't give us access to the
714      #       runner.temp variable, which we need.
715      - name: Populate binary env
716        shell: bash
717        run: |
718          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
719          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
720          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
721      - uses: actions/download-artifact@v3
722        name: Download Build Artifacts
723        with:
724          name: libtorch-cuda12_1-shared-with-deps-debug
725          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
726      - name: Checkout PyTorch
727        uses: malfet/checkout@silent-checkout
728        with:
729          submodules: recursive
730          path: pytorch
731          quiet-checkout: true
732      - name: Clean PyTorch checkout
733        run: |
734          # Remove any artifacts from the previous checkouts
735          git clean -fxd
736        working-directory: pytorch
737      - name: Checkout pytorch/builder
738        uses: malfet/checkout@silent-checkout
739        with:
740          ref: release/2.4
741          submodules: recursive
742          repository: pytorch/builder
743          path: builder
744          quiet-checkout: true
745      - name: Clean pytorch/builder checkout
746        run: |
747          # Remove any artifacts from the previous checkouts
748          git clean -fxd
749        working-directory: builder
750      - name: Populate binary env
751        shell: bash
752        run: |
753          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
754      - name: Test PyTorch binary
755        shell: bash
756        run: |
757          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
758      - name: Wait until all sessions have drained
759        shell: powershell
760        working-directory: pytorch
761        if: always()
762        timeout-minutes: 120
763        run: |
764          .github\scripts\wait_for_ssh_to_drain.ps1
765      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
766        shell: powershell
767        working-directory: pytorch
768        if: always()
769        run: |
770          .github\scripts\kill_active_ssh_sessions.ps1
771  libtorch-cuda12_1-shared-with-deps-debug-upload:  # Uploading
772    if: ${{ github.repository_owner == 'pytorch' }}
773    permissions:
774      id-token: write
775      contents: read
776    needs: libtorch-cuda12_1-shared-with-deps-debug-test
777    with:
778      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
779      BUILDER_ROOT: ${{ github.workspace }}/builder
780      PACKAGE_TYPE: libtorch
781      # TODO: This is a legacy variable that we eventually want to get rid of in
782      #       favor of GPU_ARCH_VERSION
783      DESIRED_CUDA: cu121
784      GPU_ARCH_VERSION: 12.1
785      GPU_ARCH_TYPE: cuda
786      LIBTORCH_CONFIG: debug
787      LIBTORCH_VARIANT: shared-with-deps
788      # This is a dummy value for libtorch to work correctly with our batch scripts
789      # without this value pip does not get installed for some reason
790      DESIRED_PYTHON: "3.8"
791      build_name: libtorch-cuda12_1-shared-with-deps-debug
792    secrets:
793      github-token: ${{ secrets.GITHUB_TOKEN }}
794      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
795      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
796    uses: ./.github/workflows/_binary-upload.yml
797  libtorch-cuda12_4-shared-with-deps-debug-build:
798    if: ${{ github.repository_owner == 'pytorch' }}
799    runs-on: windows.4xlarge
800    timeout-minutes: 240
801    env:
802      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
803      BUILDER_ROOT: ${{ github.workspace }}/builder
804      PACKAGE_TYPE: libtorch
805      # TODO: This is a legacy variable that we eventually want to get rid of in
806      #       favor of GPU_ARCH_VERSION
807      DESIRED_CUDA: cu124
808      GPU_ARCH_VERSION: 12.4
809      GPU_ARCH_TYPE: cuda
810      SKIP_ALL_TESTS: 1
811      LIBTORCH_CONFIG: debug
812      LIBTORCH_VARIANT: shared-with-deps
813      # This is a dummy value for libtorch to work correctly with our batch scripts
814      # without this value pip does not get installed for some reason
815      DESIRED_PYTHON: "3.8"
816    steps:
817      - name: Display EC2 information
818        shell: bash
819        run: |
820          set -euo pipefail
821          function get_ec2_metadata() {
822            # Pulled from instance metadata endpoint for EC2
823            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
824            category=$1
825            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
826          }
827          echo "ami-id: $(get_ec2_metadata ami-id)"
828          echo "instance-id: $(get_ec2_metadata instance-id)"
829          echo "instance-type: $(get_ec2_metadata instance-type)"
830          echo "system info $(uname -a)"
831      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
832        uses: pytorch/test-infra/.github/actions/setup-ssh@main
833        continue-on-error: true
834        with:
835          github-secret: ${{ secrets.GITHUB_TOKEN }}
836      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
837      - name: Enable long paths on Windows
838        shell: powershell
839        run: |
840          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
841      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
842      # removed once Windows Defender is removed from the AMI
843      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
844        continue-on-error: true
845        shell: powershell
846        run: |
847          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
848          # Let's both exclude the path and disable Windows Defender completely just to be sure
849          # that it doesn't interfere
850          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
851      # NOTE: These environment variables are put here so that they can be applied on every job equally
852      #       They are also here because setting them at a workflow level doesn't give us access to the
853      #       runner.temp variable, which we need.
854      - name: Populate binary env
855        shell: bash
856        run: |
857          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
858          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
859          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
860      - name: Checkout PyTorch
861        uses: malfet/checkout@silent-checkout
862        with:
863          submodules: recursive
864          path: pytorch
865          quiet-checkout: true
866      - name: Clean PyTorch checkout
867        run: |
868          # Remove any artifacts from the previous checkouts
869          git clean -fxd
870        working-directory: pytorch
871      - name: Checkout pytorch/builder
872        uses: malfet/checkout@silent-checkout
873        with:
874          ref: release/2.4
875          submodules: recursive
876          repository: pytorch/builder
877          path: builder
878          quiet-checkout: true
879      - name: Clean pytorch/builder checkout
880        run: |
881          # Remove any artifacts from the previous checkouts
882          git clean -fxd
883        working-directory: builder
884      - name: Populate binary env
885        shell: bash
886        run: |
887          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
888      - name: Build PyTorch binary
889        shell: bash
890        run: |
891          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
892      - uses: actions/upload-artifact@v3
893        if: always()
894        with:
895          name: libtorch-cuda12_4-shared-with-deps-debug
896          retention-days: 14
897          if-no-files-found: error
898          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
899      - name: Wait until all sessions have drained
900        shell: powershell
901        working-directory: pytorch
902        if: always()
903        timeout-minutes: 120
904        run: |
905          .github\scripts\wait_for_ssh_to_drain.ps1
906      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
907        shell: powershell
908        working-directory: pytorch
909        if: always()
910        run: |
911          .github\scripts\kill_active_ssh_sessions.ps1
912  libtorch-cuda12_4-shared-with-deps-debug-test:  # Testing
913    if: ${{ github.repository_owner == 'pytorch' }}
914    needs: libtorch-cuda12_4-shared-with-deps-debug-build
915    runs-on: windows.8xlarge.nvidia.gpu
916    timeout-minutes: 240
917    env:
918      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
919      BUILDER_ROOT: ${{ github.workspace }}/builder
920      PACKAGE_TYPE: libtorch
921      # TODO: This is a legacy variable that we eventually want to get rid of in
922      #       favor of GPU_ARCH_VERSION
923      DESIRED_CUDA: cu124
924      GPU_ARCH_VERSION: 12.4
925      GPU_ARCH_TYPE: cuda
926      SKIP_ALL_TESTS: 1
927      LIBTORCH_CONFIG: debug
928      LIBTORCH_VARIANT: shared-with-deps
929      # This is a dummy value for libtorch to work correctly with our batch scripts
930      # without this value pip does not get installed for some reason
931      DESIRED_PYTHON: "3.8"
932    steps:
933      - name: Display EC2 information
934        shell: bash
935        run: |
936          set -euo pipefail
937          function get_ec2_metadata() {
938            # Pulled from instance metadata endpoint for EC2
939            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
940            category=$1
941            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
942          }
943          echo "ami-id: $(get_ec2_metadata ami-id)"
944          echo "instance-id: $(get_ec2_metadata instance-id)"
945          echo "instance-type: $(get_ec2_metadata instance-type)"
946          echo "system info $(uname -a)"
947      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
948        uses: pytorch/test-infra/.github/actions/setup-ssh@main
949        continue-on-error: true
950        with:
951          github-secret: ${{ secrets.GITHUB_TOKEN }}
952      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
953      - name: Enable long paths on Windows
954        shell: powershell
955        run: |
956          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
957      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
958      # removed once Windows Defender is removed from the AMI
959      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
960        continue-on-error: true
961        shell: powershell
962        run: |
963          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
964          # Let's both exclude the path and disable Windows Defender completely just to be sure
965          # that it doesn't interfere
966          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
967      # NOTE: These environment variables are put here so that they can be applied on every job equally
968      #       They are also here because setting them at a workflow level doesn't give us access to the
969      #       runner.temp variable, which we need.
970      - name: Populate binary env
971        shell: bash
972        run: |
973          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
974          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
975          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
976      - uses: actions/download-artifact@v3
977        name: Download Build Artifacts
978        with:
979          name: libtorch-cuda12_4-shared-with-deps-debug
980          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
981      - name: Checkout PyTorch
982        uses: malfet/checkout@silent-checkout
983        with:
984          submodules: recursive
985          path: pytorch
986          quiet-checkout: true
987      - name: Clean PyTorch checkout
988        run: |
989          # Remove any artifacts from the previous checkouts
990          git clean -fxd
991        working-directory: pytorch
992      - name: Checkout pytorch/builder
993        uses: malfet/checkout@silent-checkout
994        with:
995          ref: release/2.4
996          submodules: recursive
997          repository: pytorch/builder
998          path: builder
999          quiet-checkout: true
1000      - name: Clean pytorch/builder checkout
1001        run: |
1002          # Remove any artifacts from the previous checkouts
1003          git clean -fxd
1004        working-directory: builder
1005      - name: Populate binary env
1006        shell: bash
1007        run: |
1008          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
1009      - name: Test PyTorch binary
1010        shell: bash
1011        run: |
1012          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
1013      - name: Wait until all sessions have drained
1014        shell: powershell
1015        working-directory: pytorch
1016        if: always()
1017        timeout-minutes: 120
1018        run: |
1019          .github\scripts\wait_for_ssh_to_drain.ps1
1020      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
1021        shell: powershell
1022        working-directory: pytorch
1023        if: always()
1024        run: |
1025          .github\scripts\kill_active_ssh_sessions.ps1
1026  libtorch-cuda12_4-shared-with-deps-debug-upload:  # Uploading
1027    if: ${{ github.repository_owner == 'pytorch' }}
1028    permissions:
1029      id-token: write
1030      contents: read
1031    needs: libtorch-cuda12_4-shared-with-deps-debug-test
1032    with:
1033      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1034      BUILDER_ROOT: ${{ github.workspace }}/builder
1035      PACKAGE_TYPE: libtorch
1036      # TODO: This is a legacy variable that we eventually want to get rid of in
1037      #       favor of GPU_ARCH_VERSION
1038      DESIRED_CUDA: cu124
1039      GPU_ARCH_VERSION: 12.4
1040      GPU_ARCH_TYPE: cuda
1041      LIBTORCH_CONFIG: debug
1042      LIBTORCH_VARIANT: shared-with-deps
1043      # This is a dummy value for libtorch to work correctly with our batch scripts
1044      # without this value pip does not get installed for some reason
1045      DESIRED_PYTHON: "3.8"
1046      build_name: libtorch-cuda12_4-shared-with-deps-debug
1047    secrets:
1048      github-token: ${{ secrets.GITHUB_TOKEN }}
1049      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
1050      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
1051    uses: ./.github/workflows/_binary-upload.yml
1052