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

Reduce dnn top memory consumption #11461

Merged
merged 3 commits into from
May 11, 2018

Conversation

dkurt
Copy link
Member

@dkurt dkurt commented May 4, 2018

  • Replace double precision weights introduced at Remove setBatchNorm and setScale methods #10821 to fusion multipliers.
  • Avoid Caffe weights copying during network upgrade.
  • Release weights memory after parsing protobuf layer (Caffe and TensorFlow importers).

Maximum resident size for a single image forward pass according to /usr/bin/time --verbose:

(Importer) Network Weights (MB) output/internal blobs (MB) Import + forward (MB)
current
Import + forward (MB)
PR
X-factor
(PR vs. current)
(Caffe) AlexNet 233 3.4 726 398 0.5482093664
(Caffe) GoogLeNet 52 14.9 169 81.7 0.4834319527
(Caffe) ResNet-50 98 12.6 404 221.7 0.5487623762
(Caffe) SqueezeNet v1.1 4.8 8.35 45 34.7 0.7711111111
(Caffe) MobileNet-SSD 23 13 118 73.1 0.6194915254
(TF) MobileNet-SSD 28 13.55 136 82.4 0.6058823529
(TF) Inception 5h 52 15.47 161 113.4 0.7043478261
(Torch) OpenFace 31 1.92 76 72.8 0.9578947368
(Torch) Enet @ 512x512 3.1 65 88 86.1 0.9784090909
(Darknet) YOLOv3 237 54.7 1038 553.7 0.5334296724
allow_multiple_commits=1

@dkurt dkurt changed the base branch from master to 3.4 May 4, 2018 09:26
@dkurt dkurt mentioned this pull request May 4, 2018
V1LayerParameter* layer_param) {
const V1LayerParameter& v0_layer_connection = *v0_layer_connection_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static analyzers dislikes this (NULL pointer dereference):

  • add pointer check before (CV_Assert(ptr != NULL))
  • or revert pointer to reference (but this check should be added in caller).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alalek, It was just to reduce number of modified lines. So I replaced all the v0_layer_connection. to v0_layer_connection->.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is the same: needed an assertion check or non-NULL guarantee before using of "->".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alalek, thanks, got it! Added it here and at UpgradeV1Net and UpgradeV1LayerParameter.

@dkurt dkurt force-pushed the dnn_reduce_mem_consumption branch from 0f108ed to 8f5a4e9 Compare May 10, 2018 13:05
@dkurt dkurt force-pushed the dnn_reduce_mem_consumption branch from 8f5a4e9 to c99c3e7 Compare May 10, 2018 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants