deps(torch): support PyTorch 2.0+ only #1676
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
paths: | |
- setup.py | |
- setup.cfg | |
- pyproject.toml | |
- MANIFEST.in | |
- CMakeLists.txt | |
- include/** | |
- src/** | |
- tests/** | |
- torchopt/** | |
- .github/workflows/tests.yml | |
# Allow to trigger the workflow manually | |
workflow_dispatch: | |
permissions: | |
contents: read | |
concurrency: | |
group: "${{ github.workflow }}-${{ github.ref }}" | |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
env: | |
CUDA_VERSION: "12.1" | |
jobs: | |
test: | |
name: Test with CXX/CUDA extensions on ubuntu-latest | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
fetch-depth: 1 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" # the lowest version we support (sync with requires-python in pyproject.toml) | |
update-environment: true | |
- name: Setup CUDA Toolkit | |
id: cuda-toolkit | |
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}" | |
/usr/local/cuda/bin/nvcc -V | |
echo "Torch index URL: ${PIP_EXTRA_INDEX_URL}" | |
- name: Upgrade pip | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
- name: Install dependencies | |
run: | | |
python -m pip install -r tests/requirements.txt | |
- name: Install TorchOpt | |
env: | |
USE_FP16: "ON" | |
TORCH_CUDA_ARCH_LIST: "Common" | |
run: | | |
python -m pip install -vvv -e . | |
- name: Test with pytest | |
run: | | |
make pytest | |
- name: Upload coverage to Codecov | |
if: runner.os == 'Linux' | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: ./tests/coverage.xml | |
flags: unittests | |
name: codecov-umbrella | |
fail_ci_if_error: false | |
test-pure-python: | |
name: Test for pure-Python on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 60 | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
fetch-depth: 1 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" # the lowest version we support (sync with requires-python in pyproject.toml) | |
update-environment: true | |
- name: Upgrade pip | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
- name: Install dependencies | |
run: | | |
python -m pip install -r tests/requirements.txt | |
- name: Install TorchOpt | |
run: | | |
python -m pip install -vvv -e . | |
env: | |
TORCHOPT_NO_EXTENSIONS: "true" | |
- name: Test with pytest | |
run: | | |
make pytest | |
- name: Upload coverage to Codecov | |
if: runner.os == 'Linux' | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: ./tests/coverage.xml | |
flags: unittests | |
name: codecov-umbrella-pure-python | |
fail_ci_if_error: false |