Skip to content

with emit_nvtx context manager is broken in current master. #21644

@mcarilli

Description

@mcarilli
$ docker pull pytorch/pytorch:nightly-runtime-cuda10.0-cudnn7
$ docker run --runtime=nvidia -it --rm --ipc=host pytorch/pytorch:nightly-runtime-cuda10.0-cudnn7

Run the following script:

import torch

a = torch.tensor([1,2,3], dtype=torch.float32, device='cuda')

with torch.cuda.profiler.profile():
    with torch.autograd.profiler.emit_nvtx():
        b = a.sum()

Result:

root@0727b6d13c99:/data/sandbox_python/autograd_explore/profiler# python test.py 
Traceback (most recent call last):
  File "test.py", line 8, in <module>
    with torch.autograd.profiler.emit_nvtx():
  File "/opt/conda/lib/python3.6/site-packages/torch/autograd/profiler.py", line 398, in __enter__
    self.record_shapes
AttributeError: 'emit_nvtx' object has no attribute 'record_shapes'

The offending line is simple:
https://github.com/pytorch/pytorch/blob/master/torch/autograd/profiler.py#L398
I'd submit a quick PR to fix it, but I'm not sure what you guys actually want the value of record_shapes to be for this call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: autogradRelated to torch.autograd, and the autograd engine in generalmodule: 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