I installed pytorch via
conda install pytorch-cpu torchvision-cpu -c pytorch
And I also tried
pip3 install https://download.pytorch
Welcome to SO,
please create a seperate conda environment
activate this environment conda activate myenv
and than install pytorch in it.
Besides you can check which python you are currently using by which python
Usually if the torch/tensorflow has been successfully installed, you still cannot import those libraries, the reason is that the python environment you try to import is not the python environment you installed.
For example, if you have installed the torch/tensorflow using python='/usr/bin/python'
, then you cannot import them to python='/home/usrname/.../bin/python'
.
The solution is simple thus, just change the python and import again.
Switch to python3
on the notebook
Try to install PyTorch using pip:
First create a Conda environment using:
conda create -n env_pytorch python=3.6
Activate the environment using:
conda activate env_pytorch
Now install PyTorch using pip:
pip install torchvision
Note: This will install both torch and torchvision.
Now go to Python shell and import using the command:
import torch
import torchvision
Once after creating conda environment, activate it.
And to install PyTorch,
conda install -c pytorch pytorch
If you are using windows and you have no CUDA, then go with the following command.
pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
You can visit its official site for more explanation. Pytorch Official site