Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97420

Is there another step to importing Pytorch and using it?

$
0
0

I'm trying to test Pytorch but the first step is to get it running and usable on my computer. I have it to an extent but I need it to function in VS code which it does, it's just that it reads as an error despite working.

I've set up pytorch locally on my computer. I can run the test scripts fine in VS Code's integrated terminal.

Example 1

The issue comes up when I try to do some work normally in VS code.

from __future__ import print_function
import torch
x = torch.rand(5, 3) //This line has an error. torch.rand(5,3) is not callable)
print(x)

It says that module 'torch' has no 'rand' member. But it still outputs correctly. Running this in the terminal as a python file or in debug mode results in.

(base) c:\Users\Sean\Desktop\Test\hello>D:\Anaconda\python.exe c:\Users\Sean\.vscode\extensions\ms-python.python-2019.10.44104\pythonFiles\ptvsd_launcher.py --default --client --host localhost --port 63625 c:\Users\Sean\Desktop\Test\hello\something.py
tensor([[0.5449, 0.1669, 0.4740],
        [0.3079, 0.0447, 0.9543],
        [0.9137, 0.3987, 0.5736],
        [0.1788, 0.4932, 0.5584],
        [0.1632, 0.6285, 0.4483]])

(base) c:\Users\Sean\Desktop\Test\hello>D:/Anaconda/Scripts/activate

(base) c:\Users\Sean\Desktop\Test\hello>conda activate Anaconda
Could not find conda environment: Anaconda
You can list all discoverable environments with `conda info --envs`.

So it's working, what I want is to not have it coming up as an error. It'll be hard to find the actual bugs later on if it continues and I feel it might cause problems if not addressed. Any help with telling me the root issue and how to go about fixing it would be appreciated.


Viewing all articles
Browse latest Browse all 97420

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>