-
Notifications
You must be signed in to change notification settings - Fork 1
/
train.py
44 lines (34 loc) · 1.35 KB
/
train.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import dotenv
import hydra
from omegaconf import DictConfig, open_dict
# load environment variables from `.env` file if it exists
# recursively searches for `.env` in all folders starting from work dir
dotenv.load_dotenv(override=True)
@hydra.main(config_path="configs/", config_name="train.yaml")
def main(config: DictConfig):
if "debugme" in config:
import debugpy
strport = config.debugme
debugpy.listen(strport)
print(
f"waiting for debugger on {strport}. Add the following to your launch.json and start the VSCode debugger with it:"
)
print(
f'{{\n "name": "Python: Attach",\n "type": "python",\n "request": "attach",\n "connect": {{\n "host": "localhost",\n "port": {strport}\n }}\n }}'
)
debugpy.wait_for_client()
with open_dict(config):
config.trainer.gpus = [0]
# config.trainer.accelerator = None
config.trainer.strategy = None
config.loggers = {}
# Imports can be nested inside @hydra.main to optimize tab completion
# https://github.com/facebookresearch/hydra/issues/934
from src import utils
from src.training_pipeline import train
# Applies optional utilities
utils.extras(config)
# Train model
return train(config)
if __name__ == "__main__":
main()