Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Change current device in stream context manager if necessary#16128

Closed
mrshenli wants to merge 3 commits into
pytorch:masterfrom
mrshenli:stream
Closed

Change current device in stream context manager if necessary#16128
mrshenli wants to merge 3 commits into
pytorch:masterfrom
mrshenli:stream

Conversation

@mrshenli
Copy link
Copy Markdown
Contributor

Fixes #16019

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@mrshenli has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@mrshenli has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@mrshenli mrshenli changed the title Change current device if stream context manager if necessary Change current device in stream context manager if necessary Jan 17, 2019
@mrshenli mrshenli requested a review from colesbury January 18, 2019 02:57
Comment thread test/test_cuda.py

@unittest.skipIf(not TEST_MULTIGPU, "detected only one GPU")
@skipIfRocm
def test_stream_context(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer a more targeted test-case here for the stream context behavior. For example, this implicitly tests that the device and stream switch by using query() and _sleep. I'd rather just check that the device and stream are set appropriately and reset appropriately. For example, something like:

  • Switch to s1, check that torch.cuda.current_stream() is s1 and current_device() is 1
  • Check that stream and device are restored after context manager
  • Check nested context managers

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@mrshenli has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ezyang ezyang added the merged label Jun 25, 2019
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
…#16128)

Summary:
Fixes pytorch#16019
Pull Request resolved: pytorch#16128

Differential Revision: D13721850

Pulled By: mrshenli

fbshipit-source-id: 422c6c0b97c1cd46e127e265b532cb8c74a3aac5
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.

No error when selecting a stream that belongs to a different device

4 participants