Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/scripts/use_cpu_torch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# CI runners have no GPU. The CUDA torch build pinned in poetry.lock sometimes
# segfaults while preloading its CUDA libraries on these runners, so swap in the
# CPU build of the same torch/torchvision versions after `poetry install`.
# Usage: use_cpu_torch.sh <python command>, e.g. "python" or "poetry run python".
set -euo pipefail
PY=${1:-python}

# Read versions from package metadata; importing torch here could crash.
pins=$($PY - <<'EOF'
from importlib.metadata import version
print(" ".join(f"{p}=={version(p).split('+')[0]}" for p in ("torch", "torchvision")))
EOF
)
$PY -m pip install --no-deps --force-reinstall \
--index-url https://download.pytorch.org/whl/cpu $pins
$PY -c "import torch; assert torch.version.cuda is None, torch.__version__; print('torch', torch.__version__)"
1 change: 1 addition & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
pip install flake8 pytest
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
poetry install
.github/scripts/use_cpu_torch.sh python
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- name: Install dependencies
run: |
poetry install
.github/scripts/use_cpu_torch.sh "poetry run python"
- name: Format with black
run: |
poetry run black .
Expand Down
Loading