To install PyTorch on Ubuntu, as instructed by the official website, I did pip3 install torch torchvision, and I am able to run PyTorch using the python3.5 command.
However, when I run Jupyter Notebook (I'm just running Jupyter Notebook in the terminal and using Chrome to access my notebooks), it doesn't recognize the package, throwing ModuleNotFoundError: No module named 'torch' at me.
The other odd thing is that PyTorch seems to have only been installed on Python 3.5 and not on Python 3.6 because:
➜ ~ python3.5 -c "import torch; print(torch.__version__)"
0.4.1
➜ ~ python3.6 -c "import torch; print(torch.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'
➜ ~
Therefore I'm guessing that Jupyter Notebook is not using Python 3.5.
This is the result when I type python in my terminal and press TAB:
➜ ~ python
python python2.7 python3.5 python3.5m python3.6 python3.6m python3-config python3m-config
python2 python3 python3.5-config python3.5m-config python3.6-config python3.6m-config python3m
Also, when I run which python, I get /home/mhy/anaconda3/bin/python since I installed Anaconda recently. I then activated my env and installed PyTorch using the following commands:
source activate my_env
conda install torch torchvision
But I wasnt able to run PyTorch on Anaconda either.