Skip to content

Commit e519951

Browse files
committed
Enhance CUDA version detection in setup script and improve caching in GitHub Actions workflow
1 parent a2426b3 commit e519951

File tree

2 files changed

+44
-12
lines changed

2 files changed

+44
-12
lines changed

.ci/setup.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,24 @@ fi
8989
# Detect CUDA version
9090
echo "Detecting CUDA version..."
9191
if [ -d "/usr/local/cuda" ]; then
92-
DETECTED_CUDA=$(ls -la /usr/local/cuda | grep -o 'cuda-[0-9.]*' | head -1 | sed 's/cuda-//')
93-
if [ -n "$DETECTED_CUDA" ]; then
94-
CUDA_VERSION="$DETECTED_CUDA"
95-
echo "Found CUDA version: $CUDA_VERSION"
92+
# Use readlink to safely get the target of the symlink
93+
if [ -L "/usr/local/cuda" ]; then
94+
CUDA_TARGET=$(readlink /usr/local/cuda)
95+
if [[ "$CUDA_TARGET" =~ cuda-([0-9.]+) ]]; then
96+
DETECTED_CUDA="${BASH_REMATCH[1]}"
97+
CUDA_VERSION="$DETECTED_CUDA"
98+
echo "Found CUDA version: $CUDA_VERSION"
99+
fi
100+
else
101+
# If not a symlink, try to find cuda-* directories
102+
for cuda_dir in /usr/local/cuda-*; do
103+
if [ -d "$cuda_dir" ]; then
104+
DETECTED_CUDA=$(basename "$cuda_dir" | sed 's/cuda-//')
105+
CUDA_VERSION="$DETECTED_CUDA"
106+
echo "Found CUDA version: $CUDA_VERSION"
107+
break
108+
fi
109+
done
96110
fi
97111
export CUDA_HOME="/usr/local/cuda"
98112
else

.github/workflows/test.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,32 @@ jobs:
3434
with:
3535
python-version: "3.11"
3636

37+
- name: Cache pip dependencies
38+
uses: actions/cache@v3
39+
with:
40+
path: ~/.cache/pip
41+
key: ${{ runner.os }}-pip-3.11-${{ hashFiles('**/pyproject.toml') }}
42+
restore-keys: |
43+
${{ runner.os }}-pip-3.11-
44+
45+
- name: Cache Conda
46+
uses: actions/cache@v3
47+
with:
48+
path: /opt/miniconda3
49+
key: ${{ runner.os }}-conda-${{ hashFiles('.ci/setup.sh') }}
50+
restore-keys: |
51+
${{ runner.os }}-conda-
52+
53+
- name: Cache Triton build
54+
uses: actions/cache@v3
55+
with:
56+
path: |
57+
~/.triton
58+
/tmp/triton
59+
key: ${{ runner.os }}-triton-${{ hashFiles('.ci/install-triton.sh') }}
60+
restore-keys: |
61+
${{ runner.os }}-triton-
62+
3763
- name: Setup environment
3864
env:
3965
CONDA_ENV: tritonparse
@@ -54,14 +80,6 @@ jobs:
5480
run: |
5581
bash .ci/install-project.sh
5682
57-
- name: Cache pip dependencies
58-
uses: actions/cache@v3
59-
with:
60-
path: ~/.cache/pip
61-
key: ${{ runner.os }}-pip-3.11-${{ hashFiles('**/pyproject.toml') }}
62-
restore-keys: |
63-
${{ runner.os }}-pip-3.11-
64-
6583
- name: Run tests
6684
env:
6785
CONDA_ENV: tritonparse

0 commit comments

Comments
 (0)