Skip to content

Commit 2e6a334

Browse files
committed
a88801
1 parent 93e39ff commit 2e6a334

1 file changed

Lines changed: 116 additions & 36 deletions

File tree

.github/workflows/ci-gpu.yml

Lines changed: 116 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -126,44 +126,84 @@ jobs:
126126

127127
- name: Discover & use Python 3.12
128128
run: |
129-
# same discovery block as lint (copy-paste or reuse via action)
130-
python --version
129+
$candidates = @()
130+
if ($env:PY_DIR) { $candidates += $env:PY_DIR }
131+
$candidates += @(
132+
"R:\tools\python\3.12.10\x64",
133+
"R:\tools\python\3.12\x64",
134+
"C:\Python312",
135+
"C:\Python312\amd64",
136+
"$env:LocalAppData\Programs\Python\Python312"
137+
)
138+
$py = $null
139+
$pyLauncher = Get-Command py.exe -ErrorAction SilentlyContinue
140+
if ($pyLauncher) {
141+
try {
142+
$ver = & py -3.12 -c "import platform;print(platform.python_version())" 2>$null
143+
if ($LASTEXITCODE -eq 0 -and $ver) {
144+
$dir = & py -3.12 -c "import sys,os;print(os.path.dirname(sys.executable))"
145+
if ($LASTEXITCODE -eq 0 -and (Test-Path $dir)) { $py = Join-Path $dir "python.exe" }
146+
}
147+
} catch {}
148+
}
149+
if (-not $py) {
150+
foreach ($root in $candidates | Where-Object { $_ -and (Test-Path $_) }) {
151+
$exe = Join-Path $root "python.exe"
152+
if (Test-Path $exe) { $py = $exe; break }
153+
}
154+
}
155+
if (-not $py -and (Test-Path "R:\actions-runner")) {
156+
$found = Get-ChildItem -Path "R:\actions-runner" -Filter "python.exe" -File -Recurse -ErrorAction SilentlyContinue |
157+
Where-Object { $_.FullName -match "Python\\3\.12" } |
158+
Select-Object -First 1
159+
if ($found) { $py = $found.FullName }
160+
}
161+
if (-not $py) { Write-Error "Python 3.12 not found"; exit 1 }
162+
$pyDir = Split-Path $py -Parent
163+
$scriptsDir = Join-Path $pyDir "Scripts"
164+
$env:PATH = "$pyDir;$scriptsDir;$env:PATH"
165+
$pyDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
166+
$scriptsDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
167+
"PY_DIR=$pyDir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
168+
& "$py" --version
169+
& "$py" -m pip --version
131170
132-
- name: Cache pip
133-
uses: actions/cache@v4
134-
with:
135-
path: ${{ env.PIP_CACHE_DIR }}
136-
key: pip-${{ hashFiles('**/requirements*.txt', 'pyproject.toml') }}
137-
restore-keys: |
138-
pip-
139171
140-
- name: Install deps
141-
run: |
142-
python -m ensurepip --upgrade
143-
python -m pip install -U pip wheel setuptools --cache-dir $env:PIP_CACHE_DIR
144-
if (Test-Path "requirements.txt") { pip install -r requirements.txt --cache-dir $env:PIP_CACHE_DIR }
145-
if (Test-Path "requirements-dev.txt") { pip install -r requirements-dev.txt --cache-dir $env:PIP_CACHE_DIR }
146-
if (Test-Path "pyproject.toml") { pip install -e . --config-settings editable_mode=compat }
172+
- name: Cache pip
173+
uses: actions/cache@v4
174+
with:
175+
path: ${{ env.PIP_CACHE_DIR }}
176+
key: pip-${{ hashFiles('**/requirements*.txt', 'pyproject.toml') }}
177+
restore-keys: |
178+
pip-
147179
148-
- name: Print Python & Torch info
149-
continue-on-error: true
150-
run: |
151-
python - << 'PY'
152-
import platform, sys
153-
print("Python:", platform.python_version())
154-
try:
155-
import torch
156-
print("Torch:", torch.__version__)
157-
print("CUDA available:", torch.cuda.is_available())
158-
if torch.cuda.is_available():
159-
print("CUDA devices:", torch.cuda.device_count())
160-
except Exception as e:
161-
print("Torch not installed:", e)
162-
PY
180+
- name: Install deps
181+
run: |
182+
python -m ensurepip --upgrade
183+
python -m pip install -U pip wheel setuptools --cache-dir $env:PIP_CACHE_DIR
184+
if (Test-Path "requirements.txt") { pip install -r requirements.txt --cache-dir $env:PIP_CACHE_DIR }
185+
if (Test-Path "requirements-dev.txt") { pip install -r requirements-dev.txt --cache-dir $env:PIP_CACHE_DIR }
186+
if (Test-Path "pyproject.toml") { pip install -e . --config-settings editable_mode=compat }
163187
164-
- name: Run pytest (CPU-only)
165-
run: |
166-
pytest -q -m "not gpu and not gpu_cuda and not gpu_mps" --maxfail=1 --disable-warnings --log-cli-level=INFO
188+
- name: Print Python & Torch info
189+
continue-on-error: true
190+
run: |
191+
python - << 'PY'
192+
import platform, sys
193+
print("Python:", platform.python_version())
194+
try:
195+
import torch
196+
print("Torch:", torch.__version__)
197+
print("CUDA available:", torch.cuda.is_available())
198+
if torch.cuda.is_available():
199+
print("CUDA devices:", torch.cuda.device_count())
200+
except Exception as e:
201+
print("Torch not installed:", e)
202+
PY
203+
204+
- name: Run pytest (CPU-only)
205+
run: |
206+
pytest -q -m "not gpu and not gpu_cuda and not gpu_mps" --maxfail=1 --disable-warnings --log-cli-level=INFO
167207
168208
tests-gpu:
169209
name: Tests (GPU)
@@ -178,8 +218,48 @@ jobs:
178218

