diff --git a/.github/workflows/gpu-tests.yml b/.github/workflows/gpu-tests.yml
index 0a72711fbdd..13c628ad302 100644
--- a/.github/workflows/gpu-tests.yml
+++ b/.github/workflows/gpu-tests.yml
@@ -124,7 +124,7 @@ jobs:
uses: nick-fields/retry@v2.9.0
with:
max_attempts: 5
- timeout_minutes: 25
+ timeout_minutes: 45
shell: bash
command: docker exec -t pthd /bin/bash -xec 'bash tests/run_gpu_tests.sh 2'
new_command_on_retry: docker exec -e USE_LAST_FAILED=1 -t pthd /bin/bash -xec 'bash tests/run_gpu_tests.sh 2'
diff --git a/ignite/contrib/engines/common.py b/ignite/contrib/engines/common.py
index 09f769a18d0..bcfa54be55e 100644
--- a/ignite/contrib/engines/common.py
+++ b/ignite/contrib/engines/common.py
@@ -78,7 +78,7 @@ def setup_common_training_handlers(
lr_scheduler: learning rate scheduler
as native torch LRScheduler or ignite's parameter scheduler.
with_gpu_stats: if True, :class:`~ignite.metrics.GpuInfo` is attached to the
- trainer. This requires `pynvml` package to be installed.
+ trainer. This requires `pynvml<12` package to be installed.
output_names: list of names associated with `update_function` output dictionary.
with_pbars: if True, two progress bars on epochs and optionally on iterations are attached.
Default, True.
diff --git a/ignite/metrics/clustering/calinski_harabasz_score.py b/ignite/metrics/clustering/calinski_harabasz_score.py
index fe58ac46151..79f8dc99ba5 100644
--- a/ignite/metrics/clustering/calinski_harabasz_score.py
+++ b/ignite/metrics/clustering/calinski_harabasz_score.py
@@ -11,8 +11,8 @@
def _calinski_harabasz_score(features: Tensor, labels: Tensor) -> float:
from sklearn.metrics import calinski_harabasz_score
- np_features = features.numpy()
- np_labels = labels.numpy()
+ np_features = features.cpu().numpy()
+ np_labels = labels.cpu().numpy()
score = calinski_harabasz_score(np_features, np_labels)
return score
diff --git a/ignite/metrics/clustering/davies_bouldin_score.py b/ignite/metrics/clustering/davies_bouldin_score.py
index b34ec69f51a..afea0518951 100644
--- a/ignite/metrics/clustering/davies_bouldin_score.py
+++ b/ignite/metrics/clustering/davies_bouldin_score.py
@@ -11,8 +11,8 @@
def _davies_bouldin_score(features: Tensor, labels: Tensor) -> float:
from sklearn.metrics import davies_bouldin_score
- np_features = features.numpy()
- np_labels = labels.numpy()
+ np_features = features.cpu().numpy()
+ np_labels = labels.cpu().numpy()
score = davies_bouldin_score(np_features, np_labels)
return score
diff --git a/ignite/metrics/clustering/silhouette_score.py b/ignite/metrics/clustering/silhouette_score.py
index 39b28c5d040..48a59d583ec 100644
--- a/ignite/metrics/clustering/silhouette_score.py
+++ b/ignite/metrics/clustering/silhouette_score.py
@@ -111,7 +111,7 @@ def __init__(
def _silhouette_score(self, features: Tensor, labels: Tensor) -> float:
from sklearn.metrics import silhouette_score
- np_features = features.numpy()
- np_labels = labels.numpy()
+ np_features = features.cpu().numpy()
+ np_labels = labels.cpu().numpy()
score = silhouette_score(np_features, np_labels, **self._silhouette_kwargs)
return score
diff --git a/ignite/metrics/gpu_info.py b/ignite/metrics/gpu_info.py
index 96ed4f07c57..d13bbd8a1da 100644
--- a/ignite/metrics/gpu_info.py
+++ b/ignite/metrics/gpu_info.py
@@ -10,7 +10,7 @@
class GpuInfo(Metric):
"""Provides GPU information: a) used memory percentage, b) gpu utilization percentage values as Metric
- on each iterations.
+ on each iterations. This metric requires `pynvml `_ package of version `<12`.
.. Note ::
@@ -39,7 +39,7 @@ def __init__(self) -> None:
except ImportError:
raise ModuleNotFoundError(
"This contrib module requires pynvml to be installed. "
- "Please install it with command: \n pip install pynvml"
+ "Please install it with command: \n pip install 'pynvml<12'"
)
# Let's check available devices
if not torch.cuda.is_available():
diff --git a/ignite/metrics/regression/kendall_correlation.py b/ignite/metrics/regression/kendall_correlation.py
index 7ad87b22402..34d876a3659 100644
--- a/ignite/metrics/regression/kendall_correlation.py
+++ b/ignite/metrics/regression/kendall_correlation.py
@@ -16,8 +16,8 @@ def _get_kendall_tau(variant: str = "b") -> Callable[[Tensor, Tensor], float]:
raise ValueError(f"variant accepts 'b' or 'c', got {variant!r}.")
def _tau(predictions: Tensor, targets: Tensor) -> float:
- np_preds = predictions.flatten().numpy()
- np_targets = targets.flatten().numpy()
+ np_preds = predictions.flatten().cpu().numpy()
+ np_targets = targets.flatten().cpu().numpy()
r = kendalltau(np_preds, np_targets, variant=variant).statistic
return r
diff --git a/ignite/metrics/regression/spearman_correlation.py b/ignite/metrics/regression/spearman_correlation.py
index 7f126d6e56b..cbd89f67c9d 100644
--- a/ignite/metrics/regression/spearman_correlation.py
+++ b/ignite/metrics/regression/spearman_correlation.py
@@ -12,8 +12,8 @@
def _spearman_r(predictions: Tensor, targets: Tensor) -> float:
from scipy.stats import spearmanr
- np_preds = predictions.flatten().numpy()
- np_targets = targets.flatten().numpy()
+ np_preds = predictions.flatten().cpu().numpy()
+ np_targets = targets.flatten().cpu().numpy()
r = spearmanr(np_preds, np_targets).statistic
return r
diff --git a/tests/common_test_functionality.sh b/tests/common_test_functionality.sh
index 6e60947f927..91003eddc09 100644
--- a/tests/common_test_functionality.sh
+++ b/tests/common_test_functionality.sh
@@ -85,7 +85,6 @@ run_tests() {
skip_distrib_opt=""
fi
-
echo [pytest] > pytest.ini ; echo "cache_dir=${cache_dir}" >> pytest.ini
# Assemble options for the pytest command
@@ -103,8 +102,8 @@ run_tests() {
# Run the command
if [ "$trap_deselected_exit_code" -eq "1" ]; then
- CUDA_VISIBLE_DEVICES="" eval "pytest ${pytest_args}" || { exit_code=$?; if [ "$exit_code" -eq ${last_failed_no_failures_code} ]; then echo "All tests deselected"; else exit $exit_code; fi; }
+ eval "pytest ${pytest_args}" || { exit_code=$?; if [ "$exit_code" -eq ${last_failed_no_failures_code} ]; then echo "All tests deselected"; else exit $exit_code; fi; }
else
- CUDA_VISIBLE_DEVICES="" eval "pytest ${pytest_args}"
+ eval "pytest ${pytest_args}"
fi
}
diff --git a/tests/ignite/metrics/test_classification_report.py b/tests/ignite/metrics/test_classification_report.py
index 87e328c8051..cae8b5145f5 100644
--- a/tests/ignite/metrics/test_classification_report.py
+++ b/tests/ignite/metrics/test_classification_report.py
@@ -164,6 +164,23 @@ def update(engine, i):
@pytest.mark.skipif(torch.cuda.device_count() < 1, reason="Skip if no GPU")
@pytest.mark.skipif(Version(torch.__version__) < Version("1.7.0"), reason="Skip if < 1.7.0")
def test_distrib_nccl_gpu(distributed_context_single_node_nccl):
+
+ pytest.skip("Temporarily skip failing test. See https://github.com/pytorch/ignite/pull/3301")
+ # When run with 2 devices:
+ # tests/ignite/metrics/test_classification_report.py::test_distrib_nccl_gpu Fatal Python error: Aborted
+ # Thread 0x00007fac95c95700 (most recent call first):
+ #
+
+ # Thread 0x00007facbb89b700 (most recent call first):
+ #
+
+ # Thread 0x00007fae637f4700 (most recent call first):
+ # File "", line 534 in read
+ # File "", line 567 in from_io
+ # File "", line 1160 in _thread_receiver
+ # File "", line 341 in run
+ # File "", line 411 in _perform_spawn
+
device = idist.device()
_test_integration_multiclass(device, True)
_test_integration_multiclass(device, False)
diff --git a/tests/ignite/metrics/test_hsic.py b/tests/ignite/metrics/test_hsic.py
index 57af5fa2862..28fe5c1f97d 100644
--- a/tests/ignite/metrics/test_hsic.py
+++ b/tests/ignite/metrics/test_hsic.py
@@ -139,10 +139,10 @@ def test_integration(self, sigma_x: float, sigma_y: float):
metric_devices.append(device)
for metric_device in metric_devices:
- x = torch.randn((n_iters * batch_size, n_dims_x)).float().to(device)
+ x = torch.randn((n_iters * batch_size, n_dims_x), device=device).float()
lin = nn.Linear(n_dims_x, n_dims_y).to(device)
- y = torch.sin(lin(x) * 100) + torch.randn(n_iters * batch_size, n_dims_y) * 1e-4
+ y = torch.sin(lin(x) * 100) + torch.randn(n_iters * batch_size, n_dims_y, device=x.device) * 1e-4
def data_loader(i, input_x, input_y):
return input_x[i * batch_size : (i + 1) * batch_size], input_y[i * batch_size : (i + 1) * batch_size]
diff --git a/tests/run_cpu_tests.sh b/tests/run_cpu_tests.sh
index 8d387f5542e..f52988a6818 100644
--- a/tests/run_cpu_tests.sh
+++ b/tests/run_cpu_tests.sh
@@ -6,8 +6,7 @@ skip_distrib_tests=${SKIP_DISTRIB_TESTS:-0}
use_last_failed=${USE_LAST_FAILED:-0}
match_tests_expression=${1:-""}
-
-run_tests \
+CUDA_VISIBLE_DEVICES="" run_tests \
--core_args "--tx 4*popen//python=python -vvv tests/ignite" \
--cache_dir ".cpu-not-distrib" \
--skip_distrib_tests "${skip_distrib_tests}" \
@@ -21,7 +20,7 @@ if [ "${skip_distrib_tests}" -eq "1" ]; then
fi
# Run 2 processes with --dist=each
-run_tests \
+CUDA_VISIBLE_DEVICES="" run_tests \
--core_args "-m distributed -vvv tests/ignite" \
--world_size 2 \
--cache_dir ".cpu-distrib" \
diff --git a/tests/run_gpu_tests.sh b/tests/run_gpu_tests.sh
index 26497f19c83..c86d1d0746e 100644
--- a/tests/run_gpu_tests.sh
+++ b/tests/run_gpu_tests.sh
@@ -2,26 +2,26 @@
source "$(dirname "$0")/common_test_functionality.sh"
set -xeu
-skip_distrib_tests=${SKIP_DISTRIB_TESTS:-1}
+# https://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02
+skip_distrib_tests=${SKIP_DISTRIB_TESTS:-0}
use_last_failed=${USE_LAST_FAILED:-0}
ngpus=${1:-1}
match_tests_expression=${2:-""}
if [ -z "$match_tests_expression" ]; then
- cuda_pattern="cuda"
+ cuda_pattern="cuda or nccl or gloo"
else
- cuda_pattern="cuda and $match_tests_expression"
+ cuda_pattern="(cuda or nccl or gloo) and $match_tests_expression"
fi
run_tests \
- --core_args "-vvv tests/ignite" \
+ --core_args "-vvv tests/ignite -m 'not distributed'" \
--cache_dir ".gpu-cuda" \
--skip_distrib_tests "${skip_distrib_tests}" \
--use_coverage 1 \
--match_tests_expression "${cuda_pattern}" \
--use_last_failed ${use_last_failed}
-# https://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02
if [ "${skip_distrib_tests}" -eq "1" ]; then
exit 0
fi