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

Calling cuda() with async results in SyntaxError #2

Open
samarth12 opened this issue Oct 25, 2020 · 1 comment
Open

Calling cuda() with async results in SyntaxError #2

samarth12 opened this issue Oct 25, 2020 · 1 comment

Comments

@samarth12
Copy link

The error occurs in this line.

if use_cuda:
    torch_t = torch.cuda
    def from_numpy(ndarray):
        return torch.from_numpy(ndarray).pin_memory().cuda(async=True)

The reason for this error is that async has become a reserved keyword from python 3.7. The cuda() constructor arguments have changed as well. This is how the new constructor looks -

cuda(device=None, non_blocking=False)

async=True can be replaced by non_blocking=True.

non_blocking (bool):
If True and the source is in pinned memory, the copy will be asynchronous with respect to the host. Otherwise, the argument has no effect. Default: False.

@pariajm
Copy link
Owner

pariajm commented May 2, 2021

The error occurs in this line.

if use_cuda:
    torch_t = torch.cuda
    def from_numpy(ndarray):
        return torch.from_numpy(ndarray).pin_memory().cuda(async=True)

The reason for this error is that async has become a reserved keyword from python 3.7. The cuda() constructor arguments have changed as well. This is how the new constructor looks -

cuda(device=None, non_blocking=False)

async=True can be replaced by non_blocking=True.

non_blocking (bool):
If True and the source is in pinned memory, the copy will be asynchronous with respect to the host. Otherwise, the argument has no effect. Default: False.

Thanks! I updated parse_nk.py

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

No branches or pull requests

2 participants