Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install pytorch in Anaconda with conda or pip?

I am trying to install pytorch in Anaconda to work with Python 3.5 in Windows. Following the instructions in pytorch.org I introduced the following code in Anaconda:

pip3 install torch torchvision  

But the following error came in:

Command "python setup.py egg_info" failed with error code 1 in C:\Users\sluis\AppData\Local\Temp\pip-install-qmrvz7b9\torch\ 

By searching on the web I found out that it may be because of setuptools being out of date but I checked and have it updated. I also tried:

conda install -c peterjc123 pytorch cuda80 

But the following error arise:

The following specifications were found to be in conflict:   - pytorch Use "conda info <package>" to see the dependencies for each package. 

I also tried to load the pytorch's tar.bz2 file which I download in the following website:

anaconda.org/peterjc123/pytorch/files

And then just do:

$ conda install filename.tar.bz2  

But I got the following error:

Error: HTTPError: 404 Client Error: None for url: file:///C|/Users/sluis/pytorch-0.3.1-py36_cuda80_cudnn6he774522_2.tar.bz2: file:///C|/Users/sluis/pytorch-0.3.1-py36_cuda80_cudnn6he774522_2.tar.bz2 

I am quite new to this programming world so I don't really know how to dig more on the errors. Anyone knows how to get pytorch installed?

Edit: As suggested in the comments I tried:

conda install pytorch torchivsion -c pytorch 

And I got the following error:

Error: Packages missing in current win-64 channels:  - pytorch  - torchvision 

I did:

anaconda search -t conda torchvision 

And tried to install dericlk/torchvision using the following command:

conda install -c derickl torchvision 

But I am getting the same error:

Error: Package missing in current win-64 channels:   - torchvision 

I couldn't find any torchvisionpackages for win-64.

conda list is giving me the following:

# packages in environment at C:\Users\aaaa\AppData\Local\Continuum\Anaconda3\envs\torchenv2: # mkl-include               2018.0.2                      1    anaconda certifi                   2016.2.28                py35_0 cffi                      1.10.0                   py35_0 cmake                     3.6.3                    vc14_0  [vc14] openmp                    2018.0.0                intel_8    intel mkl                       2017.0.3                      0 numpy                     1.13.1                   py35_0 pip                       10.0.0                    <pip> pip                       9.0.1                    py35_1 pycparser                 2.18                     py35_0 python                    3.5.4                         0 pyyaml                    3.12                     py35_0 setuptools                36.4.0                   py35_1 typing                    3.6.2                    py35_0 vc                        14                            0 vs2015_runtime            14.0.25420                    0 wheel                     0.29.0                   py35_0 wincertstore              0.2                      py35_0 zlib                      1.2.11                   vc14_0  [vc14] 

=======

like image 896
Marisa Avatar asked Apr 19 '18 10:04

Marisa


People also ask

How do I know if PyTorch is installed on Anaconda?

If you used Anaconda or Miniconda to install PyTorch, you can use conda list -f pytorch to check PyTorch package's information, which also includes its version. If you want to check PyTorch version for a specific environment such as pytorch14 , use conda list -n pytorch14 -f pytorch .

How do I install PyTorch from terminal?

To install PyTorch, you have to run the installation command of PyTorch on your command prompt. This command is available on https://pytorch.org/. Select language and cuda version as per your requirement. Now, run python -version, and Conda -version command to check Conda and python packages are installed or not.


2 Answers

The following worked for me. First install MKL:

conda install -c anaconda mkl 

After this, install pytorch and torchvision:

conda install -c pytorch pytorch torchvision 
like image 182
archit522 Avatar answered Oct 07 '22 02:10

archit522


Go to the official PyTorch.org and follow the steps accordingly. enter image description here

Select your preferences and you will see an appropriate command below on the page.

If you don't have GPU in the system, set CUDA as None or CPU

Example command:

conda install pytorch-cpu torchvision-cpu -c pytorch 
like image 42
shiva krishna Avatar answered Oct 07 '22 02:10

shiva krishna