Implement break-down mode for cross entropy calculation #1257
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR prevents the training process from falling down to the CPU mode, possibly happens in following case.
When calculating cross entropy, the process requires a tensor with following size
nr_of_detected_objects * nr_of_ground_truth * nr_of_classes
which may explode in the above case and cause GPU OOM.
This PR implements break-down mode of cross entropy calculation, which requires only
nr_of_detected_objects * nr_of_classes
of tensor. This mode will be tried when the original code caused OOM, and still runs far faster than the CPU mode.
For testing, you can pull the following branch
https://github.com/penkoba/YOLOX/tree/break_down_cross_entropy_calc-test
and run
test-train.sh
, then you may see entering the break-down mode but still runs at acceptable speed.Without this PR, the traning process falls into CPU mode very often and gets very slow.
(tested with RTX 2080 Ti)