179219
- name: Discover & use Python 3.12
180220
run: |
181-
# same discovery block as lint
182-
python --version
221+
$candidates = @()
222+
if ($env:PY_DIR) { $candidates += $env:PY_DIR }
223+
$candidates += @(
224+
"R:\tools\python\3.12.10\x64",
225+
"R:\tools\python\3.12\x64",
226+
"C:\Python312",
227+
"C:\Python312\amd64",
228+
"$env:LocalAppData\Programs\Python\Python312"
229+
)
230+
$py = $null
231+
$pyLauncher = Get-Command py.exe -ErrorAction SilentlyContinue
232+
if ($pyLauncher) {
233+
try {
234+
$ver = & py -3.12 -c "import platform;print(platform.python_version())" 2>$null
235+
if ($LASTEXITCODE -eq 0 -and $ver) {
236+
$dir = & py -3.12 -c "import sys,os;print(os.path.dirname(sys.executable))"
237+
if ($LASTEXITCODE -eq 0 -and (Test-Path $dir)) { $py = Join-Path $dir "python.exe" }
238+
}
239+
} catch {}
240+
}
241+
if (-not $py) {
242+
foreach ($root in $candidates | Where-Object { $_ -and (Test-Path $_) }) {
243+
$exe = Join-Path $root "python.exe"
244+
if (Test-Path $exe) { $py = $exe; break }
245+
}
246+
}
247+
if (-not $py -and (Test-Path "R:\actions-runner")) {
248+
$found = Get-ChildItem -Path "R:\actions-runner" -Filter "python.exe" -File -Recurse -ErrorAction SilentlyContinue |
249+
Where-Object { $_.FullName -match "Python\\3\.12" } |
250+
Select-Object -First 1
251+
if ($found) { $py = $found.FullName }
252+
}
253+
if (-not $py) { Write-Error "Python 3.12 not found"; exit 1 }
254+
$pyDir = Split-Path $py -Parent
255+
$scriptsDir = Join-Path $pyDir "Scripts"
256+
$env:PATH = "$pyDir;$scriptsDir;$env:PATH"
257+
$pyDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
258+
$scriptsDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
259+
"PY_DIR=$pyDir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
260+
& "$py" --version
261+
& "$py" -m pip --version
262+
183263
184264
- name: Cache pip
185265
uses: actions/cache@v4

0 commit comments

Comments
 (0)