Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can we know how many resources my training is using? #10186

Closed
1 task done
JesusSilvaUtrera opened this issue Nov 17, 2022 · 4 comments
Closed
1 task done

How can we know how many resources my training is using? #10186

JesusSilvaUtrera opened this issue Nov 17, 2022 · 4 comments
Labels
question Further information is requested Stale

Comments

@JesusSilvaUtrera
Copy link

Search before asking

Question

Hi, I wanted to know why the value of the gpu_mem increases with the passage of the epochs and it's not a constant (or almost constant) value, because every epoch has the same batch size and input size, so the memory usage should be the same, shouldn't it?

Also I wanted to know how can we know how many RAM memory is necessary for our training in case, for example, we want to deploy a service on a cluster to train models.

Thanks in advance.

Additional

No response

@JesusSilvaUtrera JesusSilvaUtrera added the question Further information is requested label Nov 17, 2022
@glenn-jocher
Copy link
Member

glenn-jocher commented Nov 17, 2022

@JesusSilvaUtrera 👋 Hello! Thanks for asking about CUDA memory issues. YOLOv5 🚀 can be trained on CPU, single-GPU, or multi-GPU. When training on GPU it is important to keep your batch-size small enough that you do not use all of your GPU memory, otherwise you will see a CUDA Out Of Memory (OOM) Error and your training will crash. You can observe your CUDA memory utilization using either the nvidia-smi command or by viewing your console output:

Screenshot 2021-05-28 at 12 19 51

CUDA Out of Memory Solutions

If you encounter a CUDA OOM error, the steps you can take to reduce your memory usage are:

  • Reduce --batch-size
  • Reduce --img-size
  • Reduce model size, i.e. from YOLOv5x -> YOLOv5l -> YOLOv5m -> YOLOv5s > YOLOv5n
  • Train with multi-GPU at the same --batch-size
  • Upgrade your hardware to a larger GPU
  • Train on free GPU backends with up to 16GB of CUDA memory: Open In Colab Open In Kaggle

AutoBatch

You can use YOLOv5 AutoBatch (NEW) to find the best batch size for your training by passing --batch-size -1. AutoBatch will solve for a 90% CUDA memory-utilization batch-size given your training settings. AutoBatch is experimental, and only works for Single-GPU training. It may not work on all systems, and is not recommended for production use.

Screenshot 2021-11-06 at 12 31 10

Good luck 🍀 and let us know if you have any other questions!

@JesusSilvaUtrera
Copy link
Author

For example, if I throw a training in local, it takes a lot more time than when I use docker compose for example, but in the docker compose if I use more than 100 images it exceeds the resources (I have 8 gb RAM dedicated to docker), whereas in my local I can throw a training with 200 images and it goes slow but doesn't show any error. i want to know why this happens and how to fix this, or at least know how many resources my training needs

@github-actions
Copy link
Contributor

github-actions bot commented Dec 18, 2022

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

Access additional Ultralytics ⚡ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!

@github-actions github-actions bot added the Stale label Dec 18, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 28, 2022
@glenn-jocher
Copy link
Member

@JesusSilvaUtrera Great observations! The local training may be taking longer due to hardware acceleration differences or other system-specific factors. The Docker environment with 8GB of RAM dedicated may be insufficient for larger workloads, causing resource exhaustion during training.

To determine your training's resource requirements, start with smaller batches and incrementally increase the batch size until you encounter resource limitations. Likewise, monitor GPU memory usage and adjust your batch size or image resolution to fit within your available resources. You can use system monitoring tools such as nvidia-smi for GPU memory usage and top for CPU and RAM utilization.

In the Docker environment, you might consider increasing the allocated memory to support larger workloads. Additionally, using resource limits, such as setting a memory limit with the --memory flag in Docker, can help avoid resource exhaustion.

Optimizing resource usage often involves a balance of batch size, image resolution, and available hardware. Feel free to reach out if you have further questions or need assistance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

2 participants