Skip to content

Commit 84b05d1

Browse files
committed
Avoid file not found
1 parent 7b104ee commit 84b05d1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pl_examples/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
_PACKAGE_ROOT = os.path.dirname(_EXAMPLES_ROOT)
1515
_DATASETS_PATH = os.path.join(_PACKAGE_ROOT, 'Datasets')
1616

17-
_TORCHVISION_MNIST_AVAILABLE = not bool(os.environ.get("PL_USE_MOCKED_MNIST", False))
17+
_TORCHVISION_MNIST_AVAILABLE = not bool(os.getenv("PL_USE_MOCKED_MNIST", False))
1818
_DALI_AVAILABLE = _module_available("nvidia.dali")
1919

2020
if _TORCHVISION_MNIST_AVAILABLE:
@@ -23,6 +23,13 @@
2323
MNIST(_DATASETS_PATH, download=True)
2424
except HTTPError:
2525
_TORCHVISION_MNIST_AVAILABLE = False
26+
except RuntimeError as e:
27+
# `torchvision` can produce the following error randomly.
28+
# File "/usr/local/lib/python3.7/dist-packages/torchvision/datasets/utils.py", line 145, in download_url
29+
# raise RuntimeError("File not found or corrupted.")
30+
if "File not found" not in e:
31+
raise
32+
_TORCHVISION_MNIST_AVAILABLE = False
2633

2734
LIGHTNING_LOGO = """
2835
####

0 commit comments

Comments
 (0)