Skip to content

[CUDA 12] Autograd engine follow up#94929

Closed
Aidyn-A wants to merge 1 commit intopytorch:masterfrom
Aidyn-A:cuda12_autograd_engine_follow_up
Closed

[CUDA 12] Autograd engine follow up#94929
Aidyn-A wants to merge 1 commit intopytorch:masterfrom
Aidyn-A:cuda12_autograd_engine_follow_up

Conversation

@Aidyn-A
Copy link
Collaborator

@Aidyn-A Aidyn-A commented Feb 15, 2023

This PR is follow up to #91191.
In my latest local builds USE_CUDA not being defined by default, therefore the following piece of code never enters the guards:

#if defined(USE_CUDA)
if (at::detail::getCUDAHooks().hasPrimaryContext(device)) {
set_device(device);
}
#else
set_device(device);
#endif

In this PR USE_CUDA is redefined by applying the compile flag.

@pytorch-bot
Copy link

pytorch-bot bot commented Feb 15, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/94929

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 7ae5ba6:
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

cc @malfet

)
set_source_files_properties(${TORCH_SRC_DIR}/csrc/jit/passes/frozen_conv_add_relu_fusion.cpp PROPERTIES COMPILE_FLAGS "-DUSE_CUDA=1")
set_source_files_properties(${TORCH_SRC_DIR}/csrc/jit/codegen/cuda/interface.cpp PROPERTIES COMPILE_FLAGS "-DUSE_CUDA=1")
set_source_files_properties(${TORCH_SRC_DIR}/csrc/autograd/engine.cpp PROPERTIES COMPILE_FLAGS "-DUSE_CUDA=1")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why isn't this set for all files already. That sounds like a bug if it is not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Apparently USE_CUDA was not set. Or could it be that defined function in #if defined(USE_CUDA) is misbehaving? All I see that the code never checks the existence of primary context.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Confirmed, USE_CUDA is just not being defined.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ngimel do you know how this is setup by any chance?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, I don't, sorry. There was this dream that we can have device-agnostic pieces of code, and thus not have any ifdefs in them, like engine.cpp, but apparently this doesn't work.
This would also need corresponding changes in the internal builds, cc @dagitses

@ngimel ngimel added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Feb 16, 2023
@Aidyn-A Aidyn-A closed this Mar 1, 2023
@albanD
Copy link
Collaborator

albanD commented Mar 1, 2023

Should we just wait until we have cuda 12 CI until fixing this?

@Aidyn-A
Copy link
Collaborator Author

Aidyn-A commented Mar 1, 2023

@albanD I believe one of these #94929, #92354 should be merged sooner than later, since there are users who build manually with CUDA 12.
Both PRs (#94929, #92354) target the same goal, which do you think is the safest?

@albanD
Copy link
Collaborator

albanD commented Mar 1, 2023

But until we have CI all of these will be pretty flaky as we can't actually test they do anything?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants