Skip to content

Commit 0f4730d

Browse files
committed
WIP: TST: Detect CUDA and install if necessary
1 parent 2fd2cfa commit 0f4730d

File tree

2 files changed

+574
-6
lines changed

2 files changed

+574
-6
lines changed

.github/workflows/notebooks.yml

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: Run notebooks
22

33
on:
4+
push:
5+
branches:
6+
- main
7+
- maint/*
8+
pull_request:
9+
branches:
10+
- main
11+
- maint/*
412
schedule:
513
- cron: '0 0 * * 1' # Every Monday at 00:00 UTC
614
# Allow job to be triggered manually from GitHub interface
@@ -33,6 +41,20 @@ jobs:
3341
python-version: ['3.12']
3442

3543
steps:
44+
- name: Free up disk space
45+
run: |
46+
echo "Disk space before cleanup:"
47+
df -h
48+
49+
# Remove big pre-installed packages
50+
sudo rm -rf /usr/share/dotnet
51+
sudo rm -rf /opt/ghc
52+
sudo rm -rf /usr/local/lib/android
53+
sudo apt-get clean
54+
55+
echo "Disk space after cleanup:"
56+
df -h
57+
3658
- name: Checkout repository
3759
uses: actions/checkout@v4
3860

@@ -41,16 +63,50 @@ jobs:
4163
with:
4264
python-version: ${{ matrix.python-version }}
4365

44-
- name: Check for nvcc and set CUDA flag
45-
id: detect-cuda
66+
- name: Check for nvcc and install CUDA if missing
67+
id: cuda
4668
run: |
47-
if command -v nvcc &> /dev/null; then
48-
echo "nvcc found: CUDA is available"
69+
if command -v nvcc > /dev/null; then
70+
echo "✅ nvcc is already installed"
71+
echo "HAS_CUDA=true" >> $GITHUB_ENV
72+
else
73+
echo "❌ nvcc not found, installing CUDA..."
74+
75+
UBUNTU_VERSION=$(lsb_release -rs)
76+
UBUNTU_CODENAME="ubuntu${UBUNTU_VERSION//./}"
77+
78+
echo "Detected Ubuntu version: $UBUNTU_CODENAME"
79+
80+
# Add NVIDIA APT repository
81+
wget https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_CODENAME}/x86_64/cuda-${UBUNTU_CODENAME}.pin
82+
sudo mv cuda-${UBUNTU_CODENAME}.pin /etc/apt/preferences.d/cuda-repository-pin-600
83+
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_CODENAME}/x86_64/3bf863cc.pub
84+
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_CODENAME}/x86_64/ /"
85+
sudo apt-get update
86+
87+
# Automatically get latest available cuda-toolkit version
88+
TOOLKIT=$(apt-cache search ^cuda-toolkit-[0-9]+-[0-9]+$ | awk '{print $1}' | sort -V | tail -n1)
89+
if [ -z "$TOOLKIT" ]; then
90+
echo "❌ No CUDA toolkit version found in repository."
91+
exit 1
92+
fi
93+
94+
echo "Installing CUDA toolkit: $TOOLKIT"
95+
sudo apt-get install -y $TOOLKIT
96+
97+
echo "/usr/local/cuda/bin" >> $GITHUB_PATH
4998
echo "HAS_CUDA=true" >> $GITHUB_ENV
99+
fi
100+
101+
- name: Confirm CUDA version
102+
run: |
103+
if [ "$HAS_CUDA" = "true" ]; then
104+
nvcc --version
50105
else
51-
echo "nvcc not found: CUDA is not available"
106+
echo "CUDA not available"
52107
echo "HAS_CUDA=false" >> $GITHUB_ENV
53108
fi
109+
echo $HAS_CUDA
54110
55111
- name: Install AFNI
56112
run: |
@@ -108,4 +164,24 @@ jobs:
108164
pip install tox
109165
110166
- name: Run notebooks with tox
111-
run: tox -e notebooks
167+
# run: tox -e notebooks
168+
run: |
169+
pip install nbconvert jupyter
170+
pip install nbval
171+
pip install nibabel
172+
pip install mriqc_learn
173+
pip install nipreps-synthstrip
174+
pip install dipy
175+
pip install joblib
176+
pip install "nipype>=1.5.1,<2.0"
177+
pip install "nitransforms>=22.0.0,<24"
178+
pip install numpy
179+
pip install nest-asyncio
180+
pip install scikit_learn
181+
pip install scipy
182+
pip install .
183+
# jupyter nbconvert --to notebook --execute ${{ github.workspace }}/docs/notebooks/bold_realignment.ipynb \
184+
# --output executed_bold_realignment.ipynb
185+
# jupyter nbconvert --to python ${{ github.workspace }}/docs/notebooks/bold_realignment.ipnb
186+
python ${{ github.workspace }}/docs/notebooks/bold_realignment.py
187+
# pytest -s --nbval ${{ github.workspace }}/docs/notebooks/bold_realignment.ipynb

0 commit comments

Comments
 (0)