Skip to content

Commit

Permalink
Fixes pytorch#1426 - distrib cpu tests on win (pytorch#1429)
Browse files Browse the repository at this point in the history
* Fixes pytorch#1426 - distrib cpu tests on win

* Skip distributed/tpu/multinode_distributed if SKIP_DISTRIB_TESTS=1

* replaced sh by bash
  • Loading branch information
vfdev-5 committed Nov 5, 2020
1 parent 141d4b5 commit 7a222b3
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
command: |
# pytest on cuda
export test_cmd='sh tests/run_gpu_tests.sh'
export test_cmd='bash tests/run_gpu_tests.sh'
docker exec -it pthd /bin/bash -c "${test_cmd}"
# MNIST tests
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
- run:
name: Run 1 Node 2 GPUs Unit Tests
command: |
export test_cmd='sh tests/run_gpu_tests.sh 2'
export test_cmd='bash tests/run_gpu_tests.sh 2'
docker exec -it pthd /bin/bash -c "${test_cmd}"
- run:
Expand Down Expand Up @@ -256,7 +256,7 @@ jobs:
- run:
name: Run 1 Node 2 GPUs Unit Tests
command: |
export test_cmd='sh tests/run_gpu_tests.sh'
export test_cmd='bash tests/run_gpu_tests.sh'
docker exec -it pthd /bin/bash -c "${test_cmd}"
# no CUDA devices Horovod tests
export test_cmd='CUDA_VISIBLE_DEVICES="" py.test --cov ignite --cov-append --cov-report term-missing --cov-report xml -vvv tests/ -m distributed'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/hvd-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ jobs:
- name: Run Tests
shell: bash -l {0}
run: |
SKIP_DISTRIB_TESTS=${{ matrix.skip-distrib-tests }} CI_PYTHON_VERSION="${{ matrix.python-version }}" sh tests/run_cpu_tests.sh
SKIP_DISTRIB_TESTS=${{ matrix.skip-distrib-tests }} CI_PYTHON_VERSION="${{ matrix.python-version }}" bash tests/run_cpu_tests.sh
2 changes: 1 addition & 1 deletion .github/workflows/tpu-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
export XRT_WORKERS="localservice:0;grpc://localhost:40934"
python -c "import torch_xla; print('torch xla version:', torch_xla.__version__)"
sh tests/run_tpu_tests.sh
bash tests/run_tpu_tests.sh
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Run Tests
shell: bash -l {0}
run: |
SKIP_DISTRIB_TESTS=${{ matrix.skip-distrib-tests }} CI_PYTHON_VERSION="${{ matrix.python-version }}" sh tests/run_cpu_tests.sh
SKIP_DISTRIB_TESTS=${{ matrix.skip-distrib-tests }} CI_PYTHON_VERSION="${{ matrix.python-version }}" bash tests/run_cpu_tests.sh
- name: Run MNIST Examples
shell: bash -l {0}
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ install:

script:
- mypy --config-file mypy.ini
- CI_PYTHON_VERSION="$TRAVIS_PYTHON_VERSION" sh tests/run_cpu_tests.sh
- CI_PYTHON_VERSION="$TRAVIS_PYTHON_VERSION" bash tests/run_cpu_tests.sh

after_success:
- codecov -F cpu || echo 'Codecov upload failed'
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ pytest tests/ignite/engine/test_engine.py -vvv -k test_terminate
```
To run all tests with coverage (assuming installed `pytest-cov`):
```bash
CI_PYTHON_VERSION=<your python version, e.g 3.7> sh tests/run_cpu_tests.sh
CI_PYTHON_VERSION=<your python version, e.g 3.7> bash tests/run_cpu_tests.sh
# for example
# CI_PYTHON_VERSION=3.7 sh tests/run_cpu_tests.sh
# CI_PYTHON_VERSION=3.7 bash tests/run_cpu_tests.sh
```

#### Run Mypy checks:
Expand Down
11 changes: 10 additions & 1 deletion tests/ignite/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import shutil
import sys
import tempfile

import pytest
Expand Down Expand Up @@ -107,15 +108,23 @@ def distributed_context_single_node_gloo(local_rank, world_size):

from datetime import timedelta

init_method = "tcp://localhost:2223"
temp_file = None
if sys.platform.startswith("win"):
temp_file = tempfile.NamedTemporaryFile(delete=False)
init_method = "file:///{}".format(temp_file.name.replace("\\", "/"))

dist_info = {
"backend": "gloo",
"world_size": world_size,
"rank": local_rank,
"init_method": "tcp://localhost:2222",
"init_method": init_method,
"timeout": timedelta(seconds=60),
}
yield _create_dist_context(dist_info, local_rank)
_destroy_dist_context()
if temp_file:
temp_file.close()


@pytest.fixture()
Expand Down
2 changes: 1 addition & 1 deletion tests/ignite/contrib/handlers/test_tqdm_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ignite.metrics import RunningAverage

if sys.platform.startswith("win"):
pytest.skip("Skip if on Windows", allow_module_level=True)
pytest.skip("Skip on Windows", allow_module_level=True)


def get_tqdm_version():
Expand Down
9 changes: 8 additions & 1 deletion tests/run_cpu_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

set -xeu

CUDA_VISIBLE_DEVICES="" py.test --tx 4*popen//python=python${CI_PYTHON_VERSION:-3.7} --cov ignite --cov-report term-missing -vvv tests/
if [ "${SKIP_DISTRIB_TESTS:-0}" -eq "1" ]; then
skip_distrib_opt=(-m "not distributed and not tpu and not multinode_distributed")
else
skip_distrib_opt=(-m "")
fi

CUDA_VISIBLE_DEVICES="" py.test --tx 4*popen//python=python${CI_PYTHON_VERSION:-3.7} --cov ignite --cov-report term-missing -vvv tests "${skip_distrib_opt[@]}"

# https://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02
if [ "${SKIP_DISTRIB_TESTS:-0}" -eq "1" ]; then
Expand All @@ -11,4 +17,5 @@ fi

export WORLD_SIZE=2


CUDA_VISIBLE_DEVICES="" py.test --cov ignite --cov-append --cov-report term-missing --dist=each --tx $WORLD_SIZE*popen//python=python${CI_PYTHON_VERSION:-3.7} tests -m distributed -vvv

0 comments on commit 7a222b3

Please sign in to comment.