Skip to content

mypy error with reproducible code #38410

@RMeli

Description

@RMeli

🐛 Bug

When I use mypy with the following reproducible code

import torch
from torch.backends import cudnn
torch.manual_seed(0)

cudnn.deterministic = True
cudnn.benchmark = False

I get an error:

test.py:5: error: Module has no attribute "deterministic"
test.py:6: error: Module has no attribute "benchmark"
Found 2 errors in 1 file (checked 1 source file)

I think the problem arises from the fact that deterministic and benchmark are not defined in torch.backends.cudnn.__init__. Is there a workaround for this error (which is making my CI fail)?

To Reproduce

Steps to reproduce the behavior:

  1. Use mypy with the above code snippet.

Expected behavior

I expect mypy to return no errors.

Environment

PyTorch version: 1.4.0
Is debug build: No
CUDA used to build PyTorch: 10.1

OS: Ubuntu 18.04.4 LTS
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
CMake version: version 3.10.2

Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: GeForce GTX 1080 Ti
Nvidia driver version: 440.64
cuDNN version: Could not collect

Additional context

X-posted from the the PyTorch Forums: Mypy error with reproducible code. @albanD

cc @ezyang

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: typingRelated to mypy type annotationstriagedThis 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