Comments (4)
@lbeaucourt hi there,
Thank you for providing a detailed report and the minimal reproducible example. This is very helpful! 😊
The error you're encountering, ValueError: Default process group has not been initialized, please make sure to call init_process_group
, typically arises when the distributed training setup is not properly initialized.
Here are a few steps to help troubleshoot and resolve this issue:
-
Ensure Latest Versions: First, please make sure you are using the latest versions of
torch
andultralytics
. You can upgrade them using:%pip install -U torch ultralytics
-
Environment Variables: It seems you are setting
RANK
andWORLD_SIZE
to-1
, which indicates single-node training. However, the error suggests that the code is attempting to use distributed training. Ensure that these environment variables are correctly set before running the training:os.environ["RANK"] = "0" os.environ["WORLD_SIZE"] = "1"
-
Manual Initialization: If you still encounter issues, try manually initializing the process group before calling
model.train()
. This can be done as follows:import torch.distributed as dist if torch.cuda.device_count() > 1: dist.init_process_group(backend='nccl', init_method='env://')
-
Training Code: Here is an updated version of your code snippet incorporating the above suggestions:
%pip install -q -U ultralytics mlflow torch dbutils.library.restartPython() import os from ultralytics import YOLO import torch.distributed as dist import torch os.environ["RANK"] = "0" os.environ["WORLD_SIZE"] = "1" token = dbutils.notebook.entry_point.getDbutils().notebook().getContext().apiToken().get() dbutils.fs.put("file:///root/.databrickscfg","[DEFAULT]\nhost=<host>\ntoken = "+token,overwrite=True) model = YOLO('yolov8m-seg.pt') data_path = "data_path" model.tune(data=data_path + 'data.yaml', device=0, epochs=5, iterations=1, optimizer="AdamW", plots=False, save=False, val=False) if torch.cuda.device_count() > 1: dist.init_process_group(backend='nccl', init_method='env://') model.train(data=data_path + 'data.yaml', name='yolov8m_seg_train_after_tune', epochs=3, optimizer="AdamW", device=0, cfg="<path>/best_hyperparameters.yaml")
Please try these steps and let us know if the issue persists. Your feedback is invaluable to us, and we appreciate your patience as we work to resolve this.
from ultralytics.
Hi @lbeaucourt,
Thank you for the detailed follow-up and for sharing your working solution! 😊
It's great to hear that the provided solution works for model.train()
. The difference in behavior between model.tune()
and model.train()
regarding the environment variables and process group initialization is indeed intriguing. This could be due to differences in how these methods handle distributed training under the hood.
For now, your approach of setting the environment variables before model.train()
and keeping the previous settings for model.tune()
seems to be a practical workaround. If you encounter any further issues or have more questions, feel free to reach out.
Happy training! 🚀
from ultralytics.
👋 Hello @lbeaucourt, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.
If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.
If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.
Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.
Install
Pip install the ultralytics
package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.
pip install ultralytics
Environments
YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
- Notebooks with free GPU:
- Google Cloud Deep Learning VM. See GCP Quickstart Guide
- Amazon Deep Learning AMI. See AWS Quickstart Guide
- Docker Image. See Docker Quickstart Guide
Status
If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.
from ultralytics.
Hi @glenn-jocher , Thank you very much for this clear reply !
I tested your solution and it works fine BUT only for model.train(). I explain a bit, if a set the environment variables BEFORE model.tune() as follow
os.environ["RANK"] = "0"
os.environ["WORLD_SIZE"] = "1"
model.tune(...)
Then tunning fail with error: "Default process group has not been initialized, please make sure to call init_process_group"
But, if I keep previous env variable setting for tuning and I change the setting before training, it works !
So, thanks for your answer, it solves my problem. I still not sure to understand why behaviour is different from model.tune() to model.train() but it's not a pain point.
The final version of the code which is working for me is:
%pip install -q -U ultralytics mlflow torch
dbutils.library.restartPython()
import os
from ultralytics import YOLO
import torch.distributed as dist
import torch
os.environ["RANK"] = "-1"
os.environ["WORLD_SIZE"] = "-1"
token = dbutils.notebook.entry_point.getDbutils().notebook().getContext().apiToken().get()
dbutils.fs.put("file:///root/.databrickscfg","[DEFAULT]\nhost=<host>\ntoken = "+token,overwrite=True)
model = YOLO('yolov8m-seg.pt')
data_path = "data_path"
model.tune(data=data_path + 'data.yaml', device=0,
epochs=5, iterations=1, optimizer="AdamW", plots=False, save=False, val=False)
os.environ["RANK"] = "0"
os.environ["WORLD_SIZE"] = "1"
if torch.cuda.device_count() > 1:
dist.init_process_group(backend='nccl', init_method='env://')
model.train(data=data_path + 'data.yaml', name='yolov8m_seg_train_after_tune', epochs=3, optimizer="AdamW", device=0,
cfg="<path>/best_hyperparameters.yaml")
from ultralytics.
Related Issues (20)
- Issue with Training YOLOv8 on a Large Dataset with lack of memory and not good enough HOT 4
- Fail to run on videos from some specific cameras HOT 1
- ScannerError when import ultralytics HOT 2
- Continuous learning: top1_acc lower than before HOT 10
- Confidence Labels HOT 2
- img and orig_imgs HOT 1
- Getting all the mAP50-95 interval values for IoU thresholds ranging from 0.50 to 0.95. HOT 4
- YOLO-6D-Pose: Enhancing YOLO for Single-Stage Monocular Multi-Object 6D Pose Estimation HOT 2
- False Positive rate is high with YOLOv8 Pose Model on CCTV camera feeds HOT 6
- AttributeError: "OBB" object has no attribute "xyxy". See valid attributes below. HOT 7
- What are the input layer name and output layer name of yolov8? HOT 1
- yolov8 segmenation parameter questions HOT 3
- Sudden FPS drop on a MacBook Pro with M3 Max HOT 5
- exe file for yolov8 using openvino goes on loop HOT 4
- When I was training the dataset, I enabled AMP. I downloaded yolov8n.pt into the ultralytics folder and the ultralytics/ultralytics folder. During the first few training sessions, I wasn't prompted to download yolov8n.pt, but after training a few times, I was prompted that AMP needs to download yolov8n.pt and it keeps waiting for the download. My server is extremely slow at downloading from GitHub, so I want to know where exactly I should place the .pt file so that it can be automatically detected during runtime? HOT 3
- When using OBB training, I found that the number of predicted objects after post-processing did not match the final result number HOT 4
- yolov8 predict: 'DetectionModel' object has no attribute 'end2end' HOT 5
- Modify Yolov8 output size HOT 7
- Libraries misalignment in ultralytics and super_gradients required for model YOLO-NAS HOT 7
- YOLOv9 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultralytics.