Skip to content

Commit 8cbc6fb

Browse files
authored
1366-fix-deepatlas-ssim-loss-issue (#1397)
Fixes #1336 . Turn off the TF32 precision in this tutorial to fix the ssim loss issue caused by the rounding error. ### Description A few sentences describing the changes proposed in this pull request. ### Checks <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [ ] Avoid including large-size files in the PR. - [ ] Clean up long text outputs from code cells in the notebook. - [ ] For security purposes, please check the contents and remove any sensitive info such as user names and private key. - [ ] Ensure (1) hyperlinks and markdown anchors are working (2) use relative paths for tutorial repo files (3) put figure and graphs in the `./figure` folder - [ ] Notebook runs automatically `./runner.sh -t <path to .ipynb file>` Signed-off-by: binliu <[email protected]>
1 parent 3dfe68f commit 8cbc6fb

File tree

1 file changed

+14
-28
lines changed

1 file changed

+14
-28
lines changed

deep_atlas/deep_atlas_tutorial.ipynb

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
"\n",
2929
"This notebook works with 3D images and segmentations, and it results in two trained models: a segmentation network `seg_net` and a registration network `reg_net`. There are two training phases: a pre-training phase for the segmentation network alone, and an alternating training phase for the two networks together. Use of the trained models for inference is demonstrated at the end of the notebook.\n",
3030
"\n",
31-
"Please note that this notebook is verified to work well on the NVIDIA H100/A100/V100 GPU. However, there is a problem in the `Train Networks` part when running on the NVIDIA L40/3090Ti/3080Ti GPU. Track this [issue](https://github.com/Project-MONAI/tutorials/issues/1336) for more detail.\n",
32-
"\n",
3331
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Project-MONAI/tutorials/blob/main/deep_atlas/deep_atlas_tutorial.ipynb)\n",
3432
"\n",
3533
"---\n",
@@ -146,9 +144,7 @@
146144
"cell_type": "code",
147145
"execution_count": 2,
148146
"id": "576b9aa6",
149-
"metadata": {
150-
"scrolled": false
151-
},
147+
"metadata": {},
152148
"outputs": [
153149
{
154150
"name": "stderr",
@@ -215,6 +211,11 @@
215211
"# Set deterministic training for reproducibility\n",
216212
"monai.utils.set_determinism(seed=2938649572)\n",
217213
"\n",
214+
"# Turn off the TF32 precision. Otherwise, because of the rounding error, the ssim_loss will be a weird value on some Ampere GPUs, like L40, 3090Ti and 3080Ti.\n",
215+
"# Track this issue (https://github.com/Project-MONAI/tutorials/issues/1336) for more detail.\n",
216+
"torch.backends.cuda.matmul.allow_tf32 = False\n",
217+
"torch.backends.cudnn.allow_tf32 = False\n",
218+
"\n",
218219
"monai.config.print_config()"
219220
]
220221
},
@@ -718,9 +719,7 @@
718719
"cell_type": "code",
719720
"execution_count": 16,
720721
"id": "0a020fc2",
721-
"metadata": {
722-
"scrolled": false
723-
},
722+
"metadata": {},
724723
"outputs": [
725724
{
726725
"name": "stdout",
@@ -1233,9 +1232,7 @@
12331232
"cell_type": "code",
12341233
"execution_count": null,
12351234
"id": "fbbc25b5",
1236-
"metadata": {
1237-
"scrolled": false
1238-
},
1235+
"metadata": {},
12391236
"outputs": [],
12401237
"source": [
12411238
"# Training cell\n",
@@ -1605,9 +1602,7 @@
16051602
"cell_type": "code",
16061603
"execution_count": 39,
16071604
"id": "11402c6e",
1608-
"metadata": {
1609-
"scrolled": false
1610-
},
1605+
"metadata": {},
16111606
"outputs": [],
16121607
"source": [
16131608
"# The following are dictionaries that map segmentation availability labels 00,10,01,11 to MONAI dataloaders\n",
@@ -1690,9 +1685,7 @@
16901685
"cell_type": "code",
16911686
"execution_count": 41,
16921687
"id": "bfdacfa6",
1693-
"metadata": {
1694-
"scrolled": false
1695-
},
1688+
"metadata": {},
16961689
"outputs": [
16971690
{
16981691
"name": "stdout",
@@ -1718,7 +1711,6 @@
17181711
]
17191712
},
17201713
{
1721-
"attachments": {},
17221714
"cell_type": "markdown",
17231715
"id": "c95101e5",
17241716
"metadata": {},
@@ -1758,9 +1750,7 @@
17581750
"cell_type": "code",
17591751
"execution_count": null,
17601752
"id": "ef8af785",
1761-
"metadata": {
1762-
"scrolled": false
1763-
},
1753+
"metadata": {},
17641754
"outputs": [],
17651755
"source": [
17661756
"# Training cell\n",
@@ -1954,9 +1944,7 @@
19541944
"cell_type": "code",
19551945
"execution_count": 43,
19561946
"id": "050dd7b0",
1957-
"metadata": {
1958-
"scrolled": false
1959-
},
1947+
"metadata": {},
19601948
"outputs": [
19611949
{
19621950
"data": {
@@ -2169,9 +2157,7 @@
21692157
"cell_type": "code",
21702158
"execution_count": 60,
21712159
"id": "5801a48e",
2172-
"metadata": {
2173-
"scrolled": false
2174-
},
2160+
"metadata": {},
21752161
"outputs": [
21762162
{
21772163
"name": "stdout",
@@ -2489,7 +2475,7 @@
24892475
"name": "python",
24902476
"nbconvert_exporter": "python",
24912477
"pygments_lexer": "ipython3",
2492-
"version": "3.8.13"
2478+
"version": "3.8.10"
24932479
}
24942480
},
24952481
"nbformat": 4,

0 commit comments

Comments
 (0)