Skip to content

Commit

Permalink
split cuda and cpu tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderDokuchaev committed Apr 17, 2024
1 parent e79a474 commit adb355e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
42 changes: 20 additions & 22 deletions .github/workflows/precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/torch/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/torch/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ markers =
nightly
weekly
models_hub
cuda
python_files = test_*
xfail_strict = true
1 change: 1 addition & 0 deletions tests/torch/test_distributed_data_parallel_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/torch/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit adb355e

Please sign in to comment.