diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index 58f7d888d07..f4a2e478488 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -90,46 +90,44 @@ jobs: # name: coverage_openvino # flags: OPENVINO - pytorch: + + pytorch-cpu: + defaults: + run: + shell: bash + runs-on: ubuntu-20.04 + - uses: actions/checkout@v3 + with: + lfs: true + - uses: actions/setup-python@v3 + with: + python-version: 3.8.10 + - name: Install NNCF and test requirements + run: make install-torch-test + - name: Run PyTorch precommit test scope + run: make test-torch-cpu + + pytorch-cuda: defaults: run: shell: bash runs-on: aks-linux-4-cores-28gb-gpu-testla-t4 steps: - - name: uname -a - continue-on-error: true - run: | - uname -a - ls -l /usr/local/ - ls -l /dev/* - - - name: nvidia-smi - continue-on-error: true - run: | - nvidia-smi - - name: nvidia-smi - continue-on-error: true - run: | - nvcc --version - - name: Install dependencies run : | sudo apt-get update sudo apt-get --assume-yes install gcc ninja-build libgl1-mesa-dev libglib2.0-0 - - name: Install CUDA run: | wget -q https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda_12.1.1_530.30.02_linux.run sudo sh cuda_12.1.1_530.30.02_linux.run --toolkit --silent - - name: Runner info continue-on-error: true run: | nvidia-smi cat /proc/cpuinfo nvcc --version - - uses: actions/checkout@v3 with: lfs: true @@ -141,5 +139,5 @@ jobs: - name: Check CUDA run: | python -c "import torch; print(torch.cuda.is_available())" - - name: Run Pytorch precommit test scope - run: pytest tests/torch -m "not weekly and not nightly and not models_hub" -rA + - name: Run PyTorch precommit test scope + run: make test-torch-cuda diff --git a/Makefile b/Makefile index 545d35ec4f2..c72da3ebeb1 100644 --- a/Makefile +++ b/Makefile @@ -145,6 +145,12 @@ install-models-hub-torch: test-torch: pytest ${COVERAGE_ARGS} tests/torch -m "not weekly and not nightly and not models_hub" --junitxml ${JUNITXML_PATH} $(DATA_ARG) +test-torch-cpu: + pytest ${COVERAGE_ARGS} tests/torch -rS -m "not cuda and not weekly and not nightly and not models_hub" --junitxml ${JUNITXML_PATH} $(DATA_ARG) + +test-torch-cuda: + pytest ${COVERAGE_ARGS} tests/torch -rS -m "cuda and not weekly and not nightly and not models_hub" --junitxml ${JUNITXML_PATH} $(DATA_ARG) + test-torch-nightly: pytest ${COVERAGE_ARGS} tests/torch -m nightly --junitxml ${JUNITXML_PATH} $(DATA_ARG) diff --git a/tests/torch/conftest.py b/tests/torch/conftest.py index 6546c1085f0..c4a8910e826 100644 --- a/tests/torch/conftest.py +++ b/tests/torch/conftest.py @@ -213,7 +213,7 @@ def is_weights(request: FixtureRequest): return request.param -@pytest.fixture(params=[True, False], ids=["cuda", "cpu"]) +@pytest.fixture(params=[pytest.param(True, marks=pytest.mark.cuda), False], ids=["cuda", "cpu"]) def use_cuda(request: FixtureRequest): return request.param diff --git a/tests/torch/pytest.ini b/tests/torch/pytest.ini index 26ef8aedef9..0741cf4b300 100644 --- a/tests/torch/pytest.ini +++ b/tests/torch/pytest.ini @@ -8,5 +8,6 @@ markers = nightly weekly models_hub + cuda python_files = test_* xfail_strict = true diff --git a/tests/torch/test_distributed_data_parallel_mode.py b/tests/torch/test_distributed_data_parallel_mode.py index c186ea97318..c9e12cc5297 100644 --- a/tests/torch/test_distributed_data_parallel_mode.py +++ b/tests/torch/test_distributed_data_parallel_mode.py @@ -82,6 +82,7 @@ def worker(rank: int, world_size: int) -> None: _ = torch.nn.parallel.DistributedDataParallel(compressed_model, device_ids=[rank]) +@pytest.mark.cuda @pytest.mark.parametrize("waiting_time", [20.0]) def test_is_ddp_freezing(waiting_time: float) -> None: # Number of processes the same as GPU count diff --git a/tests/torch/test_tensor.py b/tests/torch/test_tensor.py index ee4d1d19209..1755b3badd8 100644 --- a/tests/torch/test_tensor.py +++ b/tests/torch/test_tensor.py @@ -35,6 +35,7 @@ def cast_to(x: torch.Tensor, dtype: TensorDataType) -> torch.Tensor: return cast_to(x, dtype) +@pytest.mark.cuda @pytest.mark.skipif(not torch.cuda.is_available(), reason="Skipping for CPU-only setups") class TestCudaPTNNCFTensorOperators(TemplateTestNNCFTensorOperators): @staticmethod