Skip to content

Commit 25c2219

Browse files
committed
Determinism use fix
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
1 parent d90846b commit 25c2219

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

.github/workflows/pythonapp.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
- if: runner.os == 'windows'
9595
name: Install torch cpu from pytorch.org (Windows only)
9696
run: |
97-
python -m pip install torch==2.4.1 torchvision==0.19.1+cpu --index-url https://download.pytorch.org/whl/cpu
97+
python -m pip install torch==2.5.1 torchvision==0.20.1+cpu --index-url https://download.pytorch.org/whl/cpu
9898
- if: runner.os == 'Linux'
9999
name: Install itk pre-release (Linux only)
100100
run: |
@@ -103,7 +103,7 @@ jobs:
103103
- name: Install the dependencies
104104
run: |
105105
python -m pip install --user --upgrade pip wheel
106-
python -m pip install torch==2.4.1 torchvision==0.19.1
106+
python -m pip install torch==2.5.1 torchvision==0.20.1
107107
cat "requirements-dev.txt"
108108
python -m pip install -r requirements-dev.txt
109109
python -m pip list
@@ -155,7 +155,7 @@ jobs:
155155
# install the latest pytorch for testing
156156
# however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated
157157
# fresh torch installation according to pyproject.toml
158-
python -m pip install torch>=2.4.1 torchvision
158+
python -m pip install torch>=2.5.1 torchvision
159159
- name: Check packages
160160
run: |
161161
pip uninstall monai

tests/integration/test_reg_loss_integration.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from parameterized import parameterized
2020

2121
from monai.losses import BendingEnergyLoss, GlobalMutualInformationLoss, LocalNormalizedCrossCorrelationLoss
22+
from monai.utils import set_determinism
2223
from tests.test_utils import SkipIfBeforePyTorchVersion
2324

2425
TEST_CASES = [
@@ -33,14 +34,11 @@
3334

3435
class TestRegLossIntegration(unittest.TestCase):
3536
def setUp(self):
36-
torch.backends.cudnn.deterministic = True
37-
torch.backends.cudnn.benchmark = False
38-
torch.manual_seed(0)
37+
set_determinism(0)
3938
self.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu:0")
4039

4140
def tearDown(self):
42-
torch.backends.cudnn.deterministic = False
43-
torch.backends.cudnn.benchmark = True
41+
set_determinism(None)
4442

4543
@parameterized.expand(TEST_CASES)
4644
@SkipIfBeforePyTorchVersion((1, 9))

0 commit comments

Comments
 (0)