From d198f3f9d1540882b8cc9eed185422b2bd50ae6c Mon Sep 17 00:00:00 2001 From: Ayush Chaurasia Date: Tue, 20 Dec 2022 09:53:55 +0530 Subject: [PATCH] Update docs (#73) Co-authored-by: Laughing-q <1185102784@qq.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- docs/quickstart.md | 11 ++++++++--- docs/sdk.md | 3 +++ ultralytics/yolo/engine/trainer.py | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/quickstart.md b/docs/quickstart.md index 4377d6a..42d0f2a 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -24,11 +24,15 @@ CLI requires no customization or code. You can simply run all tasks from the ter classify val s-seg.pt ``` - === "Example" + === "Example training" ```bash - yolo task=detect mode=val model=s.yaml + yolo task=detect mode=train model=s.yaml ``` TODO: add terminal screen/gif + === "Example training DDP" + ```bash + yolo task=detect mode=train model=s.yaml device=\'0,1,2,3\' + ``` [CLI Guide](#){ .md-button .md-button--primary} ## Python API @@ -42,5 +46,6 @@ Ultralytics YOLO comes with pythonic Model and Trainer interface. model.new("s-seg.yaml") # automatically detects task type model.load("s-seg.pt") # load checkpoint model.train(data="coco128-segments", epochs=1, lr0=0.01, ...) + model.train(data="coco128-segments", epochs=1, lr0=0.01, device="0,1,2,3") # DDP mode ``` -[API Guide](#){ .md-button .md-button--primary} \ No newline at end of file +[API Guide](#){ .md-button .md-button--primary} diff --git a/docs/sdk.md b/docs/sdk.md index bd2bfb4..148f9fd 100644 --- a/docs/sdk.md +++ b/docs/sdk.md @@ -74,6 +74,7 @@ You can easily cusotmize Trainers to support custom tasks or explore R&D ideas. from ultralytics import yolo trainer = yolo.DetectionTrainer(data=..., epochs=1) # override default configs + trainer = yolo.DetectionTrainer(data=..., epochs=1, device="1,2,3,4") # DDP trainer.train() ``` @@ -82,6 +83,7 @@ You can easily cusotmize Trainers to support custom tasks or explore R&D ideas. from ultralytics import yolo trainer = yolo.SegmentationTrainer(data=..., epochs=1) # override default configs + trainer = yolo.SegmentationTrainer(data=..., epochs=1, device="0,1,2,3") # DDP trainer.train() ``` === "ClassificationTrainer" @@ -89,6 +91,7 @@ You can easily cusotmize Trainers to support custom tasks or explore R&D ideas. from ultralytics import yolo trainer = yolo.ClassificationTrainer(data=..., epochs=1) # override default configs + trainer = yolo.ClassificationTrainer(data=..., epochs=1, device="0,1,2,3") # DDP trainer.train() ``` diff --git a/ultralytics/yolo/engine/trainer.py b/ultralytics/yolo/engine/trainer.py index 53e376c..6859369 100644 --- a/ultralytics/yolo/engine/trainer.py +++ b/ultralytics/yolo/engine/trainer.py @@ -119,7 +119,7 @@ class BaseTrainer: torch.cuda.set_device(rank) self.device = torch.device('cuda', rank) self.console.info(f"RANK - WORLD_SIZE - DEVICE: {rank} - {world_size} - {self.device} ") - + mp.use_start_method('spawn', force=True) dist.init_process_group("nccl" if dist.is_nccl_available() else "gloo", rank=rank, world_size=world_size) def _setup_train(self, rank, world_size):