Skip to content

Commit 5f52c3f

Browse files
committed
Update CI workflow to conditionally use CPU-only PyTorch and force pip reinstall
- Removed global environment variables for CPU-only PyTorch to allow flexibility across different runners (e.g., Gitea, local `act`). - Added a conditional check to set `PIP_EXTRA_INDEX_URL` and `TORCH_CPU_ONLY` only when running on GitHub Actions and not in `act`. - Updated the pip installation step to use `--force-reinstall` to resolve potential conflicts with Debian-managed packages.
1 parent 9e9af9f commit 5f52c3f

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

.github/workflows/notebook-test.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ jobs:
1212
NODE_EXTRA_CA_CERTS: /etc/ssl/certs/ca-certificates.crt
1313
SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt
1414
REQUESTS_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
15-
# Always use CPU-only PyTorch to ensure consistency and save resources
16-
PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu
17-
TORCH_CPU_ONLY: "true"
1815

1916
steps:
2017
- name: Check out repository
@@ -23,7 +20,14 @@ jobs:
2320
- name: Set environment variables
2421
run: |
2522
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
26-
23+
24+
# Detect if running on GitHub Actions (not Gitea or act)
25+
if [[ "${{ github.server_url }}" == "https://github.com" ]] && [[ -z "${{ env.ACT }}" ]]; then
26+
echo "Running on GitHub - using CPU-only PyTorch"
27+
echo "PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cpu" >> $GITHUB_ENV
28+
echo "TORCH_CPU_ONLY=true" >> $GITHUB_ENV
29+
fi
30+
2731
if [[ "${{ vars.IS_GITEA }}" == "true" ]]; then
2832
echo "Setting thread limits for Gitea runner"
2933
echo "OMP_NUM_THREADS=1" >> $GITHUB_ENV
@@ -91,8 +95,8 @@ jobs:
9195
sudo apt-get update
9296
sudo apt-get install -y python3.12 python3.12-venv python3.12-dev
9397
94-
# Install pip for Python 3.12
95-
curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3.12 - --break-system-packages
98+
# Install pip for Python 3.12 (force reinstall to avoid Debian package conflicts)
99+
curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3.12 - --break-system-packages --force-reinstall
96100
97101
sudo ln -sf /usr/bin/python3.12 /usr/local/bin/python
98102
sudo ln -sf /usr/bin/python3.12 /usr/local/bin/python3

0 commit comments

Comments
 (0)