|
9 | 9 | pull_request: |
10 | 10 |
|
11 | 11 | jobs: |
12 | | - torch_cpu: |
| 12 | + channel: |
13 | 13 | strategy: |
14 | 14 | matrix: |
15 | 15 | os: |
@@ -49,14 +49,96 @@ jobs: |
49 | 49 | - name: Collect environment information |
50 | 50 | run: python scripts/collect_env.py |
51 | 51 |
|
52 | | - - name: Install torch |
53 | | - run: ltt install --cpuonly --pytorch-channel=${{ matrix.pytorch-channel }} torch |
| 52 | + - name: Install PyTorch distributions |
| 53 | + run: |
| 54 | + ltt install --pytorch-channel=${{ matrix.pytorch-channel }} torch torchvision |
| 55 | + torchaudio |
54 | 56 |
|
55 | 57 | - name: Check if CPU only |
56 | 58 | shell: python |
57 | 59 | run: | |
58 | 60 | import sys |
59 | 61 | import torch |
60 | 62 |
|
61 | | - compiled_with_cuda = hasattr(torch._C, "_cuda_getDeviceCount") |
62 | | - sys.exit(compiled_with_cuda) |
| 63 | + cuda = torch.version.cuda |
| 64 | + print(f"cuda = {cuda}") |
| 65 | +
|
| 66 | + hip = torch.version.hip |
| 67 | + print(f"hip = {hip}") |
| 68 | +
|
| 69 | + sys.exit(cuda or hip) |
| 70 | +
|
| 71 | + computation-backend: |
| 72 | + strategy: |
| 73 | + matrix: |
| 74 | + os: |
| 75 | + - ubuntu-latest |
| 76 | + - windows-latest |
| 77 | + - macos-latest |
| 78 | + python-version: |
| 79 | + - "3.7" |
| 80 | + - "3.8" |
| 81 | + - "3.9" |
| 82 | + - "3.10" |
| 83 | + pytorch-computation-backend: |
| 84 | + - cpu |
| 85 | + - cu113 |
| 86 | + - cu116 |
| 87 | + exclude: |
| 88 | + - os: macos-latest |
| 89 | + pytorch-computation-backend: cu113 |
| 90 | + - os: macos-latest |
| 91 | + pytorch-computation-backend: cu116 |
| 92 | + include: |
| 93 | + - os: ubuntu-latest |
| 94 | + pytorch-computation-backend: cu102 |
| 95 | + # TODO: find a way to test this |
| 96 | + # - os: ubuntu-latest |
| 97 | + # pytorch-computation-backend: rocm5.1.1 |
| 98 | + fail-fast: false |
| 99 | + |
| 100 | + runs-on: ${{ matrix.os }} |
| 101 | + |
| 102 | + steps: |
| 103 | + - name: Checkout repository |
| 104 | + uses: actions/checkout@v2 |
| 105 | + with: |
| 106 | + fetch-depth: 0 |
| 107 | + |
| 108 | + - name: Setup development environment |
| 109 | + uses: ./.github/actions/setup-dev-env |
| 110 | + with: |
| 111 | + python-version: ${{ matrix.python-version }} |
| 112 | + |
| 113 | + - name: Collect environment information |
| 114 | + run: python scripts/collect_env.py |
| 115 | + |
| 116 | + - name: Install torch |
| 117 | + run: |
| 118 | + ltt install --pytorch-computation-backend=${{ |
| 119 | + matrix.pytorch-computation-backend }} torch==1.12.1 |
| 120 | + |
| 121 | + - name: Check computation backend |
| 122 | + shell: python |
| 123 | + run: | |
| 124 | + import sys |
| 125 | + import torch |
| 126 | + from light_the_torch._cb import ComputationBackend, CUDABackend, ROCmBackend, CPUBackend |
| 127 | +
|
| 128 | + expected = ComputationBackend.from_str("${{ matrix.pytorch-computation-backend }}") |
| 129 | +
|
| 130 | + cuda = torch.version.cuda |
| 131 | + print(f"cuda = {cuda}") |
| 132 | +
|
| 133 | + hip = torch.version.hip |
| 134 | + print(f"hip = {hip}") |
| 135 | +
|
| 136 | + if cuda: |
| 137 | + actual = CUDABackend.from_str(f"cu{torch.version.cuda}") |
| 138 | + elif hip: |
| 139 | + rocm = ".".join(torch.version.hip.split(".")[:2]) |
| 140 | + actual = ROCmBackend.from_str(f"rocm{rocm}") |
| 141 | + else: |
| 142 | + actual = CPUBackend() |
| 143 | +
|
| 144 | + sys.exit(actual != expected) |
0 commit comments