Skip to content

Commit

Permalink
refactor(workflows): rewrite setup CUDA Toolkit logic
Browse files Browse the repository at this point in the history
  • Loading branch information
XuehaiPan committed Feb 12, 2023
1 parent 773d140 commit 14b6b07
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
29 changes: 17 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
CUDA_VERSION: "11.7"

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -33,21 +36,23 @@ jobs:
update-environment: true

- name: Setup CUDA Toolkit
uses: Jimver/cuda-toolkit@v0.2.8
id: cuda-toolkit
with:
cuda: "11.7.0"
method: network
sub-packages: '["nvcc"]'
- run: |
CUDA_VERSION="${{steps.cuda-toolkit.outputs.cuda}}"
echo "CUDA_VERSION=${CUDA_VERSION}" >> "${GITHUB_ENV}"
PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cu$(echo "${CUDA_VERSION}" | cut -d'.' -f-2 | tr -d '.')"
run: |
CUDA_PKG_SUFFIX="$(echo "${CUDA_VERSION}" | cut -d'.' -f-2 | tr '.' '-')"
sudo apt-get update && sudo apt-get install wget --yes
(
source /etc/os-release
wget -O cuda-keyring.deb "https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${VERSION_ID//./}/$(uname -m)/cuda-keyring_1.0-1_all.deb"
sudo dpkg -i cuda-keyring.deb
)
sudo apt-get update && sudo apt-get install "cuda-minimal-build-${CUDA_PKG_SUFFIX}" --yes
echo "PATH=/usr/local/cuda/bin${PATH:+:${PATH}}" >> "${GITHUB_ENV}"
echo "LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" >> "${GITHUB_ENV}"
PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cu$(echo "${CUDA_PKG_SUFFIX}" | tr -d '-')"
echo "PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL}" >> "${GITHUB_ENV}"
echo "Installed CUDA version is: ${CUDA_VERSION}"
echo "CUDA install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
nvcc -V
/usr/local/cuda/bin/nvcc -V
echo "Torch index URL: ${PIP_EXTRA_INDEX_URL}"
- name: Upgrade pip
Expand Down
29 changes: 17 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
CUDA_VERSION: "11.7"

jobs:
test:
name: Test with CXX/CUDA extensions on ubuntu-latest
Expand All @@ -45,21 +48,23 @@ jobs:
update-environment: true

- name: Setup CUDA Toolkit
uses: Jimver/cuda-toolkit@v0.2.8
id: cuda-toolkit
with:
cuda: "11.7.0"
method: network
sub-packages: '["nvcc"]'
- run: |
CUDA_VERSION="${{steps.cuda-toolkit.outputs.cuda}}"
echo "CUDA_VERSION=${CUDA_VERSION}" >> "${GITHUB_ENV}"
PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cu$(echo "${CUDA_VERSION}" | cut -d'.' -f-2 | tr -d '.')"
run: |
CUDA_PKG_SUFFIX="$(echo "${CUDA_VERSION}" | cut -d'.' -f-2 | tr '.' '-')"
sudo apt-get update && sudo apt-get install wget --yes
(
source /etc/os-release
wget -O cuda-keyring.deb "https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${VERSION_ID//./}/$(uname -m)/cuda-keyring_1.0-1_all.deb"
sudo dpkg -i cuda-keyring.deb
)
sudo apt-get update && sudo apt-get install "cuda-minimal-build-${CUDA_PKG_SUFFIX}" --yes
echo "PATH=/usr/local/cuda/bin${PATH:+:${PATH}}" >> "${GITHUB_ENV}"
echo "LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" >> "${GITHUB_ENV}"
PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cu$(echo "${CUDA_PKG_SUFFIX}" | tr -d '-')"
echo "PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL}" >> "${GITHUB_ENV}"
echo "Installed CUDA version is: ${CUDA_VERSION}"
echo "CUDA install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
nvcc -V
/usr/local/cuda/bin/nvcc -V
echo "Torch index URL: ${PIP_EXTRA_INDEX_URL}"
- name: Upgrade pip
Expand Down

0 comments on commit 14b6b07

Please # to comment.