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

Set expected place in child thread for dataloader to avoid costing cuda memory on other card #30338

Merged
merged 6 commits into from
Jan 13, 2021

Conversation

zhiqiu
Copy link
Contributor

@zhiqiu zhiqiu commented Jan 12, 2021

PR types

Bug fixes

PR changes

Others

Describe

Set expected place in child thread for dataloader to avoid costing cuda memory on other card

cudaSetDevice() is valid inside host thread, so the child thread in dataloader may have the default device id (0) if not set explicitly, which may cost about 500MB memory on card 0.

It is worse when doing multi-card training in dygraph, since each process will cost about 500MB memory on card 0.

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@chenwhql chenwhql left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@heavengate heavengate left a comment

Choose a reason for hiding this comment

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

LGTM for multi-process DataLoader

Copy link
Contributor

@Xreki Xreki left a comment

Choose a reason for hiding this comment

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

LGTM for the change of framework.py

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhiqiu zhiqiu merged commit 3d015f1 into PaddlePaddle:develop Jan 13, 2021
zhiqiu added a commit to zhiqiu/Paddle that referenced this pull request Jan 13, 2021
…da memory on other card (PaddlePaddle#30338)

* set expected place in child thread for dataloader

* set device id when set tensor from numpy

* revert tensor_py change

* add compile guard

* fix ci

* fix bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants