diff --git a/.circleci/config.yml b/.circleci/config.yml index aaa29f0ed9..afef4c9781 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,26 +2,46 @@ # # Check https://circleci.com/docs/2.0/language-python/ for more details # -version: 2 +version: 2.1 # ------------------------------------------------------------------------------------- # Environments to run the jobs in # ------------------------------------------------------------------------------------- cpu: &cpu - environment: - TERM: xterm machine: image: default resource_class: medium gpu: &gpu - environment: - CUDA_VERSION: "10.2" - TERM: xterm machine: - image: ubuntu-1604:202104-01 + image: linux-cuda-11:2023.02.1 resource_class: gpu.nvidia.small.multi # NVIDIA Tesla T4 2 GPU 4 vCPUs 15 GB RAM (2 GPUs) + + +version_parameters: &version_parameters + parameters: + pytorch_index: + type: string + # use test wheels index to have access to RC wheels + # https://download.pytorch.org/whl/test/torch_test.html + default: "https://download.pytorch.org/whl/torch_stable.html" + python_version: # NOTE: only affects linux + type: string + default: '3.10.6' + cuda_version: + type: string + default: '11.6' + TERM: + type: string + default: 'xterm' + + environment: + PYTORCH_INDEX: << parameters.pytorch_index >> + PYTHON_VERSION: << parameters.python_version>> + CUDA_VERSION: << parameters.cuda_version >> + TERM: << parameters.TERM >> + # ------------------------------------------------------------------------------------- # Re-usable commands # ------------------------------------------------------------------------------------- @@ -41,8 +61,8 @@ install_python: &install_python name: Install Python working_directory: ~/ command: | - pyenv install 3.6.2 - pyenv global 3.6.2 + pyenv install << parameters.python_version >> + pyenv global << parameters.python_version >> which python which pip @@ -75,6 +95,12 @@ setup_cuda: &setup_cuda time sudo dpkg -i ~/nvidia-downloads/cuda-repo-ubuntu1604-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb nvidia-smi +select_cuda: &select_cuda + - run: + name: Select CUDA + command: | + sudo update-alternatives --set cuda /usr/local/cuda-<< parameters.cuda_version >> + check_cuda_available: &check_cuda_available - run: name: Check CUDA Available @@ -115,6 +141,7 @@ run_tests: &run_tests jobs: cpu_tests: <<: *cpu + <<: *version_parameters working_directory: ~/ClassyVision @@ -130,9 +157,9 @@ jobs: # Download and cache dependencies - restore_cache: keys: - - v9-cpu-dependencies-{{ checksum "requirements.txt" }} + - v10-cpu-dependencies-{{ checksum "requirements.txt" }} # fallback to using the latest cache if no exact match is found - - v9-cpu-dependencies- + - v10-cpu-dependencies- - <<: *install_dev_dep @@ -143,7 +170,7 @@ jobs: - save_cache: paths: - ~/venv - key: v9-cpu-dependencies-{{ checksum "requirements.txt" }} + key: v10-cpu-dependencies-{{ checksum "requirements.txt" }} - <<: *run_tests @@ -166,13 +193,16 @@ jobs: gpu_tests: <<: *gpu + <<: *version_parameters + working_directory: ~/ClassyVision steps: - checkout - - <<: *setup_cuda + # - <<: *setup_cuda + - <<: *select_cuda - <<: *install_python @@ -183,9 +213,9 @@ jobs: # Download and cache dependencies - restore_cache: keys: - - v6-gpu-dependencies-{{ checksum "requirements.txt" }} + - v7-gpu-dependencies-{{ checksum "requirements.txt" }} # fallback to using the latest cache if no exact match is found - - v6-gpu-dependencies- + - v7-gpu-dependencies- - <<: *install_dev_dep @@ -198,20 +228,22 @@ jobs: - save_cache: paths: - ~/venv - key: v6-gpu-dependencies-{{ checksum "requirements.txt" }} + key: v7-gpu-dependencies-{{ checksum "requirements.txt" }} - <<: *run_tests gpu_tests_bc: <<: *gpu + <<: *version_parameters working_directory: ~/ClassyVision steps: - checkout - - <<: *setup_cuda + # - <<: *setup_cuda + - <<: *select_cuda - <<: *install_python @@ -222,9 +254,9 @@ jobs: # Download and cache dependencies - restore_cache: keys: - - v3-gpu-bc-dependencies-{{ checksum "requirements_test_bc.txt" }} + - v4-gpu-bc-dependencies-{{ checksum "requirements_test_bc.txt" }} # fallback to using the latest cache if no exact match is found - - v3-gpu-bc-dependencies- + - v4-gpu-bc-dependencies- - <<: *install_dev_dep @@ -237,7 +269,7 @@ jobs: - save_cache: paths: - ~/venv - key: v3-gpu-bc-dependencies-{{ checksum "requirements_test_bc.txt" }} + key: v4-gpu-bc-dependencies-{{ checksum "requirements_test_bc.txt" }} - <<: *run_tests diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000000..67f5e3de6d --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,31 @@ +name: CI +on: [push, pull_request] + +# Run linter with github actions for quick feedbacks. +# Run macos tests with github actions. Linux (CPU & GPU) tests currently runs on CircleCI +jobs: + linter: + runs-on: ubuntu-latest + # run on PRs, or commits to facebookresearch (not internal) + if: ${{ github.repository_owner == 'facebookresearch' || github.event_name == 'pull_request' }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: 3.10 + - name: Install dependencies + # flake8-bugbear flake8-comprehensions are useful but not available internally + run: | + python -m pip install --upgrade pip + python -m pip install flake8==6.0.0 isort==5.12.0 + python -m pip install black==23.1.0 + flake8 --version + - name: Lint + run: | + echo "Running isort" + isort -c -sp . + echo "Running black" + black -l 100 --check . + echo "Running flake8" + flake8 . diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf99cdb481..07d3c5a039 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: rev: stable hooks: - id: black - language_version: python3.6 + language_version: python3.10 - repo: https://github.com/timothycrosley/isort rev: stable diff --git a/README.md b/README.md index 3c1b32d069..3cc9958832 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ Classy Vision is beta software. The project is under active development and our ## Installation #### Installation Requirements -Make sure you have an up-to-date installation of PyTorch (1.6), Python (3.6) and torchvision (0.7). If you want to use GPUs, then a CUDA installation (10.1) is also required. +Make sure you have an up-to-date installation of PyTorch (1.12), Python (3.8) and torchvision (0.13). If you want to use GPUs, then a CUDA installation (11.6) is also required. #### Installing the latest stable release To install Classy Vision via pip: diff --git a/classy_vision/dataset/transforms/autoaugment.py b/classy_vision/dataset/transforms/autoaugment.py index e0388bc1cb..c09a221802 100644 --- a/classy_vision/dataset/transforms/autoaugment.py +++ b/classy_vision/dataset/transforms/autoaugment.py @@ -30,7 +30,7 @@ # https://github.com/DeepVoltaire/AutoAugment/blob/master/autoaugment.py import random -from enum import auto, Enum +from enum import Enum, auto from functools import partial from typing import Any, Callable, NamedTuple, Sequence, Tuple @@ -165,7 +165,7 @@ def get_image_op_settings( ImageOp.ROTATE: ImageOpSetting(np.linspace(0, 30, 10), rotate_with_fill), ImageOp.COLOR: ImageOpSetting(np.linspace(0.0, 0.9, 10), color), ImageOp.POSTERIZE: ImageOpSetting( - np.round(np.linspace(8, 4, 10), 0).astype(np.int), posterize + np.round(np.linspace(8, 4, 10), 0).astype(np.int64), posterize ), ImageOp.SOLARIZE: ImageOpSetting(np.linspace(256, 0, 10), solarize), ImageOp.CONTRAST: ImageOpSetting(np.linspace(0.0, 0.9, 10), contrast), diff --git a/requirements.txt b/requirements.txt index 9611612d15..2c7963e835 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ fvcore>=0.1.3 -setuptools<58 +setuptools>=67.5.0 torch>=1.6 torchvision>=0.7 -wheel +wheel \ No newline at end of file diff --git a/requirements_test_bc.txt b/requirements_test_bc.txt index e2fc4ba1be..96735878e1 100644 --- a/requirements_test_bc.txt +++ b/requirements_test_bc.txt @@ -1,3 +1,3 @@ -torch==1.6 -torchvision==0.7 -fvcore>=0.1.3 +torch>=1.13.1 +torchvision>=0.14.1 +fvcore>=0.1.5.post20221221 diff --git a/setup.py b/setup.py index 62d21a7de9..c8d0fcbd06 100644 --- a/setup.py +++ b/setup.py @@ -13,8 +13,8 @@ if __name__ == "__main__": - if sys.version_info < (3, 6): - sys.exit("Sorry, Python >=3.6 is required for Classy Vision.") + if sys.version_info < (3, 8): + sys.exit("Sorry, Python >=3.8 is required for Classy Vision.") # get version string from module with open( @@ -43,21 +43,21 @@ "Source": "https://github.com/facebookresearch/ClassyVision", }, license="MIT License", - python_requires=">=3.6", + python_requires=">=3.8", packages=find_packages(exclude=("tests",)) + find_namespace_packages(include=["hydra_plugins.*"]), install_requires=reqs.strip().split("\n"), extras_require={ "dev": [ "GitPython", - "black==19.3b0", + "black>=23.1.0", "sphinx", - "isort==5.2.2", + "isort>=5.12.0", "bs4", - "nbconvert==6.0.7", + "nbconvert>=7.2.9", "pre-commit", "parameterized", - "fairscale==0.3.7", + "fairscale>=0.4.13", ] }, package_data={"classy_vision": ["configs/*.json", "templates"]}, @@ -68,7 +68,9 @@ keywords=["deep learning", "pytorch", "AI"], classifiers=[ "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Development Status :: 4 - Beta", diff --git a/test/hooks_profiler_hook_test.py b/test/hooks_profiler_hook_test.py index 91b7bac3af..1d9106e85c 100644 --- a/test/hooks_profiler_hook_test.py +++ b/test/hooks_profiler_hook_test.py @@ -6,11 +6,11 @@ import unittest import unittest.mock as mock - -from classy_vision.hooks import ProfilerHook from test.generic.config_utils import get_test_classy_task, get_test_classy_video_task from test.generic.hook_test_utils import HookTestBase +from classy_vision.hooks import ProfilerHook + class TestProfilerHook(HookTestBase): def test_constructors(self) -> None: @@ -23,7 +23,7 @@ def test_constructors(self) -> None: config=config, hook_type=ProfilerHook, hook_registry_name="profiler" ) - @mock.patch("torch.autograd.profiler.profile", auto_spec=True) + @mock.patch("torch.autograd.profiler.profile", autospec=True) @mock.patch("classy_vision.hooks.profiler_hook.summarize_profiler_info") def test_profiler( self, diff --git a/tutorials/classy_dataset.ipynb b/tutorials/classy_dataset.ipynb index f4401d3907..3837e23d24 100644 --- a/tutorials/classy_dataset.ipynb +++ b/tutorials/classy_dataset.ipynb @@ -599,4 +599,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} \ No newline at end of file +}