-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Prevent cuda:0 context initialization when working on another cuda device #124722
Conversation
34abcd5
to
26a2ef7
Compare
@@ -1094,7 +1094,13 @@ def fw_compiler_freezing( | |||
from torch._inductor.freezing import convert_conv_weights_to_channels_last, freeze | |||
|
|||
# partition_fn won't be called | |||
_recursive_joint_graph_passes(aot_autograd_model) | |||
inputs_devices = list( | |||
{i.device for i in pytree.tree_flatten(aot_example_inputs)[0]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I should avoid fetching device on non-tensor input
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
Description
Issue description. When user works with "cuda:1" device and compile a model, there is cuda context initialization for device "cuda:0", which can be surprising to the user seeing with nvidia-smi the device 0 utilisation.
Reproduction code:
Output:
This PR fixes cuda context initialization
init_cuda_context
on FakeTensor creation, lazy_init and pattern registrations.cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang