This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# >>> debug | |
def print_debug(name, obj): | |
print(f"[DEBUG] {name}: ({type(obj).__name__})({obj})", end="\n---\n") | |
print_debug("test", []) | |
# <<< debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def init_logging( | |
log_path=None, | |
format="[%(levelname)s] [%(asctime)s.%(msecs)d] [pid %(process)d] [%(pathname)s:%(lineno)d:%(funcName)s]\n%(message)s", | |
datefmt="%Y-%m-%d %H:%M:%S", | |
level=logging.INFO, | |
force=True, | |
): | |
if force: | |
logging.shutdown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
GPU Monitor with Email and Execution | |
This script monitors the usage of GPUs on a system and, when there are enough free GPUs, execute a specified function. | |
The function run a bash script by default but could be any other executable code. | |
This script uses the GPUtil library to monitor GPU usage. | |
Preparation: | |
1. `pip install GPUtil` | |
2. define your own `func` if needed |