Skip to content

[CUDA] Remove footgun related to non-blocking copies #130785

@embg

Description

@embg

Edit: I filed this issue because I believed the following code has a use-after-free.

def foo():
    A = torch.rand(SIZE, device="cpu", pin_memory=True)
    B = A.cuda(non_blocking=True)
    return B

C = foo()
# do stuff with C

It turns out that PyTorch actually keeps the pinned memory alive until the memcpy event is complete. There is no bug. Pretty cool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: cudaRelated to torch.cuda, and CUDA support in generaltriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions