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

Try to fix the problem that the insightface cannot converge。 #5906

Merged
merged 6 commits into from
Aug 16, 2021

Conversation

BBuf
Copy link
Contributor

@BBuf BBuf commented Aug 16, 2021

Try to fix the problem that the insightface cannot converge 。

dx->shape().elem_cnt() * sizeof(T));
Memset<DeviceType::kGPU>(ctx->device_ctx(), alpha_diff->mut_dptr<T>(), 0,
alpha_diff->shape().elem_cnt() * sizeof(T));

Copy link
Contributor

Choose a reason for hiding this comment

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

这里为什么需要memset呢? 感觉每一个位置都会被赋值的啊

Copy link
Contributor

Choose a reason for hiding this comment

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

dx可以不用memset,alpha_diff是需要的,alpha_diff的kernel实现是累加

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的,是这里的问题,忘记清0了,梯度累加炸了。我现在本地验证了resnet50,可以正常收敛。

Copy link
Contributor

Choose a reason for hiding this comment

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

按后江的回复,可以删掉dx的memset

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改。

@BBuf BBuf requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 16, 2021 08:17
@oneflow-ci-bot oneflow-ci-bot removed their request for review August 16, 2021 08:21
@oneflow-ci-bot oneflow-ci-bot self-requested a review August 16, 2021 08:21
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 16, 2021 09:33
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

PyTorch resnet50 time: 137.8ms (= 6887.7ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 126.1ms (= 6305.0ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
Relative speed: 1.09 (= 137.8ms / 126.1ms)

PyTorch resnet50 time: 82.6ms (= 4128.2ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 73.0ms (= 3649.9ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
Relative speed: 1.13 (= 82.6ms / 73.0ms)

PyTorch resnet50 time: 61.0ms (= 3049.9ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 47.3ms (= 2367.1ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
Relative speed: 1.29 (= 61.0ms / 47.3ms)

PyTorch resnet50 time: 48.3ms (= 2416.9ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 39.2ms (= 1961.6ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
Relative speed: 1.23 (= 48.3ms / 39.2ms)

PyTorch resnet50 time: 38.4ms (= 1919.3ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 38.7ms (= 1934.5ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
Relative speed: 0.99 (= 38.4ms / 38.7ms)

@oneflow-ci-bot oneflow-ci-bot removed their request for review August 16, 2021 10:22
@oneflow-ci-bot oneflow-ci-bot merged commit 1b7511b into master Aug 16, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the fix_prelu_insightface_bug branch August 16, 2021 10:24
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.

6 participants