* update template to pytorch 1.10+ and lightning 1.5+ * add experiment mode to all experiment configs and implement special logging paths for experiment mode * add `MaxMetric` to model, for computation of best so far validation accuracy * add RichProgressBar to default callbacks * get rid of trick for preventing auto hparam logging, since lightning now supports it with `self.save_hyperparameters(logger=False)` * add `self.save_hyperparameters()` to datamodule since lightinng now supports it * deprecate Apex support * deprecate bash script for conda setup * change `terminate_on_nan` debug option to `detect_anomaly` for compatibility with lightning v1.5 * specify model and datamodule during `trainer.test()`, for compatibility with lightning v1.5 * remove `configs/trainer/all_params.yaml` * make hyperparameter optimization compatible with lightning v1.5 * general documentation improvements
30 lines
803 B
Python
30 lines
803 B
Python
import platform
|
|
from importlib.util import find_spec
|
|
|
|
"""
|
|
Adapted from:
|
|
https://github.com/PyTorchLightning/pytorch-lightning/blob/master/pytorch_lightning/utilities/imports.py
|
|
"""
|
|
|
|
|
|
def _module_available(module_path: str) -> bool:
|
|
"""Check if a path is available in your environment.
|
|
|
|
>>> _module_available('os')
|
|
True
|
|
>>> _module_available('bla.bla')
|
|
False
|
|
|
|
"""
|
|
try:
|
|
return find_spec(module_path) is not None
|
|
except ModuleNotFoundError:
|
|
# Python 3.7+
|
|
return False
|
|
|
|
|
|
_IS_WINDOWS = platform.system() == "Windows"
|
|
_DEEPSPEED_AVAILABLE = not _IS_WINDOWS and _module_available("deepspeed")
|
|
_FAIRSCALE_AVAILABLE = not _IS_WINDOWS and _module_available("fairscale.nn")
|
|
_RPC_AVAILABLE = not _IS_WINDOWS and _module_available("torch.distributed.rpc")
|