Can't import pytorch
I am trying to import pytorch but I get an error that module does not exist. I installed via anaconda, and the folder "pytorch-0.1.12-py35_2cu80" exist in anaconda3/pkgs folder. why does it not recognize that it is there? should I rename this folder?
-Rik
/home/rik/anaconda3/bin/python /home/rik/PycharmProjects/self_driving_car/self_driving.py
Traceback (most recent call last):
File "/home/rik/PycharmProjects/self_driving_car/self_driving.py", line 18, in <module>
import pytorch
ImportError: No module named 'pytorch'
Process finished with exit code 1
Solution 1:
The command to import pytorch is
import torch
not
import pytorch
Solution 2:
It seems the module pytorch
is not installed.
First make sure your using anaconda's python
and not the system one.
To install pytorch
via conda
do
conda install pytorch torchvision -c soumith
or via pip
For python3
pip install http://download.pytorch.org/whl/cu75/torch-0.1.12.post2-cp35-cp35m-linux_x86_64.whl
pip install torchvision
For python2
pip install http://download.pytorch.org/whl/cu75/torch-0.1.12.post2-cp27-none-linux_x86_64.whl
pip install torchvision
dont install the CUDA version if you dont have Nvidia GPU on your machine that supports.