pytorch

Форк
0
105 строк · 3.9 Кб
1
name: Setup Windows
2

3
description: Set up for windows jobs
4

5
inputs:
6
  cuda-version:
7
    description: which cuda version to install, 'cpu' for none
8
    required: true
9

10
runs:
11
  using: composite
12
  steps:
13
    - name: Display EC2 information
14
      shell: bash
15
      run: |
16
        set -euo pipefail
17
        function get_ec2_metadata() {
18
          # Pulled from instance metadata endpoint for EC2
19
          # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
20
          category=$1
21
          curl -fsSL "http://169.254.169.254/latest/meta-data/${category}"
22
        }
23
        echo "ami-id: $(get_ec2_metadata ami-id)"
24
        echo "instance-id: $(get_ec2_metadata instance-id)"
25
        echo "instance-type: $(get_ec2_metadata instance-type)"
26
        echo "system info $(uname -a)"
27

28
    # Needed for binary builds, see: https://github.com/pytorch/pytorch/issues/73339#issuecomment-1058981560
29
    - name: Enable long paths on Windows
30
      shell: powershell
31
      run: |
32
        Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
33

34
    - name: Setup conda
35
      shell: bash
36
      run: |
37
        # Windows conda is baked into the AMI at this location
38
        CONDA="C:\Jenkins\Miniconda3\condabin\conda.bat"
39

40
        {
41
          echo "CONDA_RUN=${CONDA} run --no-capture-output";
42
          echo "CONDA_BUILD=${CONDA} run conda-build";
43
          echo "CONDA_INSTALL=${CONDA} install";
44
        } >> "${GITHUB_ENV}"
45

46
    - name: Setup Python3
47
      shell: bash
48
      run: |
49
        set +e
50
        set -x
51

52
        PYTHON3=$(${CONDA_RUN} which python3)
53
        EXIT_CODE=$?
54

55
        if [[ "${EXIT_CODE}" == "0" ]]; then
56
          echo "Found Python3 at ${PYTHON3}, adding it into GITHUB_PATH"
57

58
          PYTHON_PATH=$(dirname "${PYTHON3}")
59
          echo "${PYTHON_PATH}" >> "${GITHUB_PATH}"
60
        else
61
          # According to https://docs.conda.io/en/latest/miniconda.html, we are using the Miniconda3
62
          # installation, which is Python 3 based. Its Python is default to Python 3. Further, there
63
          # is also the Miniconda installation that is Python 2 based, and both can be installed if
64
          # needed. In both cases, Python binary is just called python
65
          PYTHON=$(${CONDA_RUN} which python)
66
          EXIT_CODE=$?
67

68
          if [[ "${EXIT_CODE}" == "0" ]]; then
69
            echo "Found Python at ${PYTHON}, set Python3 alias and add it into GITHUB_PATH"
70

71
            PYTHON3=$(echo "${PYTHON}" | sed "s/python/python3/")
72
            # It's difficult to setup alias across GitHub action steps, so I just add a softlink
73
            # here pointing to Python
74
            ln -s "${PYTHON}" "${PYTHON3}"
75

76
            PYTHON_PATH=$(dirname "${PYTHON}")
77
            echo "${PYTHON_PATH}" >> "${GITHUB_PATH}"
78
          else
79
            echo "Found no Python using ${CONDA_RUN}"
80
          fi
81
        fi
82

83
    - name: Get temporary directory used by Windows Python
84
      shell: bash
85
      run: |
86
        TMPDIR=$(python -c 'import tempfile; print(tempfile.gettempdir());')
87
        echo "TMPDIR=${TMPDIR}" >> "${GITHUB_ENV}"
88

89
    # Since it's just a defensive command, the workflow should continue even the command fails. This step can be
90
    # removed once Windows Defender is removed from the AMI
91
    - name: Disables Windows Defender scheduled and real-time scanning for files in directories used by PyTorch
92
      continue-on-error: true
93
      shell: powershell
94
      run: |
95
        Add-MpPreference -ExclusionPath $(Get-Location).tostring(),$Env:TMPDIR,"C:\Jenkins\Miniconda3" -ErrorAction Ignore
96
        # Let's both exclude the path and disable Windows Defender completely just to be sure
97
        # that it doesn't interfere
98
        Set-MpPreference -DisableRealtimeMonitoring $True -ErrorAction Ignore
99

100
    - name: Install sysinternals handle tool
101
      continue-on-error: true
102
      shell: powershell
103
      run: |
104
        choco install handle -y
105
        handle C:\actions-runner\_work\
106

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.