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

namespaces torch.cuda, torch.device missing from pyi #16996

Closed
soumith opened this issue Feb 12, 2019 · 32 comments
Closed

namespaces torch.cuda, torch.device missing from pyi #16996

soumith opened this issue Feb 12, 2019 · 32 comments

Comments

@soumith
Copy link
Member

soumith commented Feb 12, 2019

🐛 Bug

Auto-complete / type information for torch.cuda / torch.device are missing, as reported at #7318 (comment)

To Reproduce

Auto-complete torch.cuda.<TAB> in pycharm

@zhezh
Copy link

zhezh commented Feb 12, 2019

torch.device() torch.tensor() are still missing, I believe they are much frequently used.

@fengyanghe
Copy link

torch.randn() and torch.FloatTensor() are still missing in PyTorch 1.0.1, related to vs code and wing ide

@t-vi
Copy link
Collaborator

t-vi commented Feb 14, 2019

torch.FloatTensor is deprecated. Unfortunately, there doesn't seem to be a good mechanism to incorporate deprecation information into type hints, currently. At least that was the case a couple of months ago when I searched for that a bit.

@Wenlong-Shi
Copy link

torch.from_numpy()、torch.ones are still missing in 1.0.1.post2,related to Pycharm。

@fmassa
Copy link
Member

fmassa commented Feb 19, 2019

@Wenlong-Shi I'd say torch.from_numpy is also kind of deprecated, in favor of torch.as_tensor

@Wenlong-Shi
Copy link

@fmassa torch.as_tensor is also missing in 1.0.1.post2,related to Pycharm.

@Luvata
Copy link

Luvata commented Mar 2, 2019

torch.no_grad() is also missing in in 1.0.1.post2, related to Pycharm

@670373064
Copy link

torch.cuda()、torch.utils is also missing in in 1.0.1, related to Pycharm

@magnusjacobsen
Copy link

on 1.0.1, pylint claims torch.tensor() is not callable
Untitled

@Ajk4
Copy link

Ajk4 commented Mar 16, 2019

On pytorch 1.0.1 on Windows I don't see torch.nn package. When ran code works just fine

torch_nn

@malmaud
Copy link
Contributor

malmaud commented Mar 20, 2019

I'd be happy to manually add the stubs for some of these missing namespaces and submit those as a PR. Would that be acceptable, or are you looking for a more automatic codegen approach?

@t-vi
Copy link
Collaborator

t-vi commented Mar 20, 2019

Thank you for offering to work on these! I'm not sure whether there / what the are plans for a maintenance release, but a great first step would to fix these in master / the nightlies.

  • Things related to the automatically wrapped functions would best go in the generation
    https://github.com/pytorch/pytorch/blob/master/tools/pyi/gen_pyi.py
  • Things like imports and pure Python functions could go here: https://github.com/pytorch/pytorch/blob/master/torch/__init__.pyi.in

@imyhxy
Copy link

imyhxy commented Apr 1, 2019

I am using torch==1.0.1.post2 and Pycharm professional 2019.1. I tested and sorted out the situation mentioned by everyone in front.

can't find reference

  • torch.cat
  • torch.clamp
  • torch.exp
  • torch.FloatTensor deprecated
  • torch.from_numpy deprecated
  • torch.log
  • torch.LongTensor deprecated
  • torch.max
  • torch.min
  • torch.ones
  • torch.randn
  • torch.reshape
  • torch.sum
  • torch.zeros

not callable

  • torch.tensor
  • torch.as_tensor

@Dessix
Copy link

Dessix commented Apr 2, 2019

The message in 1b25fdb does not appear to have intended to close this issue.
"This would close #16996, although comments on that issue reference other missing stubs so maybe it's worth keeping open as an umbrella issue." @malmaud - should this be reopened?

@malmaud
Copy link
Contributor

malmaud commented Apr 2, 2019

Maybe better to just open a new issue with the things are still missing from the stubs. torch.cuda and torch.device, which is the title of this issue, have been added.

