Open NicolasDrapier opened 1 week ago
π Hello @NicolasDrapier, thank you for bringing this to our attention! π We understand how important it is to get your issue resolved. Here's how you can help us assist you more effectively:
To investigate this π potential bug thoroughly, we kindly ask that you provide a minimum reproducible example (MRE). This helps ensure that we can pinpoint the issue quickly and provide an accurate solution. The MRE should ideally include:
Detect
head and v8DetectionLoss
function.In the meantime, please ensure that you are using the latest version of Ultralytics. Upgrade with the following command and let us know if the issue persists afterward:
pip install -U ultralytics
We also recommend running your implementation in one of our verified environments to ensure compatibility. YOLO may be run in environments such as:
π While we await your MRE, you may also find it useful to visit our Documentation and explore our Model Training Tips for potential insights.
If you'd like to connect with the broader community for additional support while we investigate, feel free to join us on Discord π§, Discourse, or our Subreddit.
An Ultralytics engineer will also review your issue soon and provide further assistance. Thank you for your patience and for helping improve Ultralytics! π
If it's only with your custom backbone, then it could be related to the backbone since it doesn't occur with the default backbone.
It does not occur with my backbone and the CenterNet head. It occurs with my backbone and this Detect head. My backbone is just the Swin Transformer from hugging face
@NicolasDrapier for memory leaks specific to custom backbones with Detect heads, we recommend:
torch.cuda.memory_profiler
to identify exact leak locationsThe v8DetectionLoss maintains gradient histories - ensure intermediate outputs are properly detached when using custom components. Would you mind sharing a minimal reproducible code snippet showing your head-backbone integration? This would help us investigate further.
Search before asking
Ultralytics YOLO Component
No response
Bug
I am encountering a memory leak issue when using the Detect head with my custom backbone and the v8DetectionLoss function. This results in a CUDA out-of-memory (COOM) error during training. Switching to the CenterNet head resolves the issue, suggesting the problem is specific to the Detect head configuration.
Periodically empty PyTorch's cache using torch.cuda.empty_cache() every few steps temporarily mitigates the issue but does not resolve the root cause.
How can I help you to find the root cause of this problem?
Model:
Environment
Minimal Reproducible Example
Additional
No response
Are you willing to submit a PR?