@@ -217,7 +217,12 @@ def test_nibabel_reader(self, input_param, filenames, expected_shape):
217217 @SkipIfNoModule ("kvikio" )
218218 @parameterized .expand ([TEST_CASE_GPU_1 , TEST_CASE_GPU_2 , TEST_CASE_GPU_3 , TEST_CASE_GPU_4 ])
219219 def test_nibabel_reader_gpu (self , input_param , filenames , expected_shape ):
220- test_image = np .random .rand (128 , 128 , 128 )
220+ if torch .__version__ .endswith ("nv24.8" ):
221+ # related issue: https://github.com/Project-MONAI/MONAI/issues/8274
222+ # for this version, use randint test case to avoid the issue
223+ test_image = torch .randint (0 , 256 , (128 , 128 , 128 ), dtype = torch .uint8 ).numpy ()
224+ else :
225+ test_image = np .random .rand (128 , 128 , 128 )
221226 with tempfile .TemporaryDirectory () as tempdir :
222227 for i , name in enumerate (filenames ):
223228 filenames [i ] = os .path .join (tempdir , name )
@@ -233,7 +238,7 @@ def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape):
233238 input_param_cpu = input_param .copy ()
234239 input_param_cpu ["to_gpu" ] = False
235240 result_cpu = LoadImage (image_only = True , ** input_param_cpu )(filenames )
236- self . assertTrue ( torch . allclose ( result_cpu , result .cpu (), atol = 1e-6 ) )
241+ assert_allclose ( result_cpu , result .cpu (), atol = 1e-6 )
237242
238243 @parameterized .expand ([TEST_CASE_6 , TEST_CASE_7 , TEST_CASE_8 , TEST_CASE_8_1 , TEST_CASE_9 ])
239244 def test_itk_reader (self , input_param , filenames , expected_shape ):
0 commit comments