How to use visual studio code for pytorch

I want use visual studio code for pytorch.

it is working…?

but torch is underlined in red.

image

How can i delete that red line…:frowning:

4 Likes

An option is to remove torch from Pylint. Based on a similar solution for numpy, you can add the following config to your settings.

{
    // whitelist torch to remove lint errors
    "python.linting.pylintArgs": [
        "--extension-pkg-whitelist=torch"
    ]
}

A more proper approach might be to fix the Pylint issue with PyTorch, but I don’t know what’s exactly causing this problem (maybe torch functions are not statically resolvable).

8 Likes

Thank you very much!!

Or you can add torch to Pylint.

{
    "python.linting.pylintArgs": [
        // "--generated-members=torch.* "
        ],
}

You may want to give flake8 a try as well. Uninstall Pylint and install flake8 using:

pip install flake8 flake8-mypy flake8-bugbear flake8-comprehensions flake8-executable flake8-pyi mccabe pycodestyle pyflakes

or just:

pip install flake8

Reference: https://github.com/pytorch/pytorch/wiki/Lint-as-you-type