From bc9a8a5b26d53afb209985260b2fe509327915ac Mon Sep 17 00:00:00 2001 From: Yiheng Wang Date: Mon, 13 Jan 2025 15:08:57 +0000 Subject: [PATCH 1/2] update Signed-off-by: Yiheng Wang --- tests/test_load_image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_load_image.py b/tests/test_load_image.py index dc0af5e97e..b366d1dd76 100644 --- a/tests/test_load_image.py +++ b/tests/test_load_image.py @@ -217,7 +217,7 @@ def test_nibabel_reader(self, input_param, filenames, expected_shape): @SkipIfNoModule("kvikio") @parameterized.expand([TEST_CASE_GPU_1, TEST_CASE_GPU_2, TEST_CASE_GPU_3, TEST_CASE_GPU_4]) def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape): - test_image = np.random.rand(128, 128, 128) + test_image = torch.randint(0, 256, (128, 128, 128), dtype=torch.uint8).numpy() with tempfile.TemporaryDirectory() as tempdir: for i, name in enumerate(filenames): filenames[i] = os.path.join(tempdir, name) From b18fcb9cc7ab13cfcab4557e523c9dfc7b9e00e3 Mon Sep 17 00:00:00 2001 From: Yiheng Wang Date: Tue, 14 Jan 2025 03:27:45 +0000 Subject: [PATCH 2/2] add test case Signed-off-by: Yiheng Wang --- tests/test_load_image.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_load_image.py b/tests/test_load_image.py index b366d1dd76..498b9972b4 100644 --- a/tests/test_load_image.py +++ b/tests/test_load_image.py @@ -217,7 +217,12 @@ def test_nibabel_reader(self, input_param, filenames, expected_shape): @SkipIfNoModule("kvikio") @parameterized.expand([TEST_CASE_GPU_1, TEST_CASE_GPU_2, TEST_CASE_GPU_3, TEST_CASE_GPU_4]) def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape): - test_image = torch.randint(0, 256, (128, 128, 128), dtype=torch.uint8).numpy() + if torch.__version__.endswith("nv24.8"): + # related issue: https://github.com/Project-MONAI/MONAI/issues/8274 + # for this version, use randint test case to avoid the issue + test_image = torch.randint(0, 256, (128, 128, 128), dtype=torch.uint8).numpy() + else: + test_image = np.random.rand(128, 128, 128) with tempfile.TemporaryDirectory() as tempdir: for i, name in enumerate(filenames): filenames[i] = os.path.join(tempdir, name)