• 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-wheel
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_wheel/*'
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-wheel
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-wheel-${{ 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  wheel-py3_8-cpu-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: wheel
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      DESIRED_PYTHON: "3.8"
49      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
50    steps:
51      - name: Display EC2 information
52        shell: bash
53        run: |
54          set -euo pipefail
55          function get_ec2_metadata() {
56            # Pulled from instance metadata endpoint for EC2
57            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
58            category=$1
59            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
60          }
61          echo "ami-id: $(get_ec2_metadata ami-id)"
62          echo "instance-id: $(get_ec2_metadata instance-id)"
63          echo "instance-type: $(get_ec2_metadata instance-type)"
64          echo "system info $(uname -a)"
65      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
66        uses: pytorch/test-infra/.github/actions/setup-ssh@main
67        continue-on-error: true
68        with:
69          github-secret: ${{ secrets.GITHUB_TOKEN }}
70      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
71      - name: Enable long paths on Windows
72        shell: powershell
73        run: |
74          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
75      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
76      # removed once Windows Defender is removed from the AMI
77      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
78        continue-on-error: true
79        shell: powershell
80        run: |
81          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
82          # Let's both exclude the path and disable Windows Defender completely just to be sure
83          # that it doesn't interfere
84          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
85      # NOTE: These environment variables are put here so that they can be applied on every job equally
86      #       They are also here because setting them at a workflow level doesn't give us access to the
87      #       runner.temp variable, which we need.
88      - name: Populate binary env
89        shell: bash
90        run: |
91          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
92          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
93          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
94      - name: Checkout PyTorch
95        uses: malfet/checkout@silent-checkout
96        with:
97          submodules: recursive
98          path: pytorch
99          quiet-checkout: true
100      - name: Clean PyTorch checkout
101        run: |
102          # Remove any artifacts from the previous checkouts
103          git clean -fxd
104        working-directory: pytorch
105      - name: Checkout pytorch/builder
106        uses: malfet/checkout@silent-checkout
107        with:
108          ref: release/2.4
109          submodules: recursive
110          repository: pytorch/builder
111          path: builder
112          quiet-checkout: true
113      - name: Clean pytorch/builder checkout
114        run: |
115          # Remove any artifacts from the previous checkouts
116          git clean -fxd
117        working-directory: builder
118      - name: Populate binary env
119        shell: bash
120        run: |
121          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
122      - name: Build PyTorch binary
123        shell: bash
124        run: |
125          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
126      - uses: actions/upload-artifact@v3
127        if: always()
128        with:
129          name: wheel-py3_8-cpu
130          retention-days: 14
131          if-no-files-found: error
132          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
133      - name: Wait until all sessions have drained
134        shell: powershell
135        working-directory: pytorch
136        if: always()
137        timeout-minutes: 120
138        run: |
139          .github\scripts\wait_for_ssh_to_drain.ps1
140      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
141        shell: powershell
142        working-directory: pytorch
143        if: always()
144        run: |
145          .github\scripts\kill_active_ssh_sessions.ps1
146  wheel-py3_8-cpu-test:  # Testing
147    if: ${{ github.repository_owner == 'pytorch' }}
148    needs: wheel-py3_8-cpu-build
149    runs-on: windows.4xlarge.nonephemeral
150    timeout-minutes: 240
151    env:
152      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
153      BUILDER_ROOT: ${{ github.workspace }}/builder
154      PACKAGE_TYPE: wheel
155      # TODO: This is a legacy variable that we eventually want to get rid of in
156      #       favor of GPU_ARCH_VERSION
157      DESIRED_CUDA: cpu
158      GPU_ARCH_TYPE: cpu
159      SKIP_ALL_TESTS: 1
160      DESIRED_PYTHON: "3.8"
161    steps:
162      - name: Display EC2 information
163        shell: bash
164        run: |
165          set -euo pipefail
166          function get_ec2_metadata() {
167            # Pulled from instance metadata endpoint for EC2
168            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
169            category=$1
170            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
171          }
172          echo "ami-id: $(get_ec2_metadata ami-id)"
173          echo "instance-id: $(get_ec2_metadata instance-id)"
174          echo "instance-type: $(get_ec2_metadata instance-type)"
175          echo "system info $(uname -a)"
176      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
177        uses: pytorch/test-infra/.github/actions/setup-ssh@main
178        continue-on-error: true
179        with:
180          github-secret: ${{ secrets.GITHUB_TOKEN }}
181      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
182      - name: Enable long paths on Windows
183        shell: powershell
184        run: |
185          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
186      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
187      # removed once Windows Defender is removed from the AMI
188      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
189        continue-on-error: true
190        shell: powershell
191        run: |
192          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
193          # Let's both exclude the path and disable Windows Defender completely just to be sure
194          # that it doesn't interfere
195          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
196      # NOTE: These environment variables are put here so that they can be applied on every job equally
197      #       They are also here because setting them at a workflow level doesn't give us access to the
198      #       runner.temp variable, which we need.
199      - name: Populate binary env
200        shell: bash
201        run: |
202          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
203          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
204          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
205      - uses: actions/download-artifact@v3
206        name: Download Build Artifacts
207        with:
208          name: wheel-py3_8-cpu
209          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
210      - name: Checkout PyTorch
211        uses: malfet/checkout@silent-checkout
212        with:
213          submodules: recursive
214          path: pytorch
215          quiet-checkout: true
216      - name: Clean PyTorch checkout
217        run: |
218          # Remove any artifacts from the previous checkouts
219          git clean -fxd
220        working-directory: pytorch
221      - name: Checkout pytorch/builder
222        uses: malfet/checkout@silent-checkout
223        with:
224          ref: release/2.4
225          submodules: recursive
226          repository: pytorch/builder
227          path: builder
228          quiet-checkout: true
229      - name: Clean pytorch/builder checkout
230        run: |
231          # Remove any artifacts from the previous checkouts
232          git clean -fxd
233        working-directory: builder
234      - name: Populate binary env
235        shell: bash
236        run: |
237          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
238      - name: Test PyTorch binary
239        shell: bash
240        run: |
241          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
242      - name: Wait until all sessions have drained
243        shell: powershell
244        working-directory: pytorch
245        if: always()
246        timeout-minutes: 120
247        run: |
248          .github\scripts\wait_for_ssh_to_drain.ps1
249      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
250        shell: powershell
251        working-directory: pytorch
252        if: always()
253        run: |
254          .github\scripts\kill_active_ssh_sessions.ps1
255  wheel-py3_8-cpu-upload:  # Uploading
256    if: ${{ github.repository_owner == 'pytorch' }}
257    permissions:
258      id-token: write
259      contents: read
260    needs: wheel-py3_8-cpu-test
261    with:
262      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
263      BUILDER_ROOT: ${{ github.workspace }}/builder
264      PACKAGE_TYPE: wheel
265      # TODO: This is a legacy variable that we eventually want to get rid of in
266      #       favor of GPU_ARCH_VERSION
267      DESIRED_CUDA: cpu
268      GPU_ARCH_TYPE: cpu
269      DESIRED_PYTHON: "3.8"
270      build_name: wheel-py3_8-cpu
271    secrets:
272      github-token: ${{ secrets.GITHUB_TOKEN }}
273      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
274      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
275    uses: ./.github/workflows/_binary-upload.yml
276  wheel-py3_8-cuda11_8-build:
277    if: ${{ github.repository_owner == 'pytorch' }}
278    runs-on: windows.4xlarge
279    timeout-minutes: 240
280    env:
281      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
282      BUILDER_ROOT: ${{ github.workspace }}/builder
283      PACKAGE_TYPE: wheel
284      # TODO: This is a legacy variable that we eventually want to get rid of in
285      #       favor of GPU_ARCH_VERSION
286      DESIRED_CUDA: cu118
287      GPU_ARCH_VERSION: 11.8
288      GPU_ARCH_TYPE: cuda
289      SKIP_ALL_TESTS: 1
290      DESIRED_PYTHON: "3.8"
291      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
292    steps:
293      - name: Display EC2 information
294        shell: bash
295        run: |
296          set -euo pipefail
297          function get_ec2_metadata() {
298            # Pulled from instance metadata endpoint for EC2
299            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
300            category=$1
301            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
302          }
303          echo "ami-id: $(get_ec2_metadata ami-id)"
304          echo "instance-id: $(get_ec2_metadata instance-id)"
305          echo "instance-type: $(get_ec2_metadata instance-type)"
306          echo "system info $(uname -a)"
307      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
308        uses: pytorch/test-infra/.github/actions/setup-ssh@main
309        continue-on-error: true
310        with:
311          github-secret: ${{ secrets.GITHUB_TOKEN }}
312      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
313      - name: Enable long paths on Windows
314        shell: powershell
315        run: |
316          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
317      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
318      # removed once Windows Defender is removed from the AMI
319      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
320        continue-on-error: true
321        shell: powershell
322        run: |
323          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
324          # Let's both exclude the path and disable Windows Defender completely just to be sure
325          # that it doesn't interfere
326          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
327      # NOTE: These environment variables are put here so that they can be applied on every job equally
328      #       They are also here because setting them at a workflow level doesn't give us access to the
329      #       runner.temp variable, which we need.
330      - name: Populate binary env
331        shell: bash
332        run: |
333          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
334          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
335          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
336      - name: Checkout PyTorch
337        uses: malfet/checkout@silent-checkout
338        with:
339          submodules: recursive
340          path: pytorch
341          quiet-checkout: true
342      - name: Clean PyTorch checkout
343        run: |
344          # Remove any artifacts from the previous checkouts
345          git clean -fxd
346        working-directory: pytorch
347      - name: Checkout pytorch/builder
348        uses: malfet/checkout@silent-checkout
349        with:
350          ref: release/2.4
351          submodules: recursive
352          repository: pytorch/builder
353          path: builder
354          quiet-checkout: true
355      - name: Clean pytorch/builder checkout
356        run: |
357          # Remove any artifacts from the previous checkouts
358          git clean -fxd
359        working-directory: builder
360      - name: Populate binary env
361        shell: bash
362        run: |
363          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
364      - name: Build PyTorch binary
365        shell: bash
366        run: |
367          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
368      - uses: actions/upload-artifact@v3
369        if: always()
370        with:
371          name: wheel-py3_8-cuda11_8
372          retention-days: 14
373          if-no-files-found: error
374          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
375      - name: Wait until all sessions have drained
376        shell: powershell
377        working-directory: pytorch
378        if: always()
379        timeout-minutes: 120
380        run: |
381          .github\scripts\wait_for_ssh_to_drain.ps1
382      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
383        shell: powershell
384        working-directory: pytorch
385        if: always()
386        run: |
387          .github\scripts\kill_active_ssh_sessions.ps1
388  wheel-py3_8-cuda11_8-test:  # Testing
389    if: ${{ github.repository_owner == 'pytorch' }}
390    needs: wheel-py3_8-cuda11_8-build
391    runs-on: windows.8xlarge.nvidia.gpu
392    timeout-minutes: 240
393    env:
394      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
395      BUILDER_ROOT: ${{ github.workspace }}/builder
396      PACKAGE_TYPE: wheel
397      # TODO: This is a legacy variable that we eventually want to get rid of in
398      #       favor of GPU_ARCH_VERSION
399      DESIRED_CUDA: cu118
400      GPU_ARCH_VERSION: 11.8
401      GPU_ARCH_TYPE: cuda
402      SKIP_ALL_TESTS: 1
403      DESIRED_PYTHON: "3.8"
404    steps:
405      - name: Display EC2 information
406        shell: bash
407        run: |
408          set -euo pipefail
409          function get_ec2_metadata() {
410            # Pulled from instance metadata endpoint for EC2
411            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
412            category=$1
413            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
414          }
415          echo "ami-id: $(get_ec2_metadata ami-id)"
416          echo "instance-id: $(get_ec2_metadata instance-id)"
417          echo "instance-type: $(get_ec2_metadata instance-type)"
418          echo "system info $(uname -a)"
419      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
420        uses: pytorch/test-infra/.github/actions/setup-ssh@main
421        continue-on-error: true
422        with:
423          github-secret: ${{ secrets.GITHUB_TOKEN }}
424      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
425      - name: Enable long paths on Windows
426        shell: powershell
427        run: |
428          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
429      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
430      # removed once Windows Defender is removed from the AMI
431      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
432        continue-on-error: true
433        shell: powershell
434        run: |
435          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
436          # Let's both exclude the path and disable Windows Defender completely just to be sure
437          # that it doesn't interfere
438          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
439      # NOTE: These environment variables are put here so that they can be applied on every job equally
440      #       They are also here because setting them at a workflow level doesn't give us access to the
441      #       runner.temp variable, which we need.
442      - name: Populate binary env
443        shell: bash
444        run: |
445          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
446          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
447          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
448      - uses: actions/download-artifact@v3
449        name: Download Build Artifacts
450        with:
451          name: wheel-py3_8-cuda11_8
452          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
453      - name: Checkout PyTorch
454        uses: malfet/checkout@silent-checkout
455        with:
456          submodules: recursive
457          path: pytorch
458          quiet-checkout: true
459      - name: Clean PyTorch checkout
460        run: |
461          # Remove any artifacts from the previous checkouts
462          git clean -fxd
463        working-directory: pytorch
464      - name: Checkout pytorch/builder
465        uses: malfet/checkout@silent-checkout
466        with:
467          ref: release/2.4
468          submodules: recursive
469          repository: pytorch/builder
470          path: builder
471          quiet-checkout: true
472      - name: Clean pytorch/builder checkout
473        run: |
474          # Remove any artifacts from the previous checkouts
475          git clean -fxd
476        working-directory: builder
477      - name: Populate binary env
478        shell: bash
479        run: |
480          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
481      - name: Test PyTorch binary
482        shell: bash
483        run: |
484          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
485      - name: Wait until all sessions have drained
486        shell: powershell
487        working-directory: pytorch
488        if: always()
489        timeout-minutes: 120
490        run: |
491          .github\scripts\wait_for_ssh_to_drain.ps1
492      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
493        shell: powershell
494        working-directory: pytorch
495        if: always()
496        run: |
497          .github\scripts\kill_active_ssh_sessions.ps1
498  wheel-py3_8-cuda11_8-upload:  # Uploading
499    if: ${{ github.repository_owner == 'pytorch' }}
500    permissions:
501      id-token: write
502      contents: read
503    needs: wheel-py3_8-cuda11_8-test
504    with:
505      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
506      BUILDER_ROOT: ${{ github.workspace }}/builder
507      PACKAGE_TYPE: wheel
508      # TODO: This is a legacy variable that we eventually want to get rid of in
509      #       favor of GPU_ARCH_VERSION
510      DESIRED_CUDA: cu118
511      GPU_ARCH_VERSION: 11.8
512      GPU_ARCH_TYPE: cuda
513      DESIRED_PYTHON: "3.8"
514      build_name: wheel-py3_8-cuda11_8
515    secrets:
516      github-token: ${{ secrets.GITHUB_TOKEN }}
517      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
518      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
519    uses: ./.github/workflows/_binary-upload.yml
520  wheel-py3_8-cuda12_1-build:
521    if: ${{ github.repository_owner == 'pytorch' }}
522    runs-on: windows.4xlarge
523    timeout-minutes: 240
524    env:
525      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
526      BUILDER_ROOT: ${{ github.workspace }}/builder
527      PACKAGE_TYPE: wheel
528      # TODO: This is a legacy variable that we eventually want to get rid of in
529      #       favor of GPU_ARCH_VERSION
530      DESIRED_CUDA: cu121
531      GPU_ARCH_VERSION: 12.1
532      GPU_ARCH_TYPE: cuda
533      SKIP_ALL_TESTS: 1
534      DESIRED_PYTHON: "3.8"
535      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
536    steps:
537      - name: Display EC2 information
538        shell: bash
539        run: |
540          set -euo pipefail
541          function get_ec2_metadata() {
542            # Pulled from instance metadata endpoint for EC2
543            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
544            category=$1
545            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
546          }
547          echo "ami-id: $(get_ec2_metadata ami-id)"
548          echo "instance-id: $(get_ec2_metadata instance-id)"
549          echo "instance-type: $(get_ec2_metadata instance-type)"
550          echo "system info $(uname -a)"
551      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
552        uses: pytorch/test-infra/.github/actions/setup-ssh@main
553        continue-on-error: true
554        with:
555          github-secret: ${{ secrets.GITHUB_TOKEN }}
556      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
557      - name: Enable long paths on Windows
558        shell: powershell
559        run: |
560          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
561      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
562      # removed once Windows Defender is removed from the AMI
563      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
564        continue-on-error: true
565        shell: powershell
566        run: |
567          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
568          # Let's both exclude the path and disable Windows Defender completely just to be sure
569          # that it doesn't interfere
570          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
571      # NOTE: These environment variables are put here so that they can be applied on every job equally
572      #       They are also here because setting them at a workflow level doesn't give us access to the
573      #       runner.temp variable, which we need.
574      - name: Populate binary env
575        shell: bash
576        run: |
577          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
578          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
579          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
580      - name: Checkout PyTorch
581        uses: malfet/checkout@silent-checkout
582        with:
583          submodules: recursive
584          path: pytorch
585          quiet-checkout: true
586      - name: Clean PyTorch checkout
587        run: |
588          # Remove any artifacts from the previous checkouts
589          git clean -fxd
590        working-directory: pytorch
591      - name: Checkout pytorch/builder
592        uses: malfet/checkout@silent-checkout
593        with:
594          ref: release/2.4
595          submodules: recursive
596          repository: pytorch/builder
597          path: builder
598          quiet-checkout: true
599      - name: Clean pytorch/builder checkout
600        run: |
601          # Remove any artifacts from the previous checkouts
602          git clean -fxd
603        working-directory: builder
604      - name: Populate binary env
605        shell: bash
606        run: |
607          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
608      - name: Build PyTorch binary
609        shell: bash
610        run: |
611          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
612      - uses: actions/upload-artifact@v3
613        if: always()
614        with:
615          name: wheel-py3_8-cuda12_1
616          retention-days: 14
617          if-no-files-found: error
618          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
619      - name: Wait until all sessions have drained
620        shell: powershell
621        working-directory: pytorch
622        if: always()
623        timeout-minutes: 120
624        run: |
625          .github\scripts\wait_for_ssh_to_drain.ps1
626      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
627        shell: powershell
628        working-directory: pytorch
629        if: always()
630        run: |
631          .github\scripts\kill_active_ssh_sessions.ps1
632  wheel-py3_8-cuda12_1-test:  # Testing
633    if: ${{ github.repository_owner == 'pytorch' }}
634    needs: wheel-py3_8-cuda12_1-build
635    runs-on: windows.8xlarge.nvidia.gpu
636    timeout-minutes: 240
637    env:
638      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
639      BUILDER_ROOT: ${{ github.workspace }}/builder
640      PACKAGE_TYPE: wheel
641      # TODO: This is a legacy variable that we eventually want to get rid of in
642      #       favor of GPU_ARCH_VERSION
643      DESIRED_CUDA: cu121
644      GPU_ARCH_VERSION: 12.1
645      GPU_ARCH_TYPE: cuda
646      SKIP_ALL_TESTS: 1
647      DESIRED_PYTHON: "3.8"
648    steps:
649      - name: Display EC2 information
650        shell: bash
651        run: |
652          set -euo pipefail
653          function get_ec2_metadata() {
654            # Pulled from instance metadata endpoint for EC2
655            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
656            category=$1
657            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
658          }
659          echo "ami-id: $(get_ec2_metadata ami-id)"
660          echo "instance-id: $(get_ec2_metadata instance-id)"
661          echo "instance-type: $(get_ec2_metadata instance-type)"
662          echo "system info $(uname -a)"
663      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
664        uses: pytorch/test-infra/.github/actions/setup-ssh@main
665        continue-on-error: true
666        with:
667          github-secret: ${{ secrets.GITHUB_TOKEN }}
668      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
669      - name: Enable long paths on Windows
670        shell: powershell
671        run: |
672          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
673      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
674      # removed once Windows Defender is removed from the AMI
675      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
676        continue-on-error: true
677        shell: powershell
678        run: |
679          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
680          # Let's both exclude the path and disable Windows Defender completely just to be sure
681          # that it doesn't interfere
682          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
683      # NOTE: These environment variables are put here so that they can be applied on every job equally
684      #       They are also here because setting them at a workflow level doesn't give us access to the
685      #       runner.temp variable, which we need.
686      - name: Populate binary env
687        shell: bash
688        run: |
689          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
690          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
691          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
692      - uses: actions/download-artifact@v3
693        name: Download Build Artifacts
694        with:
695          name: wheel-py3_8-cuda12_1
696          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
697      - name: Checkout PyTorch
698        uses: malfet/checkout@silent-checkout
699        with:
700          submodules: recursive
701          path: pytorch
702          quiet-checkout: true
703      - name: Clean PyTorch checkout
704        run: |
705          # Remove any artifacts from the previous checkouts
706          git clean -fxd
707        working-directory: pytorch
708      - name: Checkout pytorch/builder
709        uses: malfet/checkout@silent-checkout
710        with:
711          ref: release/2.4
712          submodules: recursive
713          repository: pytorch/builder
714          path: builder
715          quiet-checkout: true
716      - name: Clean pytorch/builder checkout
717        run: |
718          # Remove any artifacts from the previous checkouts
719          git clean -fxd
720        working-directory: builder
721      - name: Populate binary env
722        shell: bash
723        run: |
724          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
725      - name: Test PyTorch binary
726        shell: bash
727        run: |
728          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
729      - name: Wait until all sessions have drained
730        shell: powershell
731        working-directory: pytorch
732        if: always()
733        timeout-minutes: 120
734        run: |
735          .github\scripts\wait_for_ssh_to_drain.ps1
736      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
737        shell: powershell
738        working-directory: pytorch
739        if: always()
740        run: |
741          .github\scripts\kill_active_ssh_sessions.ps1
742  wheel-py3_8-cuda12_1-upload:  # Uploading
743    if: ${{ github.repository_owner == 'pytorch' }}
744    permissions:
745      id-token: write
746      contents: read
747    needs: wheel-py3_8-cuda12_1-test
748    with:
749      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
750      BUILDER_ROOT: ${{ github.workspace }}/builder
751      PACKAGE_TYPE: wheel
752      # TODO: This is a legacy variable that we eventually want to get rid of in
753      #       favor of GPU_ARCH_VERSION
754      DESIRED_CUDA: cu121
755      GPU_ARCH_VERSION: 12.1
756      GPU_ARCH_TYPE: cuda
757      DESIRED_PYTHON: "3.8"
758      build_name: wheel-py3_8-cuda12_1
759    secrets:
760      github-token: ${{ secrets.GITHUB_TOKEN }}
761      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
762      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
763    uses: ./.github/workflows/_binary-upload.yml
764  wheel-py3_8-cuda12_4-build:
765    if: ${{ github.repository_owner == 'pytorch' }}
766    runs-on: windows.4xlarge
767    timeout-minutes: 240
768    env:
769      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
770      BUILDER_ROOT: ${{ github.workspace }}/builder
771      PACKAGE_TYPE: wheel
772      # TODO: This is a legacy variable that we eventually want to get rid of in
773      #       favor of GPU_ARCH_VERSION
774      DESIRED_CUDA: cu124
775      GPU_ARCH_VERSION: 12.4
776      GPU_ARCH_TYPE: cuda
777      SKIP_ALL_TESTS: 1
778      DESIRED_PYTHON: "3.8"
779      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
780    steps:
781      - name: Display EC2 information
782        shell: bash
783        run: |
784          set -euo pipefail
785          function get_ec2_metadata() {
786            # Pulled from instance metadata endpoint for EC2
787            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
788            category=$1
789            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
790          }
791          echo "ami-id: $(get_ec2_metadata ami-id)"
792          echo "instance-id: $(get_ec2_metadata instance-id)"
793          echo "instance-type: $(get_ec2_metadata instance-type)"
794          echo "system info $(uname -a)"
795      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
796        uses: pytorch/test-infra/.github/actions/setup-ssh@main
797        continue-on-error: true
798        with:
799          github-secret: ${{ secrets.GITHUB_TOKEN }}
800      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
801      - name: Enable long paths on Windows
802        shell: powershell
803        run: |
804          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
805      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
806      # removed once Windows Defender is removed from the AMI
807      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
808        continue-on-error: true
809        shell: powershell
810        run: |
811          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
812          # Let's both exclude the path and disable Windows Defender completely just to be sure
813          # that it doesn't interfere
814          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
815      # NOTE: These environment variables are put here so that they can be applied on every job equally
816      #       They are also here because setting them at a workflow level doesn't give us access to the
817      #       runner.temp variable, which we need.
818      - name: Populate binary env
819        shell: bash
820        run: |
821          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
822          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
823          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
824      - name: Checkout PyTorch
825        uses: malfet/checkout@silent-checkout
826        with:
827          submodules: recursive
828          path: pytorch
829          quiet-checkout: true
830      - name: Clean PyTorch checkout
831        run: |
832          # Remove any artifacts from the previous checkouts
833          git clean -fxd
834        working-directory: pytorch
835      - name: Checkout pytorch/builder
836        uses: malfet/checkout@silent-checkout
837        with:
838          ref: release/2.4
839          submodules: recursive
840          repository: pytorch/builder
841          path: builder
842          quiet-checkout: true
843      - name: Clean pytorch/builder checkout
844        run: |
845          # Remove any artifacts from the previous checkouts
846          git clean -fxd
847        working-directory: builder
848      - name: Populate binary env
849        shell: bash
850        run: |
851          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
852      - name: Build PyTorch binary
853        shell: bash
854        run: |
855          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
856      - uses: actions/upload-artifact@v3
857        if: always()
858        with:
859          name: wheel-py3_8-cuda12_4
860          retention-days: 14
861          if-no-files-found: error
862          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
863      - name: Wait until all sessions have drained
864        shell: powershell
865        working-directory: pytorch
866        if: always()
867        timeout-minutes: 120
868        run: |
869          .github\scripts\wait_for_ssh_to_drain.ps1
870      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
871        shell: powershell
872        working-directory: pytorch
873        if: always()
874        run: |
875          .github\scripts\kill_active_ssh_sessions.ps1
876  wheel-py3_8-cuda12_4-test:  # Testing
877    if: ${{ github.repository_owner == 'pytorch' }}
878    needs: wheel-py3_8-cuda12_4-build
879    runs-on: windows.8xlarge.nvidia.gpu
880    timeout-minutes: 240
881    env:
882      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
883      BUILDER_ROOT: ${{ github.workspace }}/builder
884      PACKAGE_TYPE: wheel
885      # TODO: This is a legacy variable that we eventually want to get rid of in
886      #       favor of GPU_ARCH_VERSION
887      DESIRED_CUDA: cu124
888      GPU_ARCH_VERSION: 12.4
889      GPU_ARCH_TYPE: cuda
890      SKIP_ALL_TESTS: 1
891      DESIRED_PYTHON: "3.8"
892    steps:
893      - name: Display EC2 information
894        shell: bash
895        run: |
896          set -euo pipefail
897          function get_ec2_metadata() {
898            # Pulled from instance metadata endpoint for EC2
899            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
900            category=$1
901            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
902          }
903          echo "ami-id: $(get_ec2_metadata ami-id)"
904          echo "instance-id: $(get_ec2_metadata instance-id)"
905          echo "instance-type: $(get_ec2_metadata instance-type)"
906          echo "system info $(uname -a)"
907      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
908        uses: pytorch/test-infra/.github/actions/setup-ssh@main
909        continue-on-error: true
910        with:
911          github-secret: ${{ secrets.GITHUB_TOKEN }}
912      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
913      - name: Enable long paths on Windows
914        shell: powershell
915        run: |
916          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
917      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
918      # removed once Windows Defender is removed from the AMI
919      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
920        continue-on-error: true
921        shell: powershell
922        run: |
923          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
924          # Let's both exclude the path and disable Windows Defender completely just to be sure
925          # that it doesn't interfere
926          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
927      # NOTE: These environment variables are put here so that they can be applied on every job equally
928      #       They are also here because setting them at a workflow level doesn't give us access to the
929      #       runner.temp variable, which we need.
930      - name: Populate binary env
931        shell: bash
932        run: |
933          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
934          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
935          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
936      - uses: actions/download-artifact@v3
937        name: Download Build Artifacts
938        with:
939          name: wheel-py3_8-cuda12_4
940          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
941      - name: Checkout PyTorch
942        uses: malfet/checkout@silent-checkout
943        with:
944          submodules: recursive
945          path: pytorch
946          quiet-checkout: true
947      - name: Clean PyTorch checkout
948        run: |
949          # Remove any artifacts from the previous checkouts
950          git clean -fxd
951        working-directory: pytorch
952      - name: Checkout pytorch/builder
953        uses: malfet/checkout@silent-checkout
954        with:
955          ref: release/2.4
956          submodules: recursive
957          repository: pytorch/builder
958          path: builder
959          quiet-checkout: true
960      - name: Clean pytorch/builder checkout
961        run: |
962          # Remove any artifacts from the previous checkouts
963          git clean -fxd
964        working-directory: builder
965      - name: Populate binary env
966        shell: bash
967        run: |
968          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
969      - name: Test PyTorch binary
970        shell: bash
971        run: |
972          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
973      - name: Wait until all sessions have drained
974        shell: powershell
975        working-directory: pytorch
976        if: always()
977        timeout-minutes: 120
978        run: |
979          .github\scripts\wait_for_ssh_to_drain.ps1
980      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
981        shell: powershell
982        working-directory: pytorch
983        if: always()
984        run: |
985          .github\scripts\kill_active_ssh_sessions.ps1
986  wheel-py3_8-cuda12_4-upload:  # Uploading
987    if: ${{ github.repository_owner == 'pytorch' }}
988    permissions:
989      id-token: write
990      contents: read
991    needs: wheel-py3_8-cuda12_4-test
992    with:
993      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
994      BUILDER_ROOT: ${{ github.workspace }}/builder
995      PACKAGE_TYPE: wheel
996      # TODO: This is a legacy variable that we eventually want to get rid of in
997      #       favor of GPU_ARCH_VERSION
998      DESIRED_CUDA: cu124
999      GPU_ARCH_VERSION: 12.4
1000      GPU_ARCH_TYPE: cuda
1001      DESIRED_PYTHON: "3.8"
1002      build_name: wheel-py3_8-cuda12_4
1003    secrets:
1004      github-token: ${{ secrets.GITHUB_TOKEN }}
1005      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
1006      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
1007    uses: ./.github/workflows/_binary-upload.yml
1008  wheel-py3_9-cpu-build:
1009    if: ${{ github.repository_owner == 'pytorch' }}
1010    runs-on: windows.4xlarge
1011    timeout-minutes: 240
1012    env:
1013      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1014      BUILDER_ROOT: ${{ github.workspace }}/builder
1015      PACKAGE_TYPE: wheel
1016      # TODO: This is a legacy variable that we eventually want to get rid of in
1017      #       favor of GPU_ARCH_VERSION
1018      DESIRED_CUDA: cpu
1019      GPU_ARCH_TYPE: cpu
1020      SKIP_ALL_TESTS: 1
1021      DESIRED_PYTHON: "3.9"
1022      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
1023    steps:
1024      - name: Display EC2 information
1025        shell: bash
1026        run: |
1027          set -euo pipefail
1028          function get_ec2_metadata() {
1029            # Pulled from instance metadata endpoint for EC2
1030            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
1031            category=$1
1032            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
1033          }
1034          echo "ami-id: $(get_ec2_metadata ami-id)"
1035          echo "instance-id: $(get_ec2_metadata instance-id)"
1036          echo "instance-type: $(get_ec2_metadata instance-type)"
1037          echo "system info $(uname -a)"
1038      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
1039        uses: pytorch/test-infra/.github/actions/setup-ssh@main
1040        continue-on-error: true
1041        with:
1042          github-secret: ${{ secrets.GITHUB_TOKEN }}
1043      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
1044      - name: Enable long paths on Windows
1045        shell: powershell
1046        run: |
1047          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
1048      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
1049      # removed once Windows Defender is removed from the AMI
1050      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
1051        continue-on-error: true
1052        shell: powershell
1053        run: |
1054          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
1055          # Let's both exclude the path and disable Windows Defender completely just to be sure
1056          # that it doesn't interfere
1057          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
1058      # NOTE: These environment variables are put here so that they can be applied on every job equally
1059      #       They are also here because setting them at a workflow level doesn't give us access to the
1060      #       runner.temp variable, which we need.
1061      - name: Populate binary env
1062        shell: bash
1063        run: |
1064          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
1065          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
1066          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
1067      - name: Checkout PyTorch
1068        uses: malfet/checkout@silent-checkout
1069        with:
1070          submodules: recursive
1071          path: pytorch
1072          quiet-checkout: true
1073      - name: Clean PyTorch checkout
1074        run: |
1075          # Remove any artifacts from the previous checkouts
1076          git clean -fxd
1077        working-directory: pytorch
1078      - name: Checkout pytorch/builder
1079        uses: malfet/checkout@silent-checkout
1080        with:
1081          ref: release/2.4
1082          submodules: recursive
1083          repository: pytorch/builder
1084          path: builder
1085          quiet-checkout: true
1086      - name: Clean pytorch/builder checkout
1087        run: |
1088          # Remove any artifacts from the previous checkouts
1089          git clean -fxd
1090        working-directory: builder
1091      - name: Populate binary env
1092        shell: bash
1093        run: |
1094          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
1095      - name: Build PyTorch binary
1096        shell: bash
1097        run: |
1098          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
1099      - uses: actions/upload-artifact@v3
1100        if: always()
1101        with:
1102          name: wheel-py3_9-cpu
1103          retention-days: 14
1104          if-no-files-found: error
1105          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
1106      - name: Wait until all sessions have drained
1107        shell: powershell
1108        working-directory: pytorch
1109        if: always()
1110        timeout-minutes: 120
1111        run: |
1112          .github\scripts\wait_for_ssh_to_drain.ps1
1113      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
1114        shell: powershell
1115        working-directory: pytorch
1116        if: always()
1117        run: |
1118          .github\scripts\kill_active_ssh_sessions.ps1
1119  wheel-py3_9-cpu-test:  # Testing
1120    if: ${{ github.repository_owner == 'pytorch' }}
1121    needs: wheel-py3_9-cpu-build
1122    runs-on: windows.4xlarge.nonephemeral
1123    timeout-minutes: 240
1124    env:
1125      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1126      BUILDER_ROOT: ${{ github.workspace }}/builder
1127      PACKAGE_TYPE: wheel
1128      # TODO: This is a legacy variable that we eventually want to get rid of in
1129      #       favor of GPU_ARCH_VERSION
1130      DESIRED_CUDA: cpu
1131      GPU_ARCH_TYPE: cpu
1132      SKIP_ALL_TESTS: 1
1133      DESIRED_PYTHON: "3.9"
1134    steps:
1135      - name: Display EC2 information
1136        shell: bash
1137        run: |
1138          set -euo pipefail
1139          function get_ec2_metadata() {
1140            # Pulled from instance metadata endpoint for EC2
1141            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
1142            category=$1
1143            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
1144          }
1145          echo "ami-id: $(get_ec2_metadata ami-id)"
1146          echo "instance-id: $(get_ec2_metadata instance-id)"
1147          echo "instance-type: $(get_ec2_metadata instance-type)"
1148          echo "system info $(uname -a)"
1149      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
1150        uses: pytorch/test-infra/.github/actions/setup-ssh@main
1151        continue-on-error: true
1152        with:
1153          github-secret: ${{ secrets.GITHUB_TOKEN }}
1154      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
1155      - name: Enable long paths on Windows
1156        shell: powershell
1157        run: |
1158          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
1159      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
1160      # removed once Windows Defender is removed from the AMI
1161      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
1162        continue-on-error: true
1163        shell: powershell
1164        run: |
1165          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
1166          # Let's both exclude the path and disable Windows Defender completely just to be sure
1167          # that it doesn't interfere
1168          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
1169      # NOTE: These environment variables are put here so that they can be applied on every job equally
1170      #       They are also here because setting them at a workflow level doesn't give us access to the
1171      #       runner.temp variable, which we need.
1172      - name: Populate binary env
1173        shell: bash
1174        run: |
1175          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
1176          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
1177          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
1178      - uses: actions/download-artifact@v3
1179        name: Download Build Artifacts
1180        with:
1181          name: wheel-py3_9-cpu
1182          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
1183      - name: Checkout PyTorch
1184        uses: malfet/checkout@silent-checkout
1185        with:
1186          submodules: recursive
1187          path: pytorch
1188          quiet-checkout: true
1189      - name: Clean PyTorch checkout
1190        run: |
1191          # Remove any artifacts from the previous checkouts
1192          git clean -fxd
1193        working-directory: pytorch
1194      - name: Checkout pytorch/builder
1195        uses: malfet/checkout@silent-checkout
1196        with:
1197          ref: release/2.4
1198          submodules: recursive
1199          repository: pytorch/builder
1200          path: builder
1201          quiet-checkout: true
1202      - name: Clean pytorch/builder checkout
1203        run: |
1204          # Remove any artifacts from the previous checkouts
1205          git clean -fxd
1206        working-directory: builder
1207      - name: Populate binary env
1208        shell: bash
1209        run: |
1210          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
1211      - name: Test PyTorch binary
1212        shell: bash
1213        run: |
1214          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
1215      - name: Wait until all sessions have drained
1216        shell: powershell
1217        working-directory: pytorch
1218        if: always()
1219        timeout-minutes: 120
1220        run: |
1221          .github\scripts\wait_for_ssh_to_drain.ps1
1222      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
1223        shell: powershell
1224        working-directory: pytorch
1225        if: always()
1226        run: |
1227          .github\scripts\kill_active_ssh_sessions.ps1
1228  wheel-py3_9-cpu-upload:  # Uploading
1229    if: ${{ github.repository_owner == 'pytorch' }}
1230    permissions:
1231      id-token: write
1232      contents: read
1233    needs: wheel-py3_9-cpu-test
1234    with:
1235      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1236      BUILDER_ROOT: ${{ github.workspace }}/builder
1237      PACKAGE_TYPE: wheel
1238      # TODO: This is a legacy variable that we eventually want to get rid of in
1239      #       favor of GPU_ARCH_VERSION
1240      DESIRED_CUDA: cpu
1241      GPU_ARCH_TYPE: cpu
1242      DESIRED_PYTHON: "3.9"
1243      build_name: wheel-py3_9-cpu
1244    secrets:
1245      github-token: ${{ secrets.GITHUB_TOKEN }}
1246      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
1247      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
1248    uses: ./.github/workflows/_binary-upload.yml
1249  wheel-py3_9-cuda11_8-build:
1250    if: ${{ github.repository_owner == 'pytorch' }}
1251    runs-on: windows.4xlarge
1252    timeout-minutes: 240
1253    env:
1254      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1255      BUILDER_ROOT: ${{ github.workspace }}/builder
1256      PACKAGE_TYPE: wheel
1257      # TODO: This is a legacy variable that we eventually want to get rid of in
1258      #       favor of GPU_ARCH_VERSION
1259      DESIRED_CUDA: cu118
1260      GPU_ARCH_VERSION: 11.8
1261      GPU_ARCH_TYPE: cuda
1262      SKIP_ALL_TESTS: 1
1263      DESIRED_PYTHON: "3.9"
1264      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
1265    steps:
1266      - name: Display EC2 information
1267        shell: bash
1268        run: |
1269          set -euo pipefail
1270          function get_ec2_metadata() {
1271            # Pulled from instance metadata endpoint for EC2
1272            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
1273            category=$1
1274            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
1275          }
1276          echo "ami-id: $(get_ec2_metadata ami-id)"
1277          echo "instance-id: $(get_ec2_metadata instance-id)"
1278          echo "instance-type: $(get_ec2_metadata instance-type)"
1279          echo "system info $(uname -a)"
1280      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
1281        uses: pytorch/test-infra/.github/actions/setup-ssh@main
1282        continue-on-error: true
1283        with:
1284          github-secret: ${{ secrets.GITHUB_TOKEN }}
1285      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
1286      - name: Enable long paths on Windows
1287        shell: powershell
1288        run: |
1289          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
1290      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
1291      # removed once Windows Defender is removed from the AMI
1292      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
1293        continue-on-error: true
1294        shell: powershell
1295        run: |
1296          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
1297          # Let's both exclude the path and disable Windows Defender completely just to be sure
1298          # that it doesn't interfere
1299          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
1300      # NOTE: These environment variables are put here so that they can be applied on every job equally
1301      #       They are also here because setting them at a workflow level doesn't give us access to the
1302      #       runner.temp variable, which we need.
1303      - name: Populate binary env
1304        shell: bash
1305        run: |
1306          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
1307          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
1308          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
1309      - name: Checkout PyTorch
1310        uses: malfet/checkout@silent-checkout
1311        with:
1312          submodules: recursive
1313          path: pytorch
1314          quiet-checkout: true
1315      - name: Clean PyTorch checkout
1316        run: |
1317          # Remove any artifacts from the previous checkouts
1318          git clean -fxd
1319        working-directory: pytorch
1320      - name: Checkout pytorch/builder
1321        uses: malfet/checkout@silent-checkout
1322        with:
1323          ref: release/2.4
1324          submodules: recursive
1325          repository: pytorch/builder
1326          path: builder
1327          quiet-checkout: true
1328      - name: Clean pytorch/builder checkout
1329        run: |
1330          # Remove any artifacts from the previous checkouts
1331          git clean -fxd
1332        working-directory: builder
1333      - name: Populate binary env
1334        shell: bash
1335        run: |
1336          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
1337      - name: Build PyTorch binary
1338        shell: bash
1339        run: |
1340          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
1341      - uses: actions/upload-artifact@v3
1342        if: always()
1343        with:
1344          name: wheel-py3_9-cuda11_8
1345          retention-days: 14
1346          if-no-files-found: error
1347          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
1348      - name: Wait until all sessions have drained
1349        shell: powershell
1350        working-directory: pytorch
1351        if: always()
1352        timeout-minutes: 120
1353        run: |
1354          .github\scripts\wait_for_ssh_to_drain.ps1
1355      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
1356        shell: powershell
1357        working-directory: pytorch
1358        if: always()
1359        run: |
1360          .github\scripts\kill_active_ssh_sessions.ps1
1361  wheel-py3_9-cuda11_8-test:  # Testing
1362    if: ${{ github.repository_owner == 'pytorch' }}
1363    needs: wheel-py3_9-cuda11_8-build
1364    runs-on: windows.8xlarge.nvidia.gpu
1365    timeout-minutes: 240
1366    env:
1367      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1368      BUILDER_ROOT: ${{ github.workspace }}/builder
1369      PACKAGE_TYPE: wheel
1370      # TODO: This is a legacy variable that we eventually want to get rid of in
1371      #       favor of GPU_ARCH_VERSION
1372      DESIRED_CUDA: cu118
1373      GPU_ARCH_VERSION: 11.8
1374      GPU_ARCH_TYPE: cuda
1375      SKIP_ALL_TESTS: 1
1376      DESIRED_PYTHON: "3.9"
1377    steps:
1378      - name: Display EC2 information
1379        shell: bash
1380        run: |
1381          set -euo pipefail
1382          function get_ec2_metadata() {
1383            # Pulled from instance metadata endpoint for EC2
1384            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
1385            category=$1
1386            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
1387          }
1388          echo "ami-id: $(get_ec2_metadata ami-id)"
1389          echo "instance-id: $(get_ec2_metadata instance-id)"
1390          echo "instance-type: $(get_ec2_metadata instance-type)"
1391          echo "system info $(uname -a)"
1392      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
1393        uses: pytorch/test-infra/.github/actions/setup-ssh@main
1394        continue-on-error: true
1395        with:
1396          github-secret: ${{ secrets.GITHUB_TOKEN }}
1397      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
1398      - name: Enable long paths on Windows
1399        shell: powershell
1400        run: |
1401          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
1402      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
1403      # removed once Windows Defender is removed from the AMI
1404      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
1405        continue-on-error: true
1406        shell: powershell
1407        run: |
1408          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
1409          # Let's both exclude the path and disable Windows Defender completely just to be sure
1410          # that it doesn't interfere
1411          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
1412      # NOTE: These environment variables are put here so that they can be applied on every job equally
1413      #       They are also here because setting them at a workflow level doesn't give us access to the
1414      #       runner.temp variable, which we need.
1415      - name: Populate binary env
1416        shell: bash
1417        run: |
1418          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
1419          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
1420          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
1421      - uses: actions/download-artifact@v3
1422        name: Download Build Artifacts
1423        with:
1424          name: wheel-py3_9-cuda11_8
1425          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
1426      - name: Checkout PyTorch
1427        uses: malfet/checkout@silent-checkout
1428        with:
1429          submodules: recursive
1430          path: pytorch
1431          quiet-checkout: true
1432      - name: Clean PyTorch checkout
1433        run: |
1434          # Remove any artifacts from the previous checkouts
1435          git clean -fxd
1436        working-directory: pytorch
1437      - name: Checkout pytorch/builder
1438        uses: malfet/checkout@silent-checkout
1439        with:
1440          ref: release/2.4
1441          submodules: recursive
1442          repository: pytorch/builder
1443          path: builder
1444          quiet-checkout: true
1445      - name: Clean pytorch/builder checkout
1446        run: |
1447          # Remove any artifacts from the previous checkouts
1448          git clean -fxd
1449        working-directory: builder
1450      - name: Populate binary env
1451        shell: bash
1452        run: |
1453          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
1454      - name: Test PyTorch binary
1455        shell: bash
1456        run: |
1457          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
1458      - name: Wait until all sessions have drained
1459        shell: powershell
1460        working-directory: pytorch
1461        if: always()
1462        timeout-minutes: 120
1463        run: |
1464          .github\scripts\wait_for_ssh_to_drain.ps1
1465      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
1466        shell: powershell
1467        working-directory: pytorch
1468        if: always()
1469        run: |
1470          .github\scripts\kill_active_ssh_sessions.ps1
1471  wheel-py3_9-cuda11_8-upload:  # Uploading
1472    if: ${{ github.repository_owner == 'pytorch' }}
1473    permissions:
1474      id-token: write
1475      contents: read
1476    needs: wheel-py3_9-cuda11_8-test
1477    with:
1478      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1479      BUILDER_ROOT: ${{ github.workspace }}/builder
1480      PACKAGE_TYPE: wheel
1481      # TODO: This is a legacy variable that we eventually want to get rid of in
1482      #       favor of GPU_ARCH_VERSION
1483      DESIRED_CUDA: cu118
1484      GPU_ARCH_VERSION: 11.8
1485      GPU_ARCH_TYPE: cuda
1486      DESIRED_PYTHON: "3.9"
1487      build_name: wheel-py3_9-cuda11_8
1488    secrets:
1489      github-token: ${{ secrets.GITHUB_TOKEN }}
1490      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
1491      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
1492    uses: ./.github/workflows/_binary-upload.yml
1493  wheel-py3_9-cuda12_1-build:
1494    if: ${{ github.repository_owner == 'pytorch' }}
1495    runs-on: windows.4xlarge
1496    timeout-minutes: 240
1497    env:
1498      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1499      BUILDER_ROOT: ${{ github.workspace }}/builder
1500      PACKAGE_TYPE: wheel
1501      # TODO: This is a legacy variable that we eventually want to get rid of in
1502      #       favor of GPU_ARCH_VERSION
1503      DESIRED_CUDA: cu121
1504      GPU_ARCH_VERSION: 12.1
1505      GPU_ARCH_TYPE: cuda
1506      SKIP_ALL_TESTS: 1
1507      DESIRED_PYTHON: "3.9"
1508      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
1509    steps:
1510      - name: Display EC2 information
1511        shell: bash
1512        run: |
1513          set -euo pipefail
1514          function get_ec2_metadata() {
1515            # Pulled from instance metadata endpoint for EC2
1516            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
1517            category=$1
1518            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
1519          }
1520          echo "ami-id: $(get_ec2_metadata ami-id)"
1521          echo "instance-id: $(get_ec2_metadata instance-id)"
1522          echo "instance-type: $(get_ec2_metadata instance-type)"
1523          echo "system info $(uname -a)"
1524      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
1525        uses: pytorch/test-infra/.github/actions/setup-ssh@main
1526        continue-on-error: true
1527        with:
1528          github-secret: ${{ secrets.GITHUB_TOKEN }}
1529      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
1530      - name: Enable long paths on Windows
1531        shell: powershell
1532        run: |
1533          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
1534      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
1535      # removed once Windows Defender is removed from the AMI
1536      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
1537        continue-on-error: true
1538        shell: powershell
1539        run: |
1540          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
1541          # Let's both exclude the path and disable Windows Defender completely just to be sure
1542          # that it doesn't interfere
1543          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
1544      # NOTE: These environment variables are put here so that they can be applied on every job equally
1545      #       They are also here because setting them at a workflow level doesn't give us access to the
1546      #       runner.temp variable, which we need.
1547      - name: Populate binary env
1548        shell: bash
1549        run: |
1550          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
1551          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
1552          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
1553      - name: Checkout PyTorch
1554        uses: malfet/checkout@silent-checkout
1555        with:
1556          submodules: recursive
1557          path: pytorch
1558          quiet-checkout: true
1559      - name: Clean PyTorch checkout
1560        run: |
1561          # Remove any artifacts from the previous checkouts
1562          git clean -fxd
1563        working-directory: pytorch
1564      - name: Checkout pytorch/builder
1565        uses: malfet/checkout@silent-checkout
1566        with:
1567          ref: release/2.4
1568          submodules: recursive
1569          repository: pytorch/builder
1570          path: builder
1571          quiet-checkout: true
1572      - name: Clean pytorch/builder checkout
1573        run: |
1574          # Remove any artifacts from the previous checkouts
1575          git clean -fxd
1576        working-directory: builder
1577      - name: Populate binary env
1578        shell: bash
1579        run: |
1580          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
1581      - name: Build PyTorch binary
1582        shell: bash
1583        run: |
1584          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
1585      - uses: actions/upload-artifact@v3
1586        if: always()
1587        with:
1588          name: wheel-py3_9-cuda12_1
1589          retention-days: 14
1590          if-no-files-found: error
1591          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
1592      - name: Wait until all sessions have drained
1593        shell: powershell
1594        working-directory: pytorch
1595        if: always()
1596        timeout-minutes: 120
1597        run: |
1598          .github\scripts\wait_for_ssh_to_drain.ps1
1599      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
1600        shell: powershell
1601        working-directory: pytorch
1602        if: always()
1603        run: |
1604          .github\scripts\kill_active_ssh_sessions.ps1
1605  wheel-py3_9-cuda12_1-test:  # Testing
1606    if: ${{ github.repository_owner == 'pytorch' }}
1607    needs: wheel-py3_9-cuda12_1-build
1608    runs-on: windows.8xlarge.nvidia.gpu
1609    timeout-minutes: 240
1610    env:
1611      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1612      BUILDER_ROOT: ${{ github.workspace }}/builder
1613      PACKAGE_TYPE: wheel
1614      # TODO: This is a legacy variable that we eventually want to get rid of in
1615      #       favor of GPU_ARCH_VERSION
1616      DESIRED_CUDA: cu121
1617      GPU_ARCH_VERSION: 12.1
1618      GPU_ARCH_TYPE: cuda
1619      SKIP_ALL_TESTS: 1
1620      DESIRED_PYTHON: "3.9"
1621    steps:
1622      - name: Display EC2 information
1623        shell: bash
1624        run: |
1625          set -euo pipefail
1626          function get_ec2_metadata() {
1627            # Pulled from instance metadata endpoint for EC2
1628            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
1629            category=$1
1630            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
1631          }
1632          echo "ami-id: $(get_ec2_metadata ami-id)"
1633          echo "instance-id: $(get_ec2_metadata instance-id)"
1634          echo "instance-type: $(get_ec2_metadata instance-type)"
1635          echo "system info $(uname -a)"
1636      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
1637        uses: pytorch/test-infra/.github/actions/setup-ssh@main
1638        continue-on-error: true
1639        with:
1640          github-secret: ${{ secrets.GITHUB_TOKEN }}
1641      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
1642      - name: Enable long paths on Windows
1643        shell: powershell
1644        run: |
1645          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
1646      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
1647      # removed once Windows Defender is removed from the AMI
1648      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
1649        continue-on-error: true
1650        shell: powershell
1651        run: |
1652          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
1653          # Let's both exclude the path and disable Windows Defender completely just to be sure
1654          # that it doesn't interfere
1655          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
1656      # NOTE: These environment variables are put here so that they can be applied on every job equally
1657      #       They are also here because setting them at a workflow level doesn't give us access to the
1658      #       runner.temp variable, which we need.
1659      - name: Populate binary env
1660        shell: bash
1661        run: |
1662          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
1663          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
1664          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
1665      - uses: actions/download-artifact@v3
1666        name: Download Build Artifacts
1667        with:
1668          name: wheel-py3_9-cuda12_1
1669          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
1670      - name: Checkout PyTorch
1671        uses: malfet/checkout@silent-checkout
1672        with:
1673          submodules: recursive
1674          path: pytorch
1675          quiet-checkout: true
1676      - name: Clean PyTorch checkout
1677        run: |
1678          # Remove any artifacts from the previous checkouts
1679          git clean -fxd
1680        working-directory: pytorch
1681      - name: Checkout pytorch/builder
1682        uses: malfet/checkout@silent-checkout
1683        with:
1684          ref: release/2.4
1685          submodules: recursive
1686          repository: pytorch/builder
1687          path: builder
1688          quiet-checkout: true
1689      - name: Clean pytorch/builder checkout
1690        run: |
1691          # Remove any artifacts from the previous checkouts
1692          git clean -fxd
1693        working-directory: builder
1694      - name: Populate binary env
1695        shell: bash
1696        run: |
1697          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
1698      - name: Test PyTorch binary
1699        shell: bash
1700        run: |
1701          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
1702      - name: Wait until all sessions have drained
1703        shell: powershell
1704        working-directory: pytorch
1705        if: always()
1706        timeout-minutes: 120
1707        run: |
1708          .github\scripts\wait_for_ssh_to_drain.ps1
1709      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
1710        shell: powershell
1711        working-directory: pytorch
1712        if: always()
1713        run: |
1714          .github\scripts\kill_active_ssh_sessions.ps1
1715  wheel-py3_9-cuda12_1-upload:  # Uploading
1716    if: ${{ github.repository_owner == 'pytorch' }}
1717    permissions:
1718      id-token: write
1719      contents: read
1720    needs: wheel-py3_9-cuda12_1-test
1721    with:
1722      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1723      BUILDER_ROOT: ${{ github.workspace }}/builder
1724      PACKAGE_TYPE: wheel
1725      # TODO: This is a legacy variable that we eventually want to get rid of in
1726      #       favor of GPU_ARCH_VERSION
1727      DESIRED_CUDA: cu121
1728      GPU_ARCH_VERSION: 12.1
1729      GPU_ARCH_TYPE: cuda
1730      DESIRED_PYTHON: "3.9"
1731      build_name: wheel-py3_9-cuda12_1
1732    secrets:
1733      github-token: ${{ secrets.GITHUB_TOKEN }}
1734      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
1735      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
1736    uses: ./.github/workflows/_binary-upload.yml
1737  wheel-py3_9-cuda12_4-build:
1738    if: ${{ github.repository_owner == 'pytorch' }}
1739    runs-on: windows.4xlarge
1740    timeout-minutes: 240
1741    env:
1742      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1743      BUILDER_ROOT: ${{ github.workspace }}/builder
1744      PACKAGE_TYPE: wheel
1745      # TODO: This is a legacy variable that we eventually want to get rid of in
1746      #       favor of GPU_ARCH_VERSION
1747      DESIRED_CUDA: cu124
1748      GPU_ARCH_VERSION: 12.4
1749      GPU_ARCH_TYPE: cuda
1750      SKIP_ALL_TESTS: 1
1751      DESIRED_PYTHON: "3.9"
1752      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
1753    steps:
1754      - name: Display EC2 information
1755        shell: bash
1756        run: |
1757          set -euo pipefail
1758          function get_ec2_metadata() {
1759            # Pulled from instance metadata endpoint for EC2
1760            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
1761            category=$1
1762            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
1763          }
1764          echo "ami-id: $(get_ec2_metadata ami-id)"
1765          echo "instance-id: $(get_ec2_metadata instance-id)"
1766          echo "instance-type: $(get_ec2_metadata instance-type)"
1767          echo "system info $(uname -a)"
1768      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
1769        uses: pytorch/test-infra/.github/actions/setup-ssh@main
1770        continue-on-error: true
1771        with:
1772          github-secret: ${{ secrets.GITHUB_TOKEN }}
1773      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
1774      - name: Enable long paths on Windows
1775        shell: powershell
1776        run: |
1777          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
1778      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
1779      # removed once Windows Defender is removed from the AMI
1780      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
1781        continue-on-error: true
1782        shell: powershell
1783        run: |
1784          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
1785          # Let's both exclude the path and disable Windows Defender completely just to be sure
1786          # that it doesn't interfere
1787          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
1788      # NOTE: These environment variables are put here so that they can be applied on every job equally
1789      #       They are also here because setting them at a workflow level doesn't give us access to the
1790      #       runner.temp variable, which we need.
1791      - name: Populate binary env
1792        shell: bash
1793        run: |
1794          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
1795          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
1796          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
1797      - name: Checkout PyTorch
1798        uses: malfet/checkout@silent-checkout
1799        with:
1800          submodules: recursive
1801          path: pytorch
1802          quiet-checkout: true
1803      - name: Clean PyTorch checkout
1804        run: |
1805          # Remove any artifacts from the previous checkouts
1806          git clean -fxd
1807        working-directory: pytorch
1808      - name: Checkout pytorch/builder
1809        uses: malfet/checkout@silent-checkout
1810        with:
1811          ref: release/2.4
1812          submodules: recursive
1813          repository: pytorch/builder
1814          path: builder
1815          quiet-checkout: true
1816      - name: Clean pytorch/builder checkout
1817        run: |
1818          # Remove any artifacts from the previous checkouts
1819          git clean -fxd
1820        working-directory: builder
1821      - name: Populate binary env
1822        shell: bash
1823        run: |
1824          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
1825      - name: Build PyTorch binary
1826        shell: bash
1827        run: |
1828          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
1829      - uses: actions/upload-artifact@v3
1830        if: always()
1831        with:
1832          name: wheel-py3_9-cuda12_4
1833          retention-days: 14
1834          if-no-files-found: error
1835          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
1836      - name: Wait until all sessions have drained
1837        shell: powershell
1838        working-directory: pytorch
1839        if: always()
1840        timeout-minutes: 120
1841        run: |
1842          .github\scripts\wait_for_ssh_to_drain.ps1
1843      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
1844        shell: powershell
1845        working-directory: pytorch
1846        if: always()
1847        run: |
1848          .github\scripts\kill_active_ssh_sessions.ps1
1849  wheel-py3_9-cuda12_4-test:  # Testing
1850    if: ${{ github.repository_owner == 'pytorch' }}
1851    needs: wheel-py3_9-cuda12_4-build
1852    runs-on: windows.8xlarge.nvidia.gpu
1853    timeout-minutes: 240
1854    env:
1855      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1856      BUILDER_ROOT: ${{ github.workspace }}/builder
1857      PACKAGE_TYPE: wheel
1858      # TODO: This is a legacy variable that we eventually want to get rid of in
1859      #       favor of GPU_ARCH_VERSION
1860      DESIRED_CUDA: cu124
1861      GPU_ARCH_VERSION: 12.4
1862      GPU_ARCH_TYPE: cuda
1863      SKIP_ALL_TESTS: 1
1864      DESIRED_PYTHON: "3.9"
1865    steps:
1866      - name: Display EC2 information
1867        shell: bash
1868        run: |
1869          set -euo pipefail
1870          function get_ec2_metadata() {
1871            # Pulled from instance metadata endpoint for EC2
1872            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
1873            category=$1
1874            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
1875          }
1876          echo "ami-id: $(get_ec2_metadata ami-id)"
1877          echo "instance-id: $(get_ec2_metadata instance-id)"
1878          echo "instance-type: $(get_ec2_metadata instance-type)"
1879          echo "system info $(uname -a)"
1880      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
1881        uses: pytorch/test-infra/.github/actions/setup-ssh@main
1882        continue-on-error: true
1883        with:
1884          github-secret: ${{ secrets.GITHUB_TOKEN }}
1885      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
1886      - name: Enable long paths on Windows
1887        shell: powershell
1888        run: |
1889          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
1890      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
1891      # removed once Windows Defender is removed from the AMI
1892      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
1893        continue-on-error: true
1894        shell: powershell
1895        run: |
1896          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
1897          # Let's both exclude the path and disable Windows Defender completely just to be sure
1898          # that it doesn't interfere
1899          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
1900      # NOTE: These environment variables are put here so that they can be applied on every job equally
1901      #       They are also here because setting them at a workflow level doesn't give us access to the
1902      #       runner.temp variable, which we need.
1903      - name: Populate binary env
1904        shell: bash
1905        run: |
1906          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
1907          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
1908          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
1909      - uses: actions/download-artifact@v3
1910        name: Download Build Artifacts
1911        with:
1912          name: wheel-py3_9-cuda12_4
1913          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
1914      - name: Checkout PyTorch
1915        uses: malfet/checkout@silent-checkout
1916        with:
1917          submodules: recursive
1918          path: pytorch
1919          quiet-checkout: true
1920      - name: Clean PyTorch checkout
1921        run: |
1922          # Remove any artifacts from the previous checkouts
1923          git clean -fxd
1924        working-directory: pytorch
1925      - name: Checkout pytorch/builder
1926        uses: malfet/checkout@silent-checkout
1927        with:
1928          ref: release/2.4
1929          submodules: recursive
1930          repository: pytorch/builder
1931          path: builder
1932          quiet-checkout: true
1933      - name: Clean pytorch/builder checkout
1934        run: |
1935          # Remove any artifacts from the previous checkouts
1936          git clean -fxd
1937        working-directory: builder
1938      - name: Populate binary env
1939        shell: bash
1940        run: |
1941          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
1942      - name: Test PyTorch binary
1943        shell: bash
1944        run: |
1945          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
1946      - name: Wait until all sessions have drained
1947        shell: powershell
1948        working-directory: pytorch
1949        if: always()
1950        timeout-minutes: 120
1951        run: |
1952          .github\scripts\wait_for_ssh_to_drain.ps1
1953      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
1954        shell: powershell
1955        working-directory: pytorch
1956        if: always()
1957        run: |
1958          .github\scripts\kill_active_ssh_sessions.ps1
1959  wheel-py3_9-cuda12_4-upload:  # Uploading
1960    if: ${{ github.repository_owner == 'pytorch' }}
1961    permissions:
1962      id-token: write
1963      contents: read
1964    needs: wheel-py3_9-cuda12_4-test
1965    with:
1966      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1967      BUILDER_ROOT: ${{ github.workspace }}/builder
1968      PACKAGE_TYPE: wheel
1969      # TODO: This is a legacy variable that we eventually want to get rid of in
1970      #       favor of GPU_ARCH_VERSION
1971      DESIRED_CUDA: cu124
1972      GPU_ARCH_VERSION: 12.4
1973      GPU_ARCH_TYPE: cuda
1974      DESIRED_PYTHON: "3.9"
1975      build_name: wheel-py3_9-cuda12_4
1976    secrets:
1977      github-token: ${{ secrets.GITHUB_TOKEN }}
1978      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
1979      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
1980    uses: ./.github/workflows/_binary-upload.yml
1981  wheel-py3_10-cpu-build:
1982    if: ${{ github.repository_owner == 'pytorch' }}
1983    runs-on: windows.4xlarge
1984    timeout-minutes: 240
1985    env:
1986      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
1987      BUILDER_ROOT: ${{ github.workspace }}/builder
1988      PACKAGE_TYPE: wheel
1989      # TODO: This is a legacy variable that we eventually want to get rid of in
1990      #       favor of GPU_ARCH_VERSION
1991      DESIRED_CUDA: cpu
1992      GPU_ARCH_TYPE: cpu
1993      SKIP_ALL_TESTS: 1
1994      DESIRED_PYTHON: "3.10"
1995      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
1996    steps:
1997      - name: Display EC2 information
1998        shell: bash
1999        run: |
2000          set -euo pipefail
2001          function get_ec2_metadata() {
2002            # Pulled from instance metadata endpoint for EC2
2003            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
2004            category=$1
2005            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
2006          }
2007          echo "ami-id: $(get_ec2_metadata ami-id)"
2008          echo "instance-id: $(get_ec2_metadata instance-id)"
2009          echo "instance-type: $(get_ec2_metadata instance-type)"
2010          echo "system info $(uname -a)"
2011      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
2012        uses: pytorch/test-infra/.github/actions/setup-ssh@main
2013        continue-on-error: true
2014        with:
2015          github-secret: ${{ secrets.GITHUB_TOKEN }}
2016      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
2017      - name: Enable long paths on Windows
2018        shell: powershell
2019        run: |
2020          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
2021      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
2022      # removed once Windows Defender is removed from the AMI
2023      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
2024        continue-on-error: true
2025        shell: powershell
2026        run: |
2027          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
2028          # Let's both exclude the path and disable Windows Defender completely just to be sure
2029          # that it doesn't interfere
2030          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
2031      # NOTE: These environment variables are put here so that they can be applied on every job equally
2032      #       They are also here because setting them at a workflow level doesn't give us access to the
2033      #       runner.temp variable, which we need.
2034      - name: Populate binary env
2035        shell: bash
2036        run: |
2037          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
2038          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
2039          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
2040      - name: Checkout PyTorch
2041        uses: malfet/checkout@silent-checkout
2042        with:
2043          submodules: recursive
2044          path: pytorch
2045          quiet-checkout: true
2046      - name: Clean PyTorch checkout
2047        run: |
2048          # Remove any artifacts from the previous checkouts
2049          git clean -fxd
2050        working-directory: pytorch
2051      - name: Checkout pytorch/builder
2052        uses: malfet/checkout@silent-checkout
2053        with:
2054          ref: release/2.4
2055          submodules: recursive
2056          repository: pytorch/builder
2057          path: builder
2058          quiet-checkout: true
2059      - name: Clean pytorch/builder checkout
2060        run: |
2061          # Remove any artifacts from the previous checkouts
2062          git clean -fxd
2063        working-directory: builder
2064      - name: Populate binary env
2065        shell: bash
2066        run: |
2067          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
2068      - name: Build PyTorch binary
2069        shell: bash
2070        run: |
2071          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
2072      - uses: actions/upload-artifact@v3
2073        if: always()
2074        with:
2075          name: wheel-py3_10-cpu
2076          retention-days: 14
2077          if-no-files-found: error
2078          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
2079      - name: Wait until all sessions have drained
2080        shell: powershell
2081        working-directory: pytorch
2082        if: always()
2083        timeout-minutes: 120
2084        run: |
2085          .github\scripts\wait_for_ssh_to_drain.ps1
2086      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
2087        shell: powershell
2088        working-directory: pytorch
2089        if: always()
2090        run: |
2091          .github\scripts\kill_active_ssh_sessions.ps1
2092  wheel-py3_10-cpu-test:  # Testing
2093    if: ${{ github.repository_owner == 'pytorch' }}
2094    needs: wheel-py3_10-cpu-build
2095    runs-on: windows.4xlarge.nonephemeral
2096    timeout-minutes: 240
2097    env:
2098      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
2099      BUILDER_ROOT: ${{ github.workspace }}/builder
2100      PACKAGE_TYPE: wheel
2101      # TODO: This is a legacy variable that we eventually want to get rid of in
2102      #       favor of GPU_ARCH_VERSION
2103      DESIRED_CUDA: cpu
2104      GPU_ARCH_TYPE: cpu
2105      SKIP_ALL_TESTS: 1
2106      DESIRED_PYTHON: "3.10"
2107    steps:
2108      - name: Display EC2 information
2109        shell: bash
2110        run: |
2111          set -euo pipefail
2112          function get_ec2_metadata() {
2113            # Pulled from instance metadata endpoint for EC2
2114            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
2115            category=$1
2116            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
2117          }
2118          echo "ami-id: $(get_ec2_metadata ami-id)"
2119          echo "instance-id: $(get_ec2_metadata instance-id)"
2120          echo "instance-type: $(get_ec2_metadata instance-type)"
2121          echo "system info $(uname -a)"
2122      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
2123        uses: pytorch/test-infra/.github/actions/setup-ssh@main
2124        continue-on-error: true
2125        with:
2126          github-secret: ${{ secrets.GITHUB_TOKEN }}
2127      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
2128      - name: Enable long paths on Windows
2129        shell: powershell
2130        run: |
2131          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
2132      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
2133      # removed once Windows Defender is removed from the AMI
2134      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
2135        continue-on-error: true
2136        shell: powershell
2137        run: |
2138          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
2139          # Let's both exclude the path and disable Windows Defender completely just to be sure
2140          # that it doesn't interfere
2141          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
2142      # NOTE: These environment variables are put here so that they can be applied on every job equally
2143      #       They are also here because setting them at a workflow level doesn't give us access to the
2144      #       runner.temp variable, which we need.
2145      - name: Populate binary env
2146        shell: bash
2147        run: |
2148          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
2149          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
2150          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
2151      - uses: actions/download-artifact@v3
2152        name: Download Build Artifacts
2153        with:
2154          name: wheel-py3_10-cpu
2155          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
2156      - name: Checkout PyTorch
2157        uses: malfet/checkout@silent-checkout
2158        with:
2159          submodules: recursive
2160          path: pytorch
2161          quiet-checkout: true
2162      - name: Clean PyTorch checkout
2163        run: |
2164          # Remove any artifacts from the previous checkouts
2165          git clean -fxd
2166        working-directory: pytorch
2167      - name: Checkout pytorch/builder
2168        uses: malfet/checkout@silent-checkout
2169        with:
2170          ref: release/2.4
2171          submodules: recursive
2172          repository: pytorch/builder
2173          path: builder
2174          quiet-checkout: true
2175      - name: Clean pytorch/builder checkout
2176        run: |
2177          # Remove any artifacts from the previous checkouts
2178          git clean -fxd
2179        working-directory: builder
2180      - name: Populate binary env
2181        shell: bash
2182        run: |
2183          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
2184      - name: Test PyTorch binary
2185        shell: bash
2186        run: |
2187          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
2188      - name: Wait until all sessions have drained
2189        shell: powershell
2190        working-directory: pytorch
2191        if: always()
2192        timeout-minutes: 120
2193        run: |
2194          .github\scripts\wait_for_ssh_to_drain.ps1
2195      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
2196        shell: powershell
2197        working-directory: pytorch
2198        if: always()
2199        run: |
2200          .github\scripts\kill_active_ssh_sessions.ps1
2201  wheel-py3_10-cpu-upload:  # Uploading
2202    if: ${{ github.repository_owner == 'pytorch' }}
2203    permissions:
2204      id-token: write
2205      contents: read
2206    needs: wheel-py3_10-cpu-test
2207    with:
2208      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
2209      BUILDER_ROOT: ${{ github.workspace }}/builder
2210      PACKAGE_TYPE: wheel
2211      # TODO: This is a legacy variable that we eventually want to get rid of in
2212      #       favor of GPU_ARCH_VERSION
2213      DESIRED_CUDA: cpu
2214      GPU_ARCH_TYPE: cpu
2215      DESIRED_PYTHON: "3.10"
2216      build_name: wheel-py3_10-cpu
2217    secrets:
2218      github-token: ${{ secrets.GITHUB_TOKEN }}
2219      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
2220      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
2221    uses: ./.github/workflows/_binary-upload.yml
2222  wheel-py3_10-cuda11_8-build:
2223    if: ${{ github.repository_owner == 'pytorch' }}
2224    runs-on: windows.4xlarge
2225    timeout-minutes: 240
2226    env:
2227      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
2228      BUILDER_ROOT: ${{ github.workspace }}/builder
2229      PACKAGE_TYPE: wheel
2230      # TODO: This is a legacy variable that we eventually want to get rid of in
2231      #       favor of GPU_ARCH_VERSION
2232      DESIRED_CUDA: cu118
2233      GPU_ARCH_VERSION: 11.8
2234      GPU_ARCH_TYPE: cuda
2235      SKIP_ALL_TESTS: 1
2236      DESIRED_PYTHON: "3.10"
2237      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
2238    steps:
2239      - name: Display EC2 information
2240        shell: bash
2241        run: |
2242          set -euo pipefail
2243          function get_ec2_metadata() {
2244            # Pulled from instance metadata endpoint for EC2
2245            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
2246            category=$1
2247            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
2248          }
2249          echo "ami-id: $(get_ec2_metadata ami-id)"
2250          echo "instance-id: $(get_ec2_metadata instance-id)"
2251          echo "instance-type: $(get_ec2_metadata instance-type)"
2252          echo "system info $(uname -a)"
2253      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
2254        uses: pytorch/test-infra/.github/actions/setup-ssh@main
2255        continue-on-error: true
2256        with:
2257          github-secret: ${{ secrets.GITHUB_TOKEN }}
2258      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
2259      - name: Enable long paths on Windows
2260        shell: powershell
2261        run: |
2262          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
2263      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
2264      # removed once Windows Defender is removed from the AMI
2265      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
2266        continue-on-error: true
2267        shell: powershell
2268        run: |
2269          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
2270          # Let's both exclude the path and disable Windows Defender completely just to be sure
2271          # that it doesn't interfere
2272          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
2273      # NOTE: These environment variables are put here so that they can be applied on every job equally
2274      #       They are also here because setting them at a workflow level doesn't give us access to the
2275      #       runner.temp variable, which we need.
2276      - name: Populate binary env
2277        shell: bash
2278        run: |
2279          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
2280          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
2281          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
2282      - name: Checkout PyTorch
2283        uses: malfet/checkout@silent-checkout
2284        with:
2285          submodules: recursive
2286          path: pytorch
2287          quiet-checkout: true
2288      - name: Clean PyTorch checkout
2289        run: |
2290          # Remove any artifacts from the previous checkouts
2291          git clean -fxd
2292        working-directory: pytorch
2293      - name: Checkout pytorch/builder
2294        uses: malfet/checkout@silent-checkout
2295        with:
2296          ref: release/2.4
2297          submodules: recursive
2298          repository: pytorch/builder
2299          path: builder
2300          quiet-checkout: true
2301      - name: Clean pytorch/builder checkout
2302        run: |
2303          # Remove any artifacts from the previous checkouts
2304          git clean -fxd
2305        working-directory: builder
2306      - name: Populate binary env
2307        shell: bash
2308        run: |
2309          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
2310      - name: Build PyTorch binary
2311        shell: bash
2312        run: |
2313          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
2314      - uses: actions/upload-artifact@v3
2315        if: always()
2316        with:
2317          name: wheel-py3_10-cuda11_8
2318          retention-days: 14
2319          if-no-files-found: error
2320          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
2321      - name: Wait until all sessions have drained
2322        shell: powershell
2323        working-directory: pytorch
2324        if: always()
2325        timeout-minutes: 120
2326        run: |
2327          .github\scripts\wait_for_ssh_to_drain.ps1
2328      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
2329        shell: powershell
2330        working-directory: pytorch
2331        if: always()
2332        run: |
2333          .github\scripts\kill_active_ssh_sessions.ps1
2334  wheel-py3_10-cuda11_8-test:  # Testing
2335    if: ${{ github.repository_owner == 'pytorch' }}
2336    needs: wheel-py3_10-cuda11_8-build
2337    runs-on: windows.8xlarge.nvidia.gpu
2338    timeout-minutes: 240
2339    env:
2340      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
2341      BUILDER_ROOT: ${{ github.workspace }}/builder
2342      PACKAGE_TYPE: wheel
2343      # TODO: This is a legacy variable that we eventually want to get rid of in
2344      #       favor of GPU_ARCH_VERSION
2345      DESIRED_CUDA: cu118
2346      GPU_ARCH_VERSION: 11.8
2347      GPU_ARCH_TYPE: cuda
2348      SKIP_ALL_TESTS: 1
2349      DESIRED_PYTHON: "3.10"
2350    steps:
2351      - name: Display EC2 information
2352        shell: bash
2353        run: |
2354          set -euo pipefail
2355          function get_ec2_metadata() {
2356            # Pulled from instance metadata endpoint for EC2
2357            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
2358            category=$1
2359            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
2360          }
2361          echo "ami-id: $(get_ec2_metadata ami-id)"
2362          echo "instance-id: $(get_ec2_metadata instance-id)"
2363          echo "instance-type: $(get_ec2_metadata instance-type)"
2364          echo "system info $(uname -a)"
2365      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
2366        uses: pytorch/test-infra/.github/actions/setup-ssh@main
2367        continue-on-error: true
2368        with:
2369          github-secret: ${{ secrets.GITHUB_TOKEN }}
2370      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
2371      - name: Enable long paths on Windows
2372        shell: powershell
2373        run: |
2374          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
2375      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
2376      # removed once Windows Defender is removed from the AMI
2377      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
2378        continue-on-error: true
2379        shell: powershell
2380        run: |
2381          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
2382          # Let's both exclude the path and disable Windows Defender completely just to be sure
2383          # that it doesn't interfere
2384          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
2385      # NOTE: These environment variables are put here so that they can be applied on every job equally
2386      #       They are also here because setting them at a workflow level doesn't give us access to the
2387      #       runner.temp variable, which we need.
2388      - name: Populate binary env
2389        shell: bash
2390        run: |
2391          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
2392          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
2393          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
2394      - uses: actions/download-artifact@v3
2395        name: Download Build Artifacts
2396        with:
2397          name: wheel-py3_10-cuda11_8
2398          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
2399      - name: Checkout PyTorch
2400        uses: malfet/checkout@silent-checkout
2401        with:
2402          submodules: recursive
2403          path: pytorch
2404          quiet-checkout: true
2405      - name: Clean PyTorch checkout
2406        run: |
2407          # Remove any artifacts from the previous checkouts
2408          git clean -fxd
2409        working-directory: pytorch
2410      - name: Checkout pytorch/builder
2411        uses: malfet/checkout@silent-checkout
2412        with:
2413          ref: release/2.4
2414          submodules: recursive
2415          repository: pytorch/builder
2416          path: builder
2417          quiet-checkout: true
2418      - name: Clean pytorch/builder checkout
2419        run: |
2420          # Remove any artifacts from the previous checkouts
2421          git clean -fxd
2422        working-directory: builder
2423      - name: Populate binary env
2424        shell: bash
2425        run: |
2426          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
2427      - name: Test PyTorch binary
2428        shell: bash
2429        run: |
2430          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
2431      - name: Wait until all sessions have drained
2432        shell: powershell
2433        working-directory: pytorch
2434        if: always()
2435        timeout-minutes: 120
2436        run: |
2437          .github\scripts\wait_for_ssh_to_drain.ps1
2438      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
2439        shell: powershell
2440        working-directory: pytorch
2441        if: always()
2442        run: |
2443          .github\scripts\kill_active_ssh_sessions.ps1
2444  wheel-py3_10-cuda11_8-upload:  # Uploading
2445    if: ${{ github.repository_owner == 'pytorch' }}
2446    permissions:
2447      id-token: write
2448      contents: read
2449    needs: wheel-py3_10-cuda11_8-test
2450    with:
2451      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
2452      BUILDER_ROOT: ${{ github.workspace }}/builder
2453      PACKAGE_TYPE: wheel
2454      # TODO: This is a legacy variable that we eventually want to get rid of in
2455      #       favor of GPU_ARCH_VERSION
2456      DESIRED_CUDA: cu118
2457      GPU_ARCH_VERSION: 11.8
2458      GPU_ARCH_TYPE: cuda
2459      DESIRED_PYTHON: "3.10"
2460      build_name: wheel-py3_10-cuda11_8
2461    secrets:
2462      github-token: ${{ secrets.GITHUB_TOKEN }}
2463      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
2464      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
2465    uses: ./.github/workflows/_binary-upload.yml
2466  wheel-py3_10-cuda12_1-build:
2467    if: ${{ github.repository_owner == 'pytorch' }}
2468    runs-on: windows.4xlarge
2469    timeout-minutes: 240
2470    env:
2471      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
2472      BUILDER_ROOT: ${{ github.workspace }}/builder
2473      PACKAGE_TYPE: wheel
2474      # TODO: This is a legacy variable that we eventually want to get rid of in
2475      #       favor of GPU_ARCH_VERSION
2476      DESIRED_CUDA: cu121
2477      GPU_ARCH_VERSION: 12.1
2478      GPU_ARCH_TYPE: cuda
2479      SKIP_ALL_TESTS: 1
2480      DESIRED_PYTHON: "3.10"
2481      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
2482    steps:
2483      - name: Display EC2 information
2484        shell: bash
2485        run: |
2486          set -euo pipefail
2487          function get_ec2_metadata() {
2488            # Pulled from instance metadata endpoint for EC2
2489            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
2490            category=$1
2491            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
2492          }
2493          echo "ami-id: $(get_ec2_metadata ami-id)"
2494          echo "instance-id: $(get_ec2_metadata instance-id)"
2495          echo "instance-type: $(get_ec2_metadata instance-type)"
2496          echo "system info $(uname -a)"
2497      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
2498        uses: pytorch/test-infra/.github/actions/setup-ssh@main
2499        continue-on-error: true
2500        with:
2501          github-secret: ${{ secrets.GITHUB_TOKEN }}
2502      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
2503      - name: Enable long paths on Windows
2504        shell: powershell
2505        run: |
2506          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
2507      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
2508      # removed once Windows Defender is removed from the AMI
2509      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
2510        continue-on-error: true
2511        shell: powershell
2512        run: |
2513          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
2514          # Let's both exclude the path and disable Windows Defender completely just to be sure
2515          # that it doesn't interfere
2516          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
2517      # NOTE: These environment variables are put here so that they can be applied on every job equally
2518      #       They are also here because setting them at a workflow level doesn't give us access to the
2519      #       runner.temp variable, which we need.
2520      - name: Populate binary env
2521        shell: bash
2522        run: |
2523          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
2524          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
2525          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
2526      - name: Checkout PyTorch
2527        uses: malfet/checkout@silent-checkout
2528        with:
2529          submodules: recursive
2530          path: pytorch
2531          quiet-checkout: true
2532      - name: Clean PyTorch checkout
2533        run: |
2534          # Remove any artifacts from the previous checkouts
2535          git clean -fxd
2536        working-directory: pytorch
2537      - name: Checkout pytorch/builder
2538        uses: malfet/checkout@silent-checkout
2539        with:
2540          ref: release/2.4
2541          submodules: recursive
2542          repository: pytorch/builder
2543          path: builder
2544          quiet-checkout: true
2545      - name: Clean pytorch/builder checkout
2546        run: |
2547          # Remove any artifacts from the previous checkouts
2548          git clean -fxd
2549        working-directory: builder
2550      - name: Populate binary env
2551        shell: bash
2552        run: |
2553          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
2554      - name: Build PyTorch binary
2555        shell: bash
2556        run: |
2557          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
2558      - uses: actions/upload-artifact@v3
2559        if: always()
2560        with:
2561          name: wheel-py3_10-cuda12_1
2562          retention-days: 14
2563          if-no-files-found: error
2564          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
2565      - name: Wait until all sessions have drained
2566        shell: powershell
2567        working-directory: pytorch
2568        if: always()
2569        timeout-minutes: 120
2570        run: |
2571          .github\scripts\wait_for_ssh_to_drain.ps1
2572      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
2573        shell: powershell
2574        working-directory: pytorch
2575        if: always()
2576        run: |
2577          .github\scripts\kill_active_ssh_sessions.ps1
2578  wheel-py3_10-cuda12_1-test:  # Testing
2579    if: ${{ github.repository_owner == 'pytorch' }}
2580    needs: wheel-py3_10-cuda12_1-build
2581    runs-on: windows.8xlarge.nvidia.gpu
2582    timeout-minutes: 240
2583    env:
2584      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
2585      BUILDER_ROOT: ${{ github.workspace }}/builder
2586      PACKAGE_TYPE: wheel
2587      # TODO: This is a legacy variable that we eventually want to get rid of in
2588      #       favor of GPU_ARCH_VERSION
2589      DESIRED_CUDA: cu121
2590      GPU_ARCH_VERSION: 12.1
2591      GPU_ARCH_TYPE: cuda
2592      SKIP_ALL_TESTS: 1
2593      DESIRED_PYTHON: "3.10"
2594    steps:
2595      - name: Display EC2 information
2596        shell: bash
2597        run: |
2598          set -euo pipefail
2599          function get_ec2_metadata() {
2600            # Pulled from instance metadata endpoint for EC2
2601            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
2602            category=$1
2603            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
2604          }
2605          echo "ami-id: $(get_ec2_metadata ami-id)"
2606          echo "instance-id: $(get_ec2_metadata instance-id)"
2607          echo "instance-type: $(get_ec2_metadata instance-type)"
2608          echo "system info $(uname -a)"
2609      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
2610        uses: pytorch/test-infra/.github/actions/setup-ssh@main
2611        continue-on-error: true
2612        with:
2613          github-secret: ${{ secrets.GITHUB_TOKEN }}
2614      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
2615      - name: Enable long paths on Windows
2616        shell: powershell
2617        run: |
2618          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
2619      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
2620      # removed once Windows Defender is removed from the AMI
2621      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
2622        continue-on-error: true
2623        shell: powershell
2624        run: |
2625          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
2626          # Let's both exclude the path and disable Windows Defender completely just to be sure
2627          # that it doesn't interfere
2628          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
2629      # NOTE: These environment variables are put here so that they can be applied on every job equally
2630      #       They are also here because setting them at a workflow level doesn't give us access to the
2631      #       runner.temp variable, which we need.
2632      - name: Populate binary env
2633        shell: bash
2634        run: |
2635          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
2636          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
2637          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
2638      - uses: actions/download-artifact@v3
2639        name: Download Build Artifacts
2640        with:
2641          name: wheel-py3_10-cuda12_1
2642          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
2643      - name: Checkout PyTorch
2644        uses: malfet/checkout@silent-checkout
2645        with:
2646          submodules: recursive
2647          path: pytorch
2648          quiet-checkout: true
2649      - name: Clean PyTorch checkout
2650        run: |
2651          # Remove any artifacts from the previous checkouts
2652          git clean -fxd
2653        working-directory: pytorch
2654      - name: Checkout pytorch/builder
2655        uses: malfet/checkout@silent-checkout
2656        with:
2657          ref: release/2.4
2658          submodules: recursive
2659          repository: pytorch/builder
2660          path: builder
2661          quiet-checkout: true
2662      - name: Clean pytorch/builder checkout
2663        run: |
2664          # Remove any artifacts from the previous checkouts
2665          git clean -fxd
2666        working-directory: builder
2667      - name: Populate binary env
2668        shell: bash
2669        run: |
2670          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
2671      - name: Test PyTorch binary
2672        shell: bash
2673        run: |
2674          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
2675      - name: Wait until all sessions have drained
2676        shell: powershell
2677        working-directory: pytorch
2678        if: always()
2679        timeout-minutes: 120
2680        run: |
2681          .github\scripts\wait_for_ssh_to_drain.ps1
2682      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
2683        shell: powershell
2684        working-directory: pytorch
2685        if: always()
2686        run: |
2687          .github\scripts\kill_active_ssh_sessions.ps1
2688  wheel-py3_10-cuda12_1-upload:  # Uploading
2689    if: ${{ github.repository_owner == 'pytorch' }}
2690    permissions:
2691      id-token: write
2692      contents: read
2693    needs: wheel-py3_10-cuda12_1-test
2694    with:
2695      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
2696      BUILDER_ROOT: ${{ github.workspace }}/builder
2697      PACKAGE_TYPE: wheel
2698      # TODO: This is a legacy variable that we eventually want to get rid of in
2699      #       favor of GPU_ARCH_VERSION
2700      DESIRED_CUDA: cu121
2701      GPU_ARCH_VERSION: 12.1
2702      GPU_ARCH_TYPE: cuda
2703      DESIRED_PYTHON: "3.10"
2704      build_name: wheel-py3_10-cuda12_1
2705    secrets:
2706      github-token: ${{ secrets.GITHUB_TOKEN }}
2707      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
2708      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
2709    uses: ./.github/workflows/_binary-upload.yml
2710  wheel-py3_10-cuda12_4-build:
2711    if: ${{ github.repository_owner == 'pytorch' }}
2712    runs-on: windows.4xlarge
2713    timeout-minutes: 240
2714    env:
2715      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
2716      BUILDER_ROOT: ${{ github.workspace }}/builder
2717      PACKAGE_TYPE: wheel
2718      # TODO: This is a legacy variable that we eventually want to get rid of in
2719      #       favor of GPU_ARCH_VERSION
2720      DESIRED_CUDA: cu124
2721      GPU_ARCH_VERSION: 12.4
2722      GPU_ARCH_TYPE: cuda
2723      SKIP_ALL_TESTS: 1
2724      DESIRED_PYTHON: "3.10"
2725      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
2726    steps:
2727      - name: Display EC2 information
2728        shell: bash
2729        run: |
2730          set -euo pipefail
2731          function get_ec2_metadata() {
2732            # Pulled from instance metadata endpoint for EC2
2733            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
2734            category=$1
2735            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
2736          }
2737          echo "ami-id: $(get_ec2_metadata ami-id)"
2738          echo "instance-id: $(get_ec2_metadata instance-id)"
2739          echo "instance-type: $(get_ec2_metadata instance-type)"
2740          echo "system info $(uname -a)"
2741      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
2742        uses: pytorch/test-infra/.github/actions/setup-ssh@main
2743        continue-on-error: true
2744        with:
2745          github-secret: ${{ secrets.GITHUB_TOKEN }}
2746      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
2747      - name: Enable long paths on Windows
2748        shell: powershell
2749        run: |
2750          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
2751      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
2752      # removed once Windows Defender is removed from the AMI
2753      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
2754        continue-on-error: true
2755        shell: powershell
2756        run: |
2757          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
2758          # Let's both exclude the path and disable Windows Defender completely just to be sure
2759          # that it doesn't interfere
2760          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
2761      # NOTE: These environment variables are put here so that they can be applied on every job equally
2762      #       They are also here because setting them at a workflow level doesn't give us access to the
2763      #       runner.temp variable, which we need.
2764      - name: Populate binary env
2765        shell: bash
2766        run: |
2767          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
2768          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
2769          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
2770      - name: Checkout PyTorch
2771        uses: malfet/checkout@silent-checkout
2772        with:
2773          submodules: recursive
2774          path: pytorch
2775          quiet-checkout: true
2776      - name: Clean PyTorch checkout
2777        run: |
2778          # Remove any artifacts from the previous checkouts
2779          git clean -fxd
2780        working-directory: pytorch
2781      - name: Checkout pytorch/builder
2782        uses: malfet/checkout@silent-checkout
2783        with:
2784          ref: release/2.4
2785          submodules: recursive
2786          repository: pytorch/builder
2787          path: builder
2788          quiet-checkout: true
2789      - name: Clean pytorch/builder checkout
2790        run: |
2791          # Remove any artifacts from the previous checkouts
2792          git clean -fxd
2793        working-directory: builder
2794      - name: Populate binary env
2795        shell: bash
2796        run: |
2797          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
2798      - name: Build PyTorch binary
2799        shell: bash
2800        run: |
2801          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
2802      - uses: actions/upload-artifact@v3
2803        if: always()
2804        with:
2805          name: wheel-py3_10-cuda12_4
2806          retention-days: 14
2807          if-no-files-found: error
2808          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
2809      - name: Wait until all sessions have drained
2810        shell: powershell
2811        working-directory: pytorch
2812        if: always()
2813        timeout-minutes: 120
2814        run: |
2815          .github\scripts\wait_for_ssh_to_drain.ps1
2816      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
2817        shell: powershell
2818        working-directory: pytorch
2819        if: always()
2820        run: |
2821          .github\scripts\kill_active_ssh_sessions.ps1
2822  wheel-py3_10-cuda12_4-test:  # Testing
2823    if: ${{ github.repository_owner == 'pytorch' }}
2824    needs: wheel-py3_10-cuda12_4-build
2825    runs-on: windows.8xlarge.nvidia.gpu
2826    timeout-minutes: 240
2827    env:
2828      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
2829      BUILDER_ROOT: ${{ github.workspace }}/builder
2830      PACKAGE_TYPE: wheel
2831      # TODO: This is a legacy variable that we eventually want to get rid of in
2832      #       favor of GPU_ARCH_VERSION
2833      DESIRED_CUDA: cu124
2834      GPU_ARCH_VERSION: 12.4
2835      GPU_ARCH_TYPE: cuda
2836      SKIP_ALL_TESTS: 1
2837      DESIRED_PYTHON: "3.10"
2838    steps:
2839      - name: Display EC2 information
2840        shell: bash
2841        run: |
2842          set -euo pipefail
2843          function get_ec2_metadata() {
2844            # Pulled from instance metadata endpoint for EC2
2845            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
2846            category=$1
2847            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
2848          }
2849          echo "ami-id: $(get_ec2_metadata ami-id)"
2850          echo "instance-id: $(get_ec2_metadata instance-id)"
2851          echo "instance-type: $(get_ec2_metadata instance-type)"
2852          echo "system info $(uname -a)"
2853      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
2854        uses: pytorch/test-infra/.github/actions/setup-ssh@main
2855        continue-on-error: true
2856        with:
2857          github-secret: ${{ secrets.GITHUB_TOKEN }}
2858      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
2859      - name: Enable long paths on Windows
2860        shell: powershell
2861        run: |
2862          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
2863      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
2864      # removed once Windows Defender is removed from the AMI
2865      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
2866        continue-on-error: true
2867        shell: powershell
2868        run: |
2869          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
2870          # Let's both exclude the path and disable Windows Defender completely just to be sure
2871          # that it doesn't interfere
2872          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
2873      # NOTE: These environment variables are put here so that they can be applied on every job equally
2874      #       They are also here because setting them at a workflow level doesn't give us access to the
2875      #       runner.temp variable, which we need.
2876      - name: Populate binary env
2877        shell: bash
2878        run: |
2879          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
2880          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
2881          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
2882      - uses: actions/download-artifact@v3
2883        name: Download Build Artifacts
2884        with:
2885          name: wheel-py3_10-cuda12_4
2886          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
2887      - name: Checkout PyTorch
2888        uses: malfet/checkout@silent-checkout
2889        with:
2890          submodules: recursive
2891          path: pytorch
2892          quiet-checkout: true
2893      - name: Clean PyTorch checkout
2894        run: |
2895          # Remove any artifacts from the previous checkouts
2896          git clean -fxd
2897        working-directory: pytorch
2898      - name: Checkout pytorch/builder
2899        uses: malfet/checkout@silent-checkout
2900        with:
2901          ref: release/2.4
2902          submodules: recursive
2903          repository: pytorch/builder
2904          path: builder
2905          quiet-checkout: true
2906      - name: Clean pytorch/builder checkout
2907        run: |
2908          # Remove any artifacts from the previous checkouts
2909          git clean -fxd
2910        working-directory: builder
2911      - name: Populate binary env
2912        shell: bash
2913        run: |
2914          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
2915      - name: Test PyTorch binary
2916        shell: bash
2917        run: |
2918          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
2919      - name: Wait until all sessions have drained
2920        shell: powershell
2921        working-directory: pytorch
2922        if: always()
2923        timeout-minutes: 120
2924        run: |
2925          .github\scripts\wait_for_ssh_to_drain.ps1
2926      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
2927        shell: powershell
2928        working-directory: pytorch
2929        if: always()
2930        run: |
2931          .github\scripts\kill_active_ssh_sessions.ps1
2932  wheel-py3_10-cuda12_4-upload:  # Uploading
2933    if: ${{ github.repository_owner == 'pytorch' }}
2934    permissions:
2935      id-token: write
2936      contents: read
2937    needs: wheel-py3_10-cuda12_4-test
2938    with:
2939      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
2940      BUILDER_ROOT: ${{ github.workspace }}/builder
2941      PACKAGE_TYPE: wheel
2942      # TODO: This is a legacy variable that we eventually want to get rid of in
2943      #       favor of GPU_ARCH_VERSION
2944      DESIRED_CUDA: cu124
2945      GPU_ARCH_VERSION: 12.4
2946      GPU_ARCH_TYPE: cuda
2947      DESIRED_PYTHON: "3.10"
2948      build_name: wheel-py3_10-cuda12_4
2949    secrets:
2950      github-token: ${{ secrets.GITHUB_TOKEN }}
2951      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
2952      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
2953    uses: ./.github/workflows/_binary-upload.yml
2954  wheel-py3_11-cpu-build:
2955    if: ${{ github.repository_owner == 'pytorch' }}
2956    runs-on: windows.4xlarge
2957    timeout-minutes: 240
2958    env:
2959      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
2960      BUILDER_ROOT: ${{ github.workspace }}/builder
2961      PACKAGE_TYPE: wheel
2962      # TODO: This is a legacy variable that we eventually want to get rid of in
2963      #       favor of GPU_ARCH_VERSION
2964      DESIRED_CUDA: cpu
2965      GPU_ARCH_TYPE: cpu
2966      SKIP_ALL_TESTS: 1
2967      DESIRED_PYTHON: "3.11"
2968      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
2969    steps:
2970      - name: Display EC2 information
2971        shell: bash
2972        run: |
2973          set -euo pipefail
2974          function get_ec2_metadata() {
2975            # Pulled from instance metadata endpoint for EC2
2976            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
2977            category=$1
2978            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
2979          }
2980          echo "ami-id: $(get_ec2_metadata ami-id)"
2981          echo "instance-id: $(get_ec2_metadata instance-id)"
2982          echo "instance-type: $(get_ec2_metadata instance-type)"
2983          echo "system info $(uname -a)"
2984      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
2985        uses: pytorch/test-infra/.github/actions/setup-ssh@main
2986        continue-on-error: true
2987        with:
2988          github-secret: ${{ secrets.GITHUB_TOKEN }}
2989      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
2990      - name: Enable long paths on Windows
2991        shell: powershell
2992        run: |
2993          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
2994      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
2995      # removed once Windows Defender is removed from the AMI
2996      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
2997        continue-on-error: true
2998        shell: powershell
2999        run: |
3000          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
3001          # Let's both exclude the path and disable Windows Defender completely just to be sure
3002          # that it doesn't interfere
3003          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
3004      # NOTE: These environment variables are put here so that they can be applied on every job equally
3005      #       They are also here because setting them at a workflow level doesn't give us access to the
3006      #       runner.temp variable, which we need.
3007      - name: Populate binary env
3008        shell: bash
3009        run: |
3010          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
3011          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
3012          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
3013      - name: Checkout PyTorch
3014        uses: malfet/checkout@silent-checkout
3015        with:
3016          submodules: recursive
3017          path: pytorch
3018          quiet-checkout: true
3019      - name: Clean PyTorch checkout
3020        run: |
3021          # Remove any artifacts from the previous checkouts
3022          git clean -fxd
3023        working-directory: pytorch
3024      - name: Checkout pytorch/builder
3025        uses: malfet/checkout@silent-checkout
3026        with:
3027          ref: release/2.4
3028          submodules: recursive
3029          repository: pytorch/builder
3030          path: builder
3031          quiet-checkout: true
3032      - name: Clean pytorch/builder checkout
3033        run: |
3034          # Remove any artifacts from the previous checkouts
3035          git clean -fxd
3036        working-directory: builder
3037      - name: Populate binary env
3038        shell: bash
3039        run: |
3040          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
3041      - name: Build PyTorch binary
3042        shell: bash
3043        run: |
3044          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
3045      - uses: actions/upload-artifact@v3
3046        if: always()
3047        with:
3048          name: wheel-py3_11-cpu
3049          retention-days: 14
3050          if-no-files-found: error
3051          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
3052      - name: Wait until all sessions have drained
3053        shell: powershell
3054        working-directory: pytorch
3055        if: always()
3056        timeout-minutes: 120
3057        run: |
3058          .github\scripts\wait_for_ssh_to_drain.ps1
3059      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
3060        shell: powershell
3061        working-directory: pytorch
3062        if: always()
3063        run: |
3064          .github\scripts\kill_active_ssh_sessions.ps1
3065  wheel-py3_11-cpu-test:  # Testing
3066    if: ${{ github.repository_owner == 'pytorch' }}
3067    needs: wheel-py3_11-cpu-build
3068    runs-on: windows.4xlarge.nonephemeral
3069    timeout-minutes: 240
3070    env:
3071      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
3072      BUILDER_ROOT: ${{ github.workspace }}/builder
3073      PACKAGE_TYPE: wheel
3074      # TODO: This is a legacy variable that we eventually want to get rid of in
3075      #       favor of GPU_ARCH_VERSION
3076      DESIRED_CUDA: cpu
3077      GPU_ARCH_TYPE: cpu
3078      SKIP_ALL_TESTS: 1
3079      DESIRED_PYTHON: "3.11"
3080    steps:
3081      - name: Display EC2 information
3082        shell: bash
3083        run: |
3084          set -euo pipefail
3085          function get_ec2_metadata() {
3086            # Pulled from instance metadata endpoint for EC2
3087            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
3088            category=$1
3089            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
3090          }
3091          echo "ami-id: $(get_ec2_metadata ami-id)"
3092          echo "instance-id: $(get_ec2_metadata instance-id)"
3093          echo "instance-type: $(get_ec2_metadata instance-type)"
3094          echo "system info $(uname -a)"
3095      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
3096        uses: pytorch/test-infra/.github/actions/setup-ssh@main
3097        continue-on-error: true
3098        with:
3099          github-secret: ${{ secrets.GITHUB_TOKEN }}
3100      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
3101      - name: Enable long paths on Windows
3102        shell: powershell
3103        run: |
3104          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
3105      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
3106      # removed once Windows Defender is removed from the AMI
3107      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
3108        continue-on-error: true
3109        shell: powershell
3110        run: |
3111          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
3112          # Let's both exclude the path and disable Windows Defender completely just to be sure
3113          # that it doesn't interfere
3114          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
3115      # NOTE: These environment variables are put here so that they can be applied on every job equally
3116      #       They are also here because setting them at a workflow level doesn't give us access to the
3117      #       runner.temp variable, which we need.
3118      - name: Populate binary env
3119        shell: bash
3120        run: |
3121          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
3122          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
3123          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
3124      - uses: actions/download-artifact@v3
3125        name: Download Build Artifacts
3126        with:
3127          name: wheel-py3_11-cpu
3128          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
3129      - name: Checkout PyTorch
3130        uses: malfet/checkout@silent-checkout
3131        with:
3132          submodules: recursive
3133          path: pytorch
3134          quiet-checkout: true
3135      - name: Clean PyTorch checkout
3136        run: |
3137          # Remove any artifacts from the previous checkouts
3138          git clean -fxd
3139        working-directory: pytorch
3140      - name: Checkout pytorch/builder
3141        uses: malfet/checkout@silent-checkout
3142        with:
3143          ref: release/2.4
3144          submodules: recursive
3145          repository: pytorch/builder
3146          path: builder
3147          quiet-checkout: true
3148      - name: Clean pytorch/builder checkout
3149        run: |
3150          # Remove any artifacts from the previous checkouts
3151          git clean -fxd
3152        working-directory: builder
3153      - name: Populate binary env
3154        shell: bash
3155        run: |
3156          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
3157      - name: Test PyTorch binary
3158        shell: bash
3159        run: |
3160          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
3161      - name: Wait until all sessions have drained
3162        shell: powershell
3163        working-directory: pytorch
3164        if: always()
3165        timeout-minutes: 120
3166        run: |
3167          .github\scripts\wait_for_ssh_to_drain.ps1
3168      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
3169        shell: powershell
3170        working-directory: pytorch
3171        if: always()
3172        run: |
3173          .github\scripts\kill_active_ssh_sessions.ps1
3174  wheel-py3_11-cpu-upload:  # Uploading
3175    if: ${{ github.repository_owner == 'pytorch' }}
3176    permissions:
3177      id-token: write
3178      contents: read
3179    needs: wheel-py3_11-cpu-test
3180    with:
3181      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
3182      BUILDER_ROOT: ${{ github.workspace }}/builder
3183      PACKAGE_TYPE: wheel
3184      # TODO: This is a legacy variable that we eventually want to get rid of in
3185      #       favor of GPU_ARCH_VERSION
3186      DESIRED_CUDA: cpu
3187      GPU_ARCH_TYPE: cpu
3188      DESIRED_PYTHON: "3.11"
3189      build_name: wheel-py3_11-cpu
3190    secrets:
3191      github-token: ${{ secrets.GITHUB_TOKEN }}
3192      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
3193      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
3194    uses: ./.github/workflows/_binary-upload.yml
3195  wheel-py3_11-cuda11_8-build:
3196    if: ${{ github.repository_owner == 'pytorch' }}
3197    runs-on: windows.4xlarge
3198    timeout-minutes: 240
3199    env:
3200      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
3201      BUILDER_ROOT: ${{ github.workspace }}/builder
3202      PACKAGE_TYPE: wheel
3203      # TODO: This is a legacy variable that we eventually want to get rid of in
3204      #       favor of GPU_ARCH_VERSION
3205      DESIRED_CUDA: cu118
3206      GPU_ARCH_VERSION: 11.8
3207      GPU_ARCH_TYPE: cuda
3208      SKIP_ALL_TESTS: 1
3209      DESIRED_PYTHON: "3.11"
3210      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
3211    steps:
3212      - name: Display EC2 information
3213        shell: bash
3214        run: |
3215          set -euo pipefail
3216          function get_ec2_metadata() {
3217            # Pulled from instance metadata endpoint for EC2
3218            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
3219            category=$1
3220            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
3221          }
3222          echo "ami-id: $(get_ec2_metadata ami-id)"
3223          echo "instance-id: $(get_ec2_metadata instance-id)"
3224          echo "instance-type: $(get_ec2_metadata instance-type)"
3225          echo "system info $(uname -a)"
3226      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
3227        uses: pytorch/test-infra/.github/actions/setup-ssh@main
3228        continue-on-error: true
3229        with:
3230          github-secret: ${{ secrets.GITHUB_TOKEN }}
3231      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
3232      - name: Enable long paths on Windows
3233        shell: powershell
3234        run: |
3235          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
3236      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
3237      # removed once Windows Defender is removed from the AMI
3238      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
3239        continue-on-error: true
3240        shell: powershell
3241        run: |
3242          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
3243          # Let's both exclude the path and disable Windows Defender completely just to be sure
3244          # that it doesn't interfere
3245          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
3246      # NOTE: These environment variables are put here so that they can be applied on every job equally
3247      #       They are also here because setting them at a workflow level doesn't give us access to the
3248      #       runner.temp variable, which we need.
3249      - name: Populate binary env
3250        shell: bash
3251        run: |
3252          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
3253          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
3254          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
3255      - name: Checkout PyTorch
3256        uses: malfet/checkout@silent-checkout
3257        with:
3258          submodules: recursive
3259          path: pytorch
3260          quiet-checkout: true
3261      - name: Clean PyTorch checkout
3262        run: |
3263          # Remove any artifacts from the previous checkouts
3264          git clean -fxd
3265        working-directory: pytorch
3266      - name: Checkout pytorch/builder
3267        uses: malfet/checkout@silent-checkout
3268        with:
3269          ref: release/2.4
3270          submodules: recursive
3271          repository: pytorch/builder
3272          path: builder
3273          quiet-checkout: true
3274      - name: Clean pytorch/builder checkout
3275        run: |
3276          # Remove any artifacts from the previous checkouts
3277          git clean -fxd
3278        working-directory: builder
3279      - name: Populate binary env
3280        shell: bash
3281        run: |
3282          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
3283      - name: Build PyTorch binary
3284        shell: bash
3285        run: |
3286          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
3287      - uses: actions/upload-artifact@v3
3288        if: always()
3289        with:
3290          name: wheel-py3_11-cuda11_8
3291          retention-days: 14
3292          if-no-files-found: error
3293          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
3294      - name: Wait until all sessions have drained
3295        shell: powershell
3296        working-directory: pytorch
3297        if: always()
3298        timeout-minutes: 120
3299        run: |
3300          .github\scripts\wait_for_ssh_to_drain.ps1
3301      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
3302        shell: powershell
3303        working-directory: pytorch
3304        if: always()
3305        run: |
3306          .github\scripts\kill_active_ssh_sessions.ps1
3307  wheel-py3_11-cuda11_8-test:  # Testing
3308    if: ${{ github.repository_owner == 'pytorch' }}
3309    needs: wheel-py3_11-cuda11_8-build
3310    runs-on: windows.8xlarge.nvidia.gpu
3311    timeout-minutes: 240
3312    env:
3313      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
3314      BUILDER_ROOT: ${{ github.workspace }}/builder
3315      PACKAGE_TYPE: wheel
3316      # TODO: This is a legacy variable that we eventually want to get rid of in
3317      #       favor of GPU_ARCH_VERSION
3318      DESIRED_CUDA: cu118
3319      GPU_ARCH_VERSION: 11.8
3320      GPU_ARCH_TYPE: cuda
3321      SKIP_ALL_TESTS: 1
3322      DESIRED_PYTHON: "3.11"
3323    steps:
3324      - name: Display EC2 information
3325        shell: bash
3326        run: |
3327          set -euo pipefail
3328          function get_ec2_metadata() {
3329            # Pulled from instance metadata endpoint for EC2
3330            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
3331            category=$1
3332            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
3333          }
3334          echo "ami-id: $(get_ec2_metadata ami-id)"
3335          echo "instance-id: $(get_ec2_metadata instance-id)"
3336          echo "instance-type: $(get_ec2_metadata instance-type)"
3337          echo "system info $(uname -a)"
3338      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
3339        uses: pytorch/test-infra/.github/actions/setup-ssh@main
3340        continue-on-error: true
3341        with:
3342          github-secret: ${{ secrets.GITHUB_TOKEN }}
3343      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
3344      - name: Enable long paths on Windows
3345        shell: powershell
3346        run: |
3347          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
3348      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
3349      # removed once Windows Defender is removed from the AMI
3350      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
3351        continue-on-error: true
3352        shell: powershell
3353        run: |
3354          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
3355          # Let's both exclude the path and disable Windows Defender completely just to be sure
3356          # that it doesn't interfere
3357          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
3358      # NOTE: These environment variables are put here so that they can be applied on every job equally
3359      #       They are also here because setting them at a workflow level doesn't give us access to the
3360      #       runner.temp variable, which we need.
3361      - name: Populate binary env
3362        shell: bash
3363        run: |
3364          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
3365          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
3366          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
3367      - uses: actions/download-artifact@v3
3368        name: Download Build Artifacts
3369        with:
3370          name: wheel-py3_11-cuda11_8
3371          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
3372      - name: Checkout PyTorch
3373        uses: malfet/checkout@silent-checkout
3374        with:
3375          submodules: recursive
3376          path: pytorch
3377          quiet-checkout: true
3378      - name: Clean PyTorch checkout
3379        run: |
3380          # Remove any artifacts from the previous checkouts
3381          git clean -fxd
3382        working-directory: pytorch
3383      - name: Checkout pytorch/builder
3384        uses: malfet/checkout@silent-checkout
3385        with:
3386          ref: release/2.4
3387          submodules: recursive
3388          repository: pytorch/builder
3389          path: builder
3390          quiet-checkout: true
3391      - name: Clean pytorch/builder checkout
3392        run: |
3393          # Remove any artifacts from the previous checkouts
3394          git clean -fxd
3395        working-directory: builder
3396      - name: Populate binary env
3397        shell: bash
3398        run: |
3399          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
3400      - name: Test PyTorch binary
3401        shell: bash
3402        run: |
3403          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
3404      - name: Wait until all sessions have drained
3405        shell: powershell
3406        working-directory: pytorch
3407        if: always()
3408        timeout-minutes: 120
3409        run: |
3410          .github\scripts\wait_for_ssh_to_drain.ps1
3411      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
3412        shell: powershell
3413        working-directory: pytorch
3414        if: always()
3415        run: |
3416          .github\scripts\kill_active_ssh_sessions.ps1
3417  wheel-py3_11-cuda11_8-upload:  # Uploading
3418    if: ${{ github.repository_owner == 'pytorch' }}
3419    permissions:
3420      id-token: write
3421      contents: read
3422    needs: wheel-py3_11-cuda11_8-test
3423    with:
3424      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
3425      BUILDER_ROOT: ${{ github.workspace }}/builder
3426      PACKAGE_TYPE: wheel
3427      # TODO: This is a legacy variable that we eventually want to get rid of in
3428      #       favor of GPU_ARCH_VERSION
3429      DESIRED_CUDA: cu118
3430      GPU_ARCH_VERSION: 11.8
3431      GPU_ARCH_TYPE: cuda
3432      DESIRED_PYTHON: "3.11"
3433      build_name: wheel-py3_11-cuda11_8
3434    secrets:
3435      github-token: ${{ secrets.GITHUB_TOKEN }}
3436      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
3437      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
3438    uses: ./.github/workflows/_binary-upload.yml
3439  wheel-py3_11-cuda12_1-build:
3440    if: ${{ github.repository_owner == 'pytorch' }}
3441    runs-on: windows.4xlarge
3442    timeout-minutes: 240
3443    env:
3444      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
3445      BUILDER_ROOT: ${{ github.workspace }}/builder
3446      PACKAGE_TYPE: wheel
3447      # TODO: This is a legacy variable that we eventually want to get rid of in
3448      #       favor of GPU_ARCH_VERSION
3449      DESIRED_CUDA: cu121
3450      GPU_ARCH_VERSION: 12.1
3451      GPU_ARCH_TYPE: cuda
3452      SKIP_ALL_TESTS: 1
3453      DESIRED_PYTHON: "3.11"
3454      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
3455    steps:
3456      - name: Display EC2 information
3457        shell: bash
3458        run: |
3459          set -euo pipefail
3460          function get_ec2_metadata() {
3461            # Pulled from instance metadata endpoint for EC2
3462            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
3463            category=$1
3464            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
3465          }
3466          echo "ami-id: $(get_ec2_metadata ami-id)"
3467          echo "instance-id: $(get_ec2_metadata instance-id)"
3468          echo "instance-type: $(get_ec2_metadata instance-type)"
3469          echo "system info $(uname -a)"
3470      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
3471        uses: pytorch/test-infra/.github/actions/setup-ssh@main
3472        continue-on-error: true
3473        with:
3474          github-secret: ${{ secrets.GITHUB_TOKEN }}
3475      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
3476      - name: Enable long paths on Windows
3477        shell: powershell
3478        run: |
3479          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
3480      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
3481      # removed once Windows Defender is removed from the AMI
3482      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
3483        continue-on-error: true
3484        shell: powershell
3485        run: |
3486          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
3487          # Let's both exclude the path and disable Windows Defender completely just to be sure
3488          # that it doesn't interfere
3489          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
3490      # NOTE: These environment variables are put here so that they can be applied on every job equally
3491      #       They are also here because setting them at a workflow level doesn't give us access to the
3492      #       runner.temp variable, which we need.
3493      - name: Populate binary env
3494        shell: bash
3495        run: |
3496          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
3497          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
3498          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
3499      - name: Checkout PyTorch
3500        uses: malfet/checkout@silent-checkout
3501        with:
3502          submodules: recursive
3503          path: pytorch
3504          quiet-checkout: true
3505      - name: Clean PyTorch checkout
3506        run: |
3507          # Remove any artifacts from the previous checkouts
3508          git clean -fxd
3509        working-directory: pytorch
3510      - name: Checkout pytorch/builder
3511        uses: malfet/checkout@silent-checkout
3512        with:
3513          ref: release/2.4
3514          submodules: recursive
3515          repository: pytorch/builder
3516          path: builder
3517          quiet-checkout: true
3518      - name: Clean pytorch/builder checkout
3519        run: |
3520          # Remove any artifacts from the previous checkouts
3521          git clean -fxd
3522        working-directory: builder
3523      - name: Populate binary env
3524        shell: bash
3525        run: |
3526          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
3527      - name: Build PyTorch binary
3528        shell: bash
3529        run: |
3530          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
3531      - uses: actions/upload-artifact@v3
3532        if: always()
3533        with:
3534          name: wheel-py3_11-cuda12_1
3535          retention-days: 14
3536          if-no-files-found: error
3537          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
3538      - name: Wait until all sessions have drained
3539        shell: powershell
3540        working-directory: pytorch
3541        if: always()
3542        timeout-minutes: 120
3543        run: |
3544          .github\scripts\wait_for_ssh_to_drain.ps1
3545      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
3546        shell: powershell
3547        working-directory: pytorch
3548        if: always()
3549        run: |
3550          .github\scripts\kill_active_ssh_sessions.ps1
3551  wheel-py3_11-cuda12_1-test:  # Testing
3552    if: ${{ github.repository_owner == 'pytorch' }}
3553    needs: wheel-py3_11-cuda12_1-build
3554    runs-on: windows.8xlarge.nvidia.gpu
3555    timeout-minutes: 240
3556    env:
3557      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
3558      BUILDER_ROOT: ${{ github.workspace }}/builder
3559      PACKAGE_TYPE: wheel
3560      # TODO: This is a legacy variable that we eventually want to get rid of in
3561      #       favor of GPU_ARCH_VERSION
3562      DESIRED_CUDA: cu121
3563      GPU_ARCH_VERSION: 12.1
3564      GPU_ARCH_TYPE: cuda
3565      SKIP_ALL_TESTS: 1
3566      DESIRED_PYTHON: "3.11"
3567    steps:
3568      - name: Display EC2 information
3569        shell: bash
3570        run: |
3571          set -euo pipefail
3572          function get_ec2_metadata() {
3573            # Pulled from instance metadata endpoint for EC2
3574            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
3575            category=$1
3576            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
3577          }
3578          echo "ami-id: $(get_ec2_metadata ami-id)"
3579          echo "instance-id: $(get_ec2_metadata instance-id)"
3580          echo "instance-type: $(get_ec2_metadata instance-type)"
3581          echo "system info $(uname -a)"
3582      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
3583        uses: pytorch/test-infra/.github/actions/setup-ssh@main
3584        continue-on-error: true
3585        with:
3586          github-secret: ${{ secrets.GITHUB_TOKEN }}
3587      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
3588      - name: Enable long paths on Windows
3589        shell: powershell
3590        run: |
3591          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
3592      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
3593      # removed once Windows Defender is removed from the AMI
3594      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
3595        continue-on-error: true
3596        shell: powershell
3597        run: |
3598          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
3599          # Let's both exclude the path and disable Windows Defender completely just to be sure
3600          # that it doesn't interfere
3601          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
3602      # NOTE: These environment variables are put here so that they can be applied on every job equally
3603      #       They are also here because setting them at a workflow level doesn't give us access to the
3604      #       runner.temp variable, which we need.
3605      - name: Populate binary env
3606        shell: bash
3607        run: |
3608          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
3609          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
3610          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
3611      - uses: actions/download-artifact@v3
3612        name: Download Build Artifacts
3613        with:
3614          name: wheel-py3_11-cuda12_1
3615          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
3616      - name: Checkout PyTorch
3617        uses: malfet/checkout@silent-checkout
3618        with:
3619          submodules: recursive
3620          path: pytorch
3621          quiet-checkout: true
3622      - name: Clean PyTorch checkout
3623        run: |
3624          # Remove any artifacts from the previous checkouts
3625          git clean -fxd
3626        working-directory: pytorch
3627      - name: Checkout pytorch/builder
3628        uses: malfet/checkout@silent-checkout
3629        with:
3630          ref: release/2.4
3631          submodules: recursive
3632          repository: pytorch/builder
3633          path: builder
3634          quiet-checkout: true
3635      - name: Clean pytorch/builder checkout
3636        run: |
3637          # Remove any artifacts from the previous checkouts
3638          git clean -fxd
3639        working-directory: builder
3640      - name: Populate binary env
3641        shell: bash
3642        run: |
3643          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
3644      - name: Test PyTorch binary
3645        shell: bash
3646        run: |
3647          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
3648      - name: Wait until all sessions have drained
3649        shell: powershell
3650        working-directory: pytorch
3651        if: always()
3652        timeout-minutes: 120
3653        run: |
3654          .github\scripts\wait_for_ssh_to_drain.ps1
3655      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
3656        shell: powershell
3657        working-directory: pytorch
3658        if: always()
3659        run: |
3660          .github\scripts\kill_active_ssh_sessions.ps1
3661  wheel-py3_11-cuda12_1-upload:  # Uploading
3662    if: ${{ github.repository_owner == 'pytorch' }}
3663    permissions:
3664      id-token: write
3665      contents: read
3666    needs: wheel-py3_11-cuda12_1-test
3667    with:
3668      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
3669      BUILDER_ROOT: ${{ github.workspace }}/builder
3670      PACKAGE_TYPE: wheel
3671      # TODO: This is a legacy variable that we eventually want to get rid of in
3672      #       favor of GPU_ARCH_VERSION
3673      DESIRED_CUDA: cu121
3674      GPU_ARCH_VERSION: 12.1
3675      GPU_ARCH_TYPE: cuda
3676      DESIRED_PYTHON: "3.11"
3677      build_name: wheel-py3_11-cuda12_1
3678    secrets:
3679      github-token: ${{ secrets.GITHUB_TOKEN }}
3680      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
3681      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
3682    uses: ./.github/workflows/_binary-upload.yml
3683  wheel-py3_11-cuda12_4-build:
3684    if: ${{ github.repository_owner == 'pytorch' }}
3685    runs-on: windows.4xlarge
3686    timeout-minutes: 240
3687    env:
3688      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
3689      BUILDER_ROOT: ${{ github.workspace }}/builder
3690      PACKAGE_TYPE: wheel
3691      # TODO: This is a legacy variable that we eventually want to get rid of in
3692      #       favor of GPU_ARCH_VERSION
3693      DESIRED_CUDA: cu124
3694      GPU_ARCH_VERSION: 12.4
3695      GPU_ARCH_TYPE: cuda
3696      SKIP_ALL_TESTS: 1
3697      DESIRED_PYTHON: "3.11"
3698      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
3699    steps:
3700      - name: Display EC2 information
3701        shell: bash
3702        run: |
3703          set -euo pipefail
3704          function get_ec2_metadata() {
3705            # Pulled from instance metadata endpoint for EC2
3706            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
3707            category=$1
3708            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
3709          }
3710          echo "ami-id: $(get_ec2_metadata ami-id)"
3711          echo "instance-id: $(get_ec2_metadata instance-id)"
3712          echo "instance-type: $(get_ec2_metadata instance-type)"
3713          echo "system info $(uname -a)"
3714      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
3715        uses: pytorch/test-infra/.github/actions/setup-ssh@main
3716        continue-on-error: true
3717        with:
3718          github-secret: ${{ secrets.GITHUB_TOKEN }}
3719      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
3720      - name: Enable long paths on Windows
3721        shell: powershell
3722        run: |
3723          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
3724      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
3725      # removed once Windows Defender is removed from the AMI
3726      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
3727        continue-on-error: true
3728        shell: powershell
3729        run: |
3730          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
3731          # Let's both exclude the path and disable Windows Defender completely just to be sure
3732          # that it doesn't interfere
3733          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
3734      # NOTE: These environment variables are put here so that they can be applied on every job equally
3735      #       They are also here because setting them at a workflow level doesn't give us access to the
3736      #       runner.temp variable, which we need.
3737      - name: Populate binary env
3738        shell: bash
3739        run: |
3740          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
3741          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
3742          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
3743      - name: Checkout PyTorch
3744        uses: malfet/checkout@silent-checkout
3745        with:
3746          submodules: recursive
3747          path: pytorch
3748          quiet-checkout: true
3749      - name: Clean PyTorch checkout
3750        run: |
3751          # Remove any artifacts from the previous checkouts
3752          git clean -fxd
3753        working-directory: pytorch
3754      - name: Checkout pytorch/builder
3755        uses: malfet/checkout@silent-checkout
3756        with:
3757          ref: release/2.4
3758          submodules: recursive
3759          repository: pytorch/builder
3760          path: builder
3761          quiet-checkout: true
3762      - name: Clean pytorch/builder checkout
3763        run: |
3764          # Remove any artifacts from the previous checkouts
3765          git clean -fxd
3766        working-directory: builder
3767      - name: Populate binary env
3768        shell: bash
3769        run: |
3770          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
3771      - name: Build PyTorch binary
3772        shell: bash
3773        run: |
3774          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
3775      - uses: actions/upload-artifact@v3
3776        if: always()
3777        with:
3778          name: wheel-py3_11-cuda12_4
3779          retention-days: 14
3780          if-no-files-found: error
3781          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
3782      - name: Wait until all sessions have drained
3783        shell: powershell
3784        working-directory: pytorch
3785        if: always()
3786        timeout-minutes: 120
3787        run: |
3788          .github\scripts\wait_for_ssh_to_drain.ps1
3789      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
3790        shell: powershell
3791        working-directory: pytorch
3792        if: always()
3793        run: |
3794          .github\scripts\kill_active_ssh_sessions.ps1
3795  wheel-py3_11-cuda12_4-test:  # Testing
3796    if: ${{ github.repository_owner == 'pytorch' }}
3797    needs: wheel-py3_11-cuda12_4-build
3798    runs-on: windows.8xlarge.nvidia.gpu
3799    timeout-minutes: 240
3800    env:
3801      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
3802      BUILDER_ROOT: ${{ github.workspace }}/builder
3803      PACKAGE_TYPE: wheel
3804      # TODO: This is a legacy variable that we eventually want to get rid of in
3805      #       favor of GPU_ARCH_VERSION
3806      DESIRED_CUDA: cu124
3807      GPU_ARCH_VERSION: 12.4
3808      GPU_ARCH_TYPE: cuda
3809      SKIP_ALL_TESTS: 1
3810      DESIRED_PYTHON: "3.11"
3811    steps:
3812      - name: Display EC2 information
3813        shell: bash
3814        run: |
3815          set -euo pipefail
3816          function get_ec2_metadata() {
3817            # Pulled from instance metadata endpoint for EC2
3818            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
3819            category=$1
3820            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
3821          }
3822          echo "ami-id: $(get_ec2_metadata ami-id)"
3823          echo "instance-id: $(get_ec2_metadata instance-id)"
3824          echo "instance-type: $(get_ec2_metadata instance-type)"
3825          echo "system info $(uname -a)"
3826      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
3827        uses: pytorch/test-infra/.github/actions/setup-ssh@main
3828        continue-on-error: true
3829        with:
3830          github-secret: ${{ secrets.GITHUB_TOKEN }}
3831      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
3832      - name: Enable long paths on Windows
3833        shell: powershell
3834        run: |
3835          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
3836      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
3837      # removed once Windows Defender is removed from the AMI
3838      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
3839        continue-on-error: true
3840        shell: powershell
3841        run: |
3842          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
3843          # Let's both exclude the path and disable Windows Defender completely just to be sure
3844          # that it doesn't interfere
3845          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
3846      # NOTE: These environment variables are put here so that they can be applied on every job equally
3847      #       They are also here because setting them at a workflow level doesn't give us access to the
3848      #       runner.temp variable, which we need.
3849      - name: Populate binary env
3850        shell: bash
3851        run: |
3852          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
3853          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
3854          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
3855      - uses: actions/download-artifact@v3
3856        name: Download Build Artifacts
3857        with:
3858          name: wheel-py3_11-cuda12_4
3859          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
3860      - name: Checkout PyTorch
3861        uses: malfet/checkout@silent-checkout
3862        with:
3863          submodules: recursive
3864          path: pytorch
3865          quiet-checkout: true
3866      - name: Clean PyTorch checkout
3867        run: |
3868          # Remove any artifacts from the previous checkouts
3869          git clean -fxd
3870        working-directory: pytorch
3871      - name: Checkout pytorch/builder
3872        uses: malfet/checkout@silent-checkout
3873        with:
3874          ref: release/2.4
3875          submodules: recursive
3876          repository: pytorch/builder
3877          path: builder
3878          quiet-checkout: true
3879      - name: Clean pytorch/builder checkout
3880        run: |
3881          # Remove any artifacts from the previous checkouts
3882          git clean -fxd
3883        working-directory: builder
3884      - name: Populate binary env
3885        shell: bash
3886        run: |
3887          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
3888      - name: Test PyTorch binary
3889        shell: bash
3890        run: |
3891          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
3892      - name: Wait until all sessions have drained
3893        shell: powershell
3894        working-directory: pytorch
3895        if: always()
3896        timeout-minutes: 120
3897        run: |
3898          .github\scripts\wait_for_ssh_to_drain.ps1
3899      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
3900        shell: powershell
3901        working-directory: pytorch
3902        if: always()
3903        run: |
3904          .github\scripts\kill_active_ssh_sessions.ps1
3905  wheel-py3_11-cuda12_4-upload:  # Uploading
3906    if: ${{ github.repository_owner == 'pytorch' }}
3907    permissions:
3908      id-token: write
3909      contents: read
3910    needs: wheel-py3_11-cuda12_4-test
3911    with:
3912      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
3913      BUILDER_ROOT: ${{ github.workspace }}/builder
3914      PACKAGE_TYPE: wheel
3915      # TODO: This is a legacy variable that we eventually want to get rid of in
3916      #       favor of GPU_ARCH_VERSION
3917      DESIRED_CUDA: cu124
3918      GPU_ARCH_VERSION: 12.4
3919      GPU_ARCH_TYPE: cuda
3920      DESIRED_PYTHON: "3.11"
3921      build_name: wheel-py3_11-cuda12_4
3922    secrets:
3923      github-token: ${{ secrets.GITHUB_TOKEN }}
3924      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
3925      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
3926    uses: ./.github/workflows/_binary-upload.yml
3927  wheel-py3_12-cpu-build:
3928    if: ${{ github.repository_owner == 'pytorch' }}
3929    runs-on: windows.4xlarge
3930    timeout-minutes: 240
3931    env:
3932      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
3933      BUILDER_ROOT: ${{ github.workspace }}/builder
3934      PACKAGE_TYPE: wheel
3935      # TODO: This is a legacy variable that we eventually want to get rid of in
3936      #       favor of GPU_ARCH_VERSION
3937      DESIRED_CUDA: cpu
3938      GPU_ARCH_TYPE: cpu
3939      SKIP_ALL_TESTS: 1
3940      DESIRED_PYTHON: "3.12"
3941      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
3942    steps:
3943      - name: Display EC2 information
3944        shell: bash
3945        run: |
3946          set -euo pipefail
3947          function get_ec2_metadata() {
3948            # Pulled from instance metadata endpoint for EC2
3949            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
3950            category=$1
3951            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
3952          }
3953          echo "ami-id: $(get_ec2_metadata ami-id)"
3954          echo "instance-id: $(get_ec2_metadata instance-id)"
3955          echo "instance-type: $(get_ec2_metadata instance-type)"
3956          echo "system info $(uname -a)"
3957      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
3958        uses: pytorch/test-infra/.github/actions/setup-ssh@main
3959        continue-on-error: true
3960        with:
3961          github-secret: ${{ secrets.GITHUB_TOKEN }}
3962      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
3963      - name: Enable long paths on Windows
3964        shell: powershell
3965        run: |
3966          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
3967      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
3968      # removed once Windows Defender is removed from the AMI
3969      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
3970        continue-on-error: true
3971        shell: powershell
3972        run: |
3973          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
3974          # Let's both exclude the path and disable Windows Defender completely just to be sure
3975          # that it doesn't interfere
3976          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
3977      # NOTE: These environment variables are put here so that they can be applied on every job equally
3978      #       They are also here because setting them at a workflow level doesn't give us access to the
3979      #       runner.temp variable, which we need.
3980      - name: Populate binary env
3981        shell: bash
3982        run: |
3983          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
3984          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
3985          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
3986      - name: Checkout PyTorch
3987        uses: malfet/checkout@silent-checkout
3988        with:
3989          submodules: recursive
3990          path: pytorch
3991          quiet-checkout: true
3992      - name: Clean PyTorch checkout
3993        run: |
3994          # Remove any artifacts from the previous checkouts
3995          git clean -fxd
3996        working-directory: pytorch
3997      - name: Checkout pytorch/builder
3998        uses: malfet/checkout@silent-checkout
3999        with:
4000          ref: release/2.4
4001          submodules: recursive
4002          repository: pytorch/builder
4003          path: builder
4004          quiet-checkout: true
4005      - name: Clean pytorch/builder checkout
4006        run: |
4007          # Remove any artifacts from the previous checkouts
4008          git clean -fxd
4009        working-directory: builder
4010      - name: Populate binary env
4011        shell: bash
4012        run: |
4013          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
4014      - name: Build PyTorch binary
4015        shell: bash
4016        run: |
4017          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
4018      - uses: actions/upload-artifact@v3
4019        if: always()
4020        with:
4021          name: wheel-py3_12-cpu
4022          retention-days: 14
4023          if-no-files-found: error
4024          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
4025      - name: Wait until all sessions have drained
4026        shell: powershell
4027        working-directory: pytorch
4028        if: always()
4029        timeout-minutes: 120
4030        run: |
4031          .github\scripts\wait_for_ssh_to_drain.ps1
4032      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
4033        shell: powershell
4034        working-directory: pytorch
4035        if: always()
4036        run: |
4037          .github\scripts\kill_active_ssh_sessions.ps1
4038  wheel-py3_12-cpu-test:  # Testing
4039    if: ${{ github.repository_owner == 'pytorch' }}
4040    needs: wheel-py3_12-cpu-build
4041    runs-on: windows.4xlarge.nonephemeral
4042    timeout-minutes: 240
4043    env:
4044      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
4045      BUILDER_ROOT: ${{ github.workspace }}/builder
4046      PACKAGE_TYPE: wheel
4047      # TODO: This is a legacy variable that we eventually want to get rid of in
4048      #       favor of GPU_ARCH_VERSION
4049      DESIRED_CUDA: cpu
4050      GPU_ARCH_TYPE: cpu
4051      SKIP_ALL_TESTS: 1
4052      DESIRED_PYTHON: "3.12"
4053    steps:
4054      - name: Display EC2 information
4055        shell: bash
4056        run: |
4057          set -euo pipefail
4058          function get_ec2_metadata() {
4059            # Pulled from instance metadata endpoint for EC2
4060            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
4061            category=$1
4062            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
4063          }
4064          echo "ami-id: $(get_ec2_metadata ami-id)"
4065          echo "instance-id: $(get_ec2_metadata instance-id)"
4066          echo "instance-type: $(get_ec2_metadata instance-type)"
4067          echo "system info $(uname -a)"
4068      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
4069        uses: pytorch/test-infra/.github/actions/setup-ssh@main
4070        continue-on-error: true
4071        with:
4072          github-secret: ${{ secrets.GITHUB_TOKEN }}
4073      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
4074      - name: Enable long paths on Windows
4075        shell: powershell
4076        run: |
4077          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
4078      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
4079      # removed once Windows Defender is removed from the AMI
4080      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
4081        continue-on-error: true
4082        shell: powershell
4083        run: |
4084          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
4085          # Let's both exclude the path and disable Windows Defender completely just to be sure
4086          # that it doesn't interfere
4087          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
4088      # NOTE: These environment variables are put here so that they can be applied on every job equally
4089      #       They are also here because setting them at a workflow level doesn't give us access to the
4090      #       runner.temp variable, which we need.
4091      - name: Populate binary env
4092        shell: bash
4093        run: |
4094          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
4095          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
4096          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
4097      - uses: actions/download-artifact@v3
4098        name: Download Build Artifacts
4099        with:
4100          name: wheel-py3_12-cpu
4101          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
4102      - name: Checkout PyTorch
4103        uses: malfet/checkout@silent-checkout
4104        with:
4105          submodules: recursive
4106          path: pytorch
4107          quiet-checkout: true
4108      - name: Clean PyTorch checkout
4109        run: |
4110          # Remove any artifacts from the previous checkouts
4111          git clean -fxd
4112        working-directory: pytorch
4113      - name: Checkout pytorch/builder
4114        uses: malfet/checkout@silent-checkout
4115        with:
4116          ref: release/2.4
4117          submodules: recursive
4118          repository: pytorch/builder
4119          path: builder
4120          quiet-checkout: true
4121      - name: Clean pytorch/builder checkout
4122        run: |
4123          # Remove any artifacts from the previous checkouts
4124          git clean -fxd
4125        working-directory: builder
4126      - name: Populate binary env
4127        shell: bash
4128        run: |
4129          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
4130      - name: Test PyTorch binary
4131        shell: bash
4132        run: |
4133          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
4134      - name: Wait until all sessions have drained
4135        shell: powershell
4136        working-directory: pytorch
4137        if: always()
4138        timeout-minutes: 120
4139        run: |
4140          .github\scripts\wait_for_ssh_to_drain.ps1
4141      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
4142        shell: powershell
4143        working-directory: pytorch
4144        if: always()
4145        run: |
4146          .github\scripts\kill_active_ssh_sessions.ps1
4147  wheel-py3_12-cpu-upload:  # Uploading
4148    if: ${{ github.repository_owner == 'pytorch' }}
4149    permissions:
4150      id-token: write
4151      contents: read
4152    needs: wheel-py3_12-cpu-test
4153    with:
4154      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
4155      BUILDER_ROOT: ${{ github.workspace }}/builder
4156      PACKAGE_TYPE: wheel
4157      # TODO: This is a legacy variable that we eventually want to get rid of in
4158      #       favor of GPU_ARCH_VERSION
4159      DESIRED_CUDA: cpu
4160      GPU_ARCH_TYPE: cpu
4161      DESIRED_PYTHON: "3.12"
4162      build_name: wheel-py3_12-cpu
4163    secrets:
4164      github-token: ${{ secrets.GITHUB_TOKEN }}
4165      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
4166      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
4167    uses: ./.github/workflows/_binary-upload.yml
4168  wheel-py3_12-cuda11_8-build:
4169    if: ${{ github.repository_owner == 'pytorch' }}
4170    runs-on: windows.4xlarge
4171    timeout-minutes: 240
4172    env:
4173      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
4174      BUILDER_ROOT: ${{ github.workspace }}/builder
4175      PACKAGE_TYPE: wheel
4176      # TODO: This is a legacy variable that we eventually want to get rid of in
4177      #       favor of GPU_ARCH_VERSION
4178      DESIRED_CUDA: cu118
4179      GPU_ARCH_VERSION: 11.8
4180      GPU_ARCH_TYPE: cuda
4181      SKIP_ALL_TESTS: 1
4182      DESIRED_PYTHON: "3.12"
4183      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
4184    steps:
4185      - name: Display EC2 information
4186        shell: bash
4187        run: |
4188          set -euo pipefail
4189          function get_ec2_metadata() {
4190            # Pulled from instance metadata endpoint for EC2
4191            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
4192            category=$1
4193            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
4194          }
4195          echo "ami-id: $(get_ec2_metadata ami-id)"
4196          echo "instance-id: $(get_ec2_metadata instance-id)"
4197          echo "instance-type: $(get_ec2_metadata instance-type)"
4198          echo "system info $(uname -a)"
4199      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
4200        uses: pytorch/test-infra/.github/actions/setup-ssh@main
4201        continue-on-error: true
4202        with:
4203          github-secret: ${{ secrets.GITHUB_TOKEN }}
4204      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
4205      - name: Enable long paths on Windows
4206        shell: powershell
4207        run: |
4208          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
4209      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
4210      # removed once Windows Defender is removed from the AMI
4211      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
4212        continue-on-error: true
4213        shell: powershell
4214        run: |
4215          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
4216          # Let's both exclude the path and disable Windows Defender completely just to be sure
4217          # that it doesn't interfere
4218          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
4219      # NOTE: These environment variables are put here so that they can be applied on every job equally
4220      #       They are also here because setting them at a workflow level doesn't give us access to the
4221      #       runner.temp variable, which we need.
4222      - name: Populate binary env
4223        shell: bash
4224        run: |
4225          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
4226          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
4227          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
4228      - name: Checkout PyTorch
4229        uses: malfet/checkout@silent-checkout
4230        with:
4231          submodules: recursive
4232          path: pytorch
4233          quiet-checkout: true
4234      - name: Clean PyTorch checkout
4235        run: |
4236          # Remove any artifacts from the previous checkouts
4237          git clean -fxd
4238        working-directory: pytorch
4239      - name: Checkout pytorch/builder
4240        uses: malfet/checkout@silent-checkout
4241        with:
4242          ref: release/2.4
4243          submodules: recursive
4244          repository: pytorch/builder
4245          path: builder
4246          quiet-checkout: true
4247      - name: Clean pytorch/builder checkout
4248        run: |
4249          # Remove any artifacts from the previous checkouts
4250          git clean -fxd
4251        working-directory: builder
4252      - name: Populate binary env
4253        shell: bash
4254        run: |
4255          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
4256      - name: Build PyTorch binary
4257        shell: bash
4258        run: |
4259          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
4260      - uses: actions/upload-artifact@v3
4261        if: always()
4262        with:
4263          name: wheel-py3_12-cuda11_8
4264          retention-days: 14
4265          if-no-files-found: error
4266          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
4267      - name: Wait until all sessions have drained
4268        shell: powershell
4269        working-directory: pytorch
4270        if: always()
4271        timeout-minutes: 120
4272        run: |
4273          .github\scripts\wait_for_ssh_to_drain.ps1
4274      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
4275        shell: powershell
4276        working-directory: pytorch
4277        if: always()
4278        run: |
4279          .github\scripts\kill_active_ssh_sessions.ps1
4280  wheel-py3_12-cuda11_8-test:  # Testing
4281    if: ${{ github.repository_owner == 'pytorch' }}
4282    needs: wheel-py3_12-cuda11_8-build
4283    runs-on: windows.8xlarge.nvidia.gpu
4284    timeout-minutes: 240
4285    env:
4286      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
4287      BUILDER_ROOT: ${{ github.workspace }}/builder
4288      PACKAGE_TYPE: wheel
4289      # TODO: This is a legacy variable that we eventually want to get rid of in
4290      #       favor of GPU_ARCH_VERSION
4291      DESIRED_CUDA: cu118
4292      GPU_ARCH_VERSION: 11.8
4293      GPU_ARCH_TYPE: cuda
4294      SKIP_ALL_TESTS: 1
4295      DESIRED_PYTHON: "3.12"
4296    steps:
4297      - name: Display EC2 information
4298        shell: bash
4299        run: |
4300          set -euo pipefail
4301          function get_ec2_metadata() {
4302            # Pulled from instance metadata endpoint for EC2
4303            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
4304            category=$1
4305            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
4306          }
4307          echo "ami-id: $(get_ec2_metadata ami-id)"
4308          echo "instance-id: $(get_ec2_metadata instance-id)"
4309          echo "instance-type: $(get_ec2_metadata instance-type)"
4310          echo "system info $(uname -a)"
4311      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
4312        uses: pytorch/test-infra/.github/actions/setup-ssh@main
4313        continue-on-error: true
4314        with:
4315          github-secret: ${{ secrets.GITHUB_TOKEN }}
4316      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
4317      - name: Enable long paths on Windows
4318        shell: powershell
4319        run: |
4320          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
4321      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
4322      # removed once Windows Defender is removed from the AMI
4323      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
4324        continue-on-error: true
4325        shell: powershell
4326        run: |
4327          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
4328          # Let's both exclude the path and disable Windows Defender completely just to be sure
4329          # that it doesn't interfere
4330          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
4331      # NOTE: These environment variables are put here so that they can be applied on every job equally
4332      #       They are also here because setting them at a workflow level doesn't give us access to the
4333      #       runner.temp variable, which we need.
4334      - name: Populate binary env
4335        shell: bash
4336        run: |
4337          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
4338          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
4339          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
4340      - uses: actions/download-artifact@v3
4341        name: Download Build Artifacts
4342        with:
4343          name: wheel-py3_12-cuda11_8
4344          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
4345      - name: Checkout PyTorch
4346        uses: malfet/checkout@silent-checkout
4347        with:
4348          submodules: recursive
4349          path: pytorch
4350          quiet-checkout: true
4351      - name: Clean PyTorch checkout
4352        run: |
4353          # Remove any artifacts from the previous checkouts
4354          git clean -fxd
4355        working-directory: pytorch
4356      - name: Checkout pytorch/builder
4357        uses: malfet/checkout@silent-checkout
4358        with:
4359          ref: release/2.4
4360          submodules: recursive
4361          repository: pytorch/builder
4362          path: builder
4363          quiet-checkout: true
4364      - name: Clean pytorch/builder checkout
4365        run: |
4366          # Remove any artifacts from the previous checkouts
4367          git clean -fxd
4368        working-directory: builder
4369      - name: Populate binary env
4370        shell: bash
4371        run: |
4372          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
4373      - name: Test PyTorch binary
4374        shell: bash
4375        run: |
4376          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
4377      - name: Wait until all sessions have drained
4378        shell: powershell
4379        working-directory: pytorch
4380        if: always()
4381        timeout-minutes: 120
4382        run: |
4383          .github\scripts\wait_for_ssh_to_drain.ps1
4384      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
4385        shell: powershell
4386        working-directory: pytorch
4387        if: always()
4388        run: |
4389          .github\scripts\kill_active_ssh_sessions.ps1
4390  wheel-py3_12-cuda11_8-upload:  # Uploading
4391    if: ${{ github.repository_owner == 'pytorch' }}
4392    permissions:
4393      id-token: write
4394      contents: read
4395    needs: wheel-py3_12-cuda11_8-test
4396    with:
4397      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
4398      BUILDER_ROOT: ${{ github.workspace }}/builder
4399      PACKAGE_TYPE: wheel
4400      # TODO: This is a legacy variable that we eventually want to get rid of in
4401      #       favor of GPU_ARCH_VERSION
4402      DESIRED_CUDA: cu118
4403      GPU_ARCH_VERSION: 11.8
4404      GPU_ARCH_TYPE: cuda
4405      DESIRED_PYTHON: "3.12"
4406      build_name: wheel-py3_12-cuda11_8
4407    secrets:
4408      github-token: ${{ secrets.GITHUB_TOKEN }}
4409      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
4410      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
4411    uses: ./.github/workflows/_binary-upload.yml
4412  wheel-py3_12-cuda12_1-build:
4413    if: ${{ github.repository_owner == 'pytorch' }}
4414    runs-on: windows.4xlarge
4415    timeout-minutes: 240
4416    env:
4417      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
4418      BUILDER_ROOT: ${{ github.workspace }}/builder
4419      PACKAGE_TYPE: wheel
4420      # TODO: This is a legacy variable that we eventually want to get rid of in
4421      #       favor of GPU_ARCH_VERSION
4422      DESIRED_CUDA: cu121
4423      GPU_ARCH_VERSION: 12.1
4424      GPU_ARCH_TYPE: cuda
4425      SKIP_ALL_TESTS: 1
4426      DESIRED_PYTHON: "3.12"
4427      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
4428    steps:
4429      - name: Display EC2 information
4430        shell: bash
4431        run: |
4432          set -euo pipefail
4433          function get_ec2_metadata() {
4434            # Pulled from instance metadata endpoint for EC2
4435            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
4436            category=$1
4437            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
4438          }
4439          echo "ami-id: $(get_ec2_metadata ami-id)"
4440          echo "instance-id: $(get_ec2_metadata instance-id)"
4441          echo "instance-type: $(get_ec2_metadata instance-type)"
4442          echo "system info $(uname -a)"
4443      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
4444        uses: pytorch/test-infra/.github/actions/setup-ssh@main
4445        continue-on-error: true
4446        with:
4447          github-secret: ${{ secrets.GITHUB_TOKEN }}
4448      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
4449      - name: Enable long paths on Windows
4450        shell: powershell
4451        run: |
4452          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
4453      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
4454      # removed once Windows Defender is removed from the AMI
4455      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
4456        continue-on-error: true
4457        shell: powershell
4458        run: |
4459          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
4460          # Let's both exclude the path and disable Windows Defender completely just to be sure
4461          # that it doesn't interfere
4462          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
4463      # NOTE: These environment variables are put here so that they can be applied on every job equally
4464      #       They are also here because setting them at a workflow level doesn't give us access to the
4465      #       runner.temp variable, which we need.
4466      - name: Populate binary env
4467        shell: bash
4468        run: |
4469          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
4470          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
4471          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
4472      - name: Checkout PyTorch
4473        uses: malfet/checkout@silent-checkout
4474        with:
4475          submodules: recursive
4476          path: pytorch
4477          quiet-checkout: true
4478      - name: Clean PyTorch checkout
4479        run: |
4480          # Remove any artifacts from the previous checkouts
4481          git clean -fxd
4482        working-directory: pytorch
4483      - name: Checkout pytorch/builder
4484        uses: malfet/checkout@silent-checkout
4485        with:
4486          ref: release/2.4
4487          submodules: recursive
4488          repository: pytorch/builder
4489          path: builder
4490          quiet-checkout: true
4491      - name: Clean pytorch/builder checkout
4492        run: |
4493          # Remove any artifacts from the previous checkouts
4494          git clean -fxd
4495        working-directory: builder
4496      - name: Populate binary env
4497        shell: bash
4498        run: |
4499          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
4500      - name: Build PyTorch binary
4501        shell: bash
4502        run: |
4503          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
4504      - uses: actions/upload-artifact@v3
4505        if: always()
4506        with:
4507          name: wheel-py3_12-cuda12_1
4508          retention-days: 14
4509          if-no-files-found: error
4510          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
4511      - name: Wait until all sessions have drained
4512        shell: powershell
4513        working-directory: pytorch
4514        if: always()
4515        timeout-minutes: 120
4516        run: |
4517          .github\scripts\wait_for_ssh_to_drain.ps1
4518      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
4519        shell: powershell
4520        working-directory: pytorch
4521        if: always()
4522        run: |
4523          .github\scripts\kill_active_ssh_sessions.ps1
4524  wheel-py3_12-cuda12_1-test:  # Testing
4525    if: ${{ github.repository_owner == 'pytorch' }}
4526    needs: wheel-py3_12-cuda12_1-build
4527    runs-on: windows.8xlarge.nvidia.gpu
4528    timeout-minutes: 240
4529    env:
4530      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
4531      BUILDER_ROOT: ${{ github.workspace }}/builder
4532      PACKAGE_TYPE: wheel
4533      # TODO: This is a legacy variable that we eventually want to get rid of in
4534      #       favor of GPU_ARCH_VERSION
4535      DESIRED_CUDA: cu121
4536      GPU_ARCH_VERSION: 12.1
4537      GPU_ARCH_TYPE: cuda
4538      SKIP_ALL_TESTS: 1
4539      DESIRED_PYTHON: "3.12"
4540    steps:
4541      - name: Display EC2 information
4542        shell: bash
4543        run: |
4544          set -euo pipefail
4545          function get_ec2_metadata() {
4546            # Pulled from instance metadata endpoint for EC2
4547            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
4548            category=$1
4549            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
4550          }
4551          echo "ami-id: $(get_ec2_metadata ami-id)"
4552          echo "instance-id: $(get_ec2_metadata instance-id)"
4553          echo "instance-type: $(get_ec2_metadata instance-type)"
4554          echo "system info $(uname -a)"
4555      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
4556        uses: pytorch/test-infra/.github/actions/setup-ssh@main
4557        continue-on-error: true
4558        with:
4559          github-secret: ${{ secrets.GITHUB_TOKEN }}
4560      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
4561      - name: Enable long paths on Windows
4562        shell: powershell
4563        run: |
4564          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
4565      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
4566      # removed once Windows Defender is removed from the AMI
4567      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
4568        continue-on-error: true
4569        shell: powershell
4570        run: |
4571          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
4572          # Let's both exclude the path and disable Windows Defender completely just to be sure
4573          # that it doesn't interfere
4574          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
4575      # NOTE: These environment variables are put here so that they can be applied on every job equally
4576      #       They are also here because setting them at a workflow level doesn't give us access to the
4577      #       runner.temp variable, which we need.
4578      - name: Populate binary env
4579        shell: bash
4580        run: |
4581          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
4582          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
4583          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
4584      - uses: actions/download-artifact@v3
4585        name: Download Build Artifacts
4586        with:
4587          name: wheel-py3_12-cuda12_1
4588          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
4589      - name: Checkout PyTorch
4590        uses: malfet/checkout@silent-checkout
4591        with:
4592          submodules: recursive
4593          path: pytorch
4594          quiet-checkout: true
4595      - name: Clean PyTorch checkout
4596        run: |
4597          # Remove any artifacts from the previous checkouts
4598          git clean -fxd
4599        working-directory: pytorch
4600      - name: Checkout pytorch/builder
4601        uses: malfet/checkout@silent-checkout
4602        with:
4603          ref: release/2.4
4604          submodules: recursive
4605          repository: pytorch/builder
4606          path: builder
4607          quiet-checkout: true
4608      - name: Clean pytorch/builder checkout
4609        run: |
4610          # Remove any artifacts from the previous checkouts
4611          git clean -fxd
4612        working-directory: builder
4613      - name: Populate binary env
4614        shell: bash
4615        run: |
4616          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
4617      - name: Test PyTorch binary
4618        shell: bash
4619        run: |
4620          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
4621      - name: Wait until all sessions have drained
4622        shell: powershell
4623        working-directory: pytorch
4624        if: always()
4625        timeout-minutes: 120
4626        run: |
4627          .github\scripts\wait_for_ssh_to_drain.ps1
4628      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
4629        shell: powershell
4630        working-directory: pytorch
4631        if: always()
4632        run: |
4633          .github\scripts\kill_active_ssh_sessions.ps1
4634  wheel-py3_12-cuda12_1-upload:  # Uploading
4635    if: ${{ github.repository_owner == 'pytorch' }}
4636    permissions:
4637      id-token: write
4638      contents: read
4639    needs: wheel-py3_12-cuda12_1-test
4640    with:
4641      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
4642      BUILDER_ROOT: ${{ github.workspace }}/builder
4643      PACKAGE_TYPE: wheel
4644      # TODO: This is a legacy variable that we eventually want to get rid of in
4645      #       favor of GPU_ARCH_VERSION
4646      DESIRED_CUDA: cu121
4647      GPU_ARCH_VERSION: 12.1
4648      GPU_ARCH_TYPE: cuda
4649      DESIRED_PYTHON: "3.12"
4650      build_name: wheel-py3_12-cuda12_1
4651    secrets:
4652      github-token: ${{ secrets.GITHUB_TOKEN }}
4653      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
4654      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
4655    uses: ./.github/workflows/_binary-upload.yml
4656  wheel-py3_12-cuda12_4-build:
4657    if: ${{ github.repository_owner == 'pytorch' }}
4658    runs-on: windows.4xlarge
4659    timeout-minutes: 240
4660    env:
4661      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
4662      BUILDER_ROOT: ${{ github.workspace }}/builder
4663      PACKAGE_TYPE: wheel
4664      # TODO: This is a legacy variable that we eventually want to get rid of in
4665      #       favor of GPU_ARCH_VERSION
4666      DESIRED_CUDA: cu124
4667      GPU_ARCH_VERSION: 12.4
4668      GPU_ARCH_TYPE: cuda
4669      SKIP_ALL_TESTS: 1
4670      DESIRED_PYTHON: "3.12"
4671      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-runtime-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cuda-cupti-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cudnn-cu12==9.1.0.70; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cublas-cu12==12.1.3.1; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cufft-cu12==11.0.2.54; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-curand-cu12==10.3.2.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusolver-cu12==11.4.5.107; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-cusparse-cu12==12.1.0.106; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nccl-cu12==2.20.5; platform_system == 'Linux' and platform_machine == 'x86_64' | nvidia-nvtx-cu12==12.1.105; platform_system == 'Linux' and platform_machine == 'x86_64'
4672    steps:
4673      - name: Display EC2 information
4674        shell: bash
4675        run: |
4676          set -euo pipefail
4677          function get_ec2_metadata() {
4678            # Pulled from instance metadata endpoint for EC2
4679            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
4680            category=$1
4681            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
4682          }
4683          echo "ami-id: $(get_ec2_metadata ami-id)"
4684          echo "instance-id: $(get_ec2_metadata instance-id)"
4685          echo "instance-type: $(get_ec2_metadata instance-type)"
4686          echo "system info $(uname -a)"
4687      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
4688        uses: pytorch/test-infra/.github/actions/setup-ssh@main
4689        continue-on-error: true
4690        with:
4691          github-secret: ${{ secrets.GITHUB_TOKEN }}
4692      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
4693      - name: Enable long paths on Windows
4694        shell: powershell
4695        run: |
4696          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
4697      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
4698      # removed once Windows Defender is removed from the AMI
4699      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
4700        continue-on-error: true
4701        shell: powershell
4702        run: |
4703          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
4704          # Let's both exclude the path and disable Windows Defender completely just to be sure
4705          # that it doesn't interfere
4706          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
4707      # NOTE: These environment variables are put here so that they can be applied on every job equally
4708      #       They are also here because setting them at a workflow level doesn't give us access to the
4709      #       runner.temp variable, which we need.
4710      - name: Populate binary env
4711        shell: bash
4712        run: |
4713          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
4714          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
4715          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
4716      - name: Checkout PyTorch
4717        uses: malfet/checkout@silent-checkout
4718        with:
4719          submodules: recursive
4720          path: pytorch
4721          quiet-checkout: true
4722      - name: Clean PyTorch checkout
4723        run: |
4724          # Remove any artifacts from the previous checkouts
4725          git clean -fxd
4726        working-directory: pytorch
4727      - name: Checkout pytorch/builder
4728        uses: malfet/checkout@silent-checkout
4729        with:
4730          ref: release/2.4
4731          submodules: recursive
4732          repository: pytorch/builder
4733          path: builder
4734          quiet-checkout: true
4735      - name: Clean pytorch/builder checkout
4736        run: |
4737          # Remove any artifacts from the previous checkouts
4738          git clean -fxd
4739        working-directory: builder
4740      - name: Populate binary env
4741        shell: bash
4742        run: |
4743          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
4744      - name: Build PyTorch binary
4745        shell: bash
4746        run: |
4747          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
4748      - uses: actions/upload-artifact@v3
4749        if: always()
4750        with:
4751          name: wheel-py3_12-cuda12_4
4752          retention-days: 14
4753          if-no-files-found: error
4754          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
4755      - name: Wait until all sessions have drained
4756        shell: powershell
4757        working-directory: pytorch
4758        if: always()
4759        timeout-minutes: 120
4760        run: |
4761          .github\scripts\wait_for_ssh_to_drain.ps1
4762      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
4763        shell: powershell
4764        working-directory: pytorch
4765        if: always()
4766        run: |
4767          .github\scripts\kill_active_ssh_sessions.ps1
4768  wheel-py3_12-cuda12_4-test:  # Testing
4769    if: ${{ github.repository_owner == 'pytorch' }}
4770    needs: wheel-py3_12-cuda12_4-build
4771    runs-on: windows.8xlarge.nvidia.gpu
4772    timeout-minutes: 240
4773    env:
4774      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
4775      BUILDER_ROOT: ${{ github.workspace }}/builder
4776      PACKAGE_TYPE: wheel
4777      # TODO: This is a legacy variable that we eventually want to get rid of in
4778      #       favor of GPU_ARCH_VERSION
4779      DESIRED_CUDA: cu124
4780      GPU_ARCH_VERSION: 12.4
4781      GPU_ARCH_TYPE: cuda
4782      SKIP_ALL_TESTS: 1
4783      DESIRED_PYTHON: "3.12"
4784    steps:
4785      - name: Display EC2 information
4786        shell: bash
4787        run: |
4788          set -euo pipefail
4789          function get_ec2_metadata() {
4790            # Pulled from instance metadata endpoint for EC2
4791            # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
4792            category=$1
4793            curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
4794          }
4795          echo "ami-id: $(get_ec2_metadata ami-id)"
4796          echo "instance-id: $(get_ec2_metadata instance-id)"
4797          echo "instance-type: $(get_ec2_metadata instance-type)"
4798          echo "system info $(uname -a)"
4799      - name: "[FB EMPLOYEES] Enable SSH (Click me for login details)"
4800        uses: pytorch/test-infra/.github/actions/setup-ssh@main
4801        continue-on-error: true
4802        with:
4803          github-secret: ${{ secrets.GITHUB_TOKEN }}
4804      # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
4805      - name: Enable long paths on Windows
4806        shell: powershell
4807        run: |
4808          Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
4809      # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
4810      # removed once Windows Defender is removed from the AMI
4811      - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
4812        continue-on-error: true
4813        shell: powershell
4814        run: |
4815          Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TEMP -ErrorAction Ignore
4816          # Let's both exclude the path and disable Windows Defender completely just to be sure
4817          # that it doesn't interfere
4818          Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
4819      # NOTE: These environment variables are put here so that they can be applied on every job equally
4820      #       They are also here because setting them at a workflow level doesn't give us access to the
4821      #       runner.temp variable, which we need.
4822      - name: Populate binary env
4823        shell: bash
4824        run: |
4825          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
4826          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
4827          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
4828      - uses: actions/download-artifact@v3
4829        name: Download Build Artifacts
4830        with:
4831          name: wheel-py3_12-cuda12_4
4832          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
4833      - name: Checkout PyTorch
4834        uses: malfet/checkout@silent-checkout
4835        with:
4836          submodules: recursive
4837          path: pytorch
4838          quiet-checkout: true
4839      - name: Clean PyTorch checkout
4840        run: |
4841          # Remove any artifacts from the previous checkouts
4842          git clean -fxd
4843        working-directory: pytorch
4844      - name: Checkout pytorch/builder
4845        uses: malfet/checkout@silent-checkout
4846        with:
4847          ref: release/2.4
4848          submodules: recursive
4849          repository: pytorch/builder
4850          path: builder
4851          quiet-checkout: true
4852      - name: Clean pytorch/builder checkout
4853        run: |
4854          # Remove any artifacts from the previous checkouts
4855          git clean -fxd
4856        working-directory: builder
4857      - name: Populate binary env
4858        shell: bash
4859        run: |
4860          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
4861      - name: Test PyTorch binary
4862        shell: bash
4863        run: |
4864          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
4865      - name: Wait until all sessions have drained
4866        shell: powershell
4867        working-directory: pytorch
4868        if: always()
4869        timeout-minutes: 120
4870        run: |
4871          .github\scripts\wait_for_ssh_to_drain.ps1
4872      - name: Kill active ssh sessions if still around (Useful if workflow was cancelled)
4873        shell: powershell
4874        working-directory: pytorch
4875        if: always()
4876        run: |
4877          .github\scripts\kill_active_ssh_sessions.ps1
4878  wheel-py3_12-cuda12_4-upload:  # Uploading
4879    if: ${{ github.repository_owner == 'pytorch' }}
4880    permissions:
4881      id-token: write
4882      contents: read
4883    needs: wheel-py3_12-cuda12_4-test
4884    with:
4885      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
4886      BUILDER_ROOT: ${{ github.workspace }}/builder
4887      PACKAGE_TYPE: wheel
4888      # TODO: This is a legacy variable that we eventually want to get rid of in
4889      #       favor of GPU_ARCH_VERSION
4890      DESIRED_CUDA: cu124
4891      GPU_ARCH_VERSION: 12.4
4892      GPU_ARCH_TYPE: cuda
4893      DESIRED_PYTHON: "3.12"
4894      build_name: wheel-py3_12-cuda12_4
4895    secrets:
4896      github-token: ${{ secrets.GITHUB_TOKEN }}
4897      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
4898      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
4899    uses: ./.github/workflows/_binary-upload.yml
4900