@malmaud
Copy link
Contributor

malmaud commented Apr 2, 2019

I went ahead and opened new issues for nn and util.data. The other missing methods mentioned in this issue are all fixed on master but aren't on a release yet.

@zhutmost
Copy link

zhutmost commented May 3, 2019

I have updated to the latest version (1.1.0). However, this bug is still not fixed.

@malmaud
Copy link
Contributor

malmaud commented May 9, 2019

What specifically do you mean by 'this bug'? Like, which methods? I did a fresh install of 1.1.0 and all the new type stubs have seemingly been installed correctly.

@lianghongzhuo
Copy link

can't find reference in 1.1.0, some examples:

torch.cuda.manual_seed()
torch.utils.data.dataloader.default_collate()

@bcrchzz
Copy link

bcrchzz commented May 10, 2019

What specifically do you mean by 'this bug'? Like, which methods? I did a fresh install of 1.1.0 and all the new type stubs have seemingly been installed correctly.

@malmaud

for example, torch.arange, torch.zeros, torch.cat
image

@lianghongzhuo
Copy link

@bcrchzz torch.arange, torch.zeros, torch.cat works fine in 1.1.0 with the PyCharm IDE.
Did you update your pytorch?

@lianghongzhuo
Copy link

What still cannot find the reference now is torch.data in the 1.1.0 version.

@bcrchzz
Copy link

bcrchzz commented May 10, 2019

@bcrchzz torch.arange, torch.zeros, torch.cat works fine in 1.1.0 with the PyCharm IDE.
Did you update your pytorch?

@lianghongzhuo Both my pytorch and pycharm are in the latest version.
image

@bcrchzz
Copy link

bcrchzz commented May 10, 2019

Besides, I find more functions, torch.sqrt/zeros_like/where, which cannot be referred correctly.

@malmaud
Copy link
Contributor

malmaud commented May 10, 2019

As @lianghongzhuo says, the type stubs for torch.arange etc have been successfully used in pycharm by others and me. If there still an issue for you, it must be on the PyCharm side - there's nothing more that can be done on the PyTorch side than shipping working type stubs.

@bcrchzz
Copy link

bcrchzz commented May 10, 2019

@malmaud Thank you a lot. I re-configured the python interpreter in the PyCharm Preference and reopened it. And the problem solved.
I use a remote python interpreter installed on a server. And I guess Pycharm may cache something locally, which makes it cannot refer the right version for lint.

Thanks again for your great jobs.

@DavidRuhe
Copy link

DavidRuhe commented May 10, 2019

@bcrchzz I also use a remote interpreter. How did you reconfigure the remote interpreter? I removed it and re-added it but still have the reference problems.

Also: did you install pytorch from root, conda or pip?

@Genius1237
Copy link

I get errors for torch.tensor,torch.float, torch.ones, torch.zeros and torch.zeros on 1.1.0 installed from pypi on VS Code.

@DavidRuhe
Copy link

DavidRuhe commented May 13, 2019

For me torch.log, torch.stack, torch.exp, torch.randn, torch.empty and torch.FloatTensor do not work yet on 1.1.0 installed from pypi.

@malmaud
Copy link
Contributor

malmaud commented May 13, 2019

I think there's no doubt that the stubs of the torch.* methods are being installed with 1.1.0. If your editor isn't making use of them, the issue must be with your editor and its interaction with your Python environment - there isn't anything more that can be on the PyTorch side.

@jakkes
Copy link

jakkes commented May 15, 2019

Using torch v1.1.0 and VSCode v1.33.1 (latest) with python 3.6.7, pretty much all torch.* methods do not show up (including all posted by the @imyhxy further up), nor is torch.tensor callable. It works fine in pycharm (apart from the callability of torch.tensor).

@Whisht
Copy link

Whisht commented May 28, 2019

I found that the stubs of torch.* works well in pycharm python console, but still cannot find reference in the editor. Even I reinstall pycharm as well as remote python interpreter. So confusing.

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

Successfully merging a pull request may close this issue.