Pytorch install with anaconda error - anaconda

I get this error:
C:\Users>conda install pytorch torchvision -c soumith
Fetching package metadata .............
PackageNotFoundError: Package missing in current win-64 channels:
- pytorch
I got conda install pytorch torchvision -c soumith from Pytorch official website and I have OSX/conda/3.6/none for settings on Pytorch site(should be correct). I am new to conda, any tips how to solve this?

Update: From PyTorch 0.4, there is an official Anaconda channel with packages for Windows as well.
You can install the latest pre-built (binary) version of PyTorch (GPU version by default) on windows using:
conda install -c pytorch pytorch
For CPU only version:
conda install -c pytorch pytorch-cpu
For specific version of CUDA say CUDA9.1:
conda install -c pytorch pytorch cuda91
Official instructions for windows are now available here
Old answer for previous versions (<0.4) of PyTorch on Windows:
It looks like you are on windows (win 64) and you are trying to install pytorch by choosing OSX because you don't have an option listed for win64 on pytorch site. (Correct me if that is not the case, I will revise my answer). -c soumith will use soumith's channel which only has packages for Linux and OSX not for windows. That is why you got that error when you ran conda from a windows machine.
You can install pytorch on windows through conda using this command:
conda install -c peterjc123 pytorch
This will fetch the pytorch package using peterjc123's channel which has packages for Win64.
You can install the torchvision package using pip like this:
pip install torchvision

On June,2019, The command generated at pytorch will require dependencies before it can be executed successfully. For example I chose stable pytorch 1.1 build with python 3.6 and Cuda 10.0. The command generated by pytorch page was as follows:
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
But it will not work if you have created a new conda environment like me. The step by step process for setting up pytorch is as follows:
First install the cudatoolkit as follows:
conda install -c anaconda cudatoolkit=10.0
Then install the mkl_fft as follows:
conda install -c anaconda mkl_fft
Assuming you will face no more dependency issues. Use the following command to setup pytorch:
conda install -c pytorch pytorch
This worked for me. But I had setup my new conda environment with scikit-learn and jupyter notebook before starting the pytorch setup. So if any dependency problem arise, it would be a good idea to install both scikit-learn and jupyter notebook as well.

Use the following commands to install pytorch on windows
for Windows 10 and Windows Server 2016, CUDA 8
conda install -c peterjc123 pytorch cuda80
for Windows 10 and Windows Server 2016, CUDA 9
conda install -c peterjc123 pytorch cuda90
for Windows 7/8/8.1 and Windows Server 2008/2012, CUDA 8
conda install -c peterjc123 pytorch_legacy cuda80

I have face similar problem because I have installed pytorch cpu only version. I tried everything and update pytorch to gpu version but nothing helped.
Simple solution is to create new environment and then install pytorch gpu version. It resolve my problem

Related

PyTorch dll issues for Caffe2

I am using a Windows 10 Machine and after re-installing Anaconda and all of the packages I had previously, including torchvision, torch and necessary dependencies, I am still getting this error:
OSError: [WinError 127] The specified procedure could not be found. Error loading "C:\Users\XXX\Anaconda3\envs\XXX\lib\site-packages\torch\lib\caffe2.dll" or one of its dependencies.
I am using python 3.7.9 and:
torchaudio=0.6.0=py37
torchvision=0.7.0=py37_cpu
tornado=6.0.4=py37he774522_1
traitlets=5.0.5=py_0
I've looked into it quite a bit but feel like this should be an easy solve...
I do not have CUDA and have used this:
conda install pytorch torchvision torchaudio cpuonly -c pytorch
as per instructed on the official website of pytorch
After a long time trying many things with Anaconda I decided to use bare python instead and I installed Python 3.8.6 and installed PyTorch from the link you provided and it finally worked even with CUDA support. Make sure to completely remove all Anaconda/Other Python version scripts from your path to ensure only the 3.8.6 version is used by your prompt.
I had the same problem, so I uninstalled the pytorch in my machine using
"conda uninstall pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch"
Then did a clean installation using the following
"pip install torch===1.7.0 torchvision===0.8.1 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html"
I did not use conda for installation as it was persistently giving me the cpu version of pytorch.
I tried to install PyTorch with Anaconda and had the same error.
For me what solved the issue was to uninstall Pytorch using Pip (even though I installed it with conda) and then installing again with Pip as explains at PyTorch guide.
Uninstall:
pip uninstall torch
pip uninstall torchvision
pip uninstall torchaudio
Install:
pip3 install torch torchvision torchaudio

how to install fastai on windows 10

I cant seem to install the right version of torch and I cant get fast ai libraries working
I try
Python 3.7
pip3 install https://download.pytorch.org/whl/cu100/torch-1.0.1-cp37-cp37m-win_amd64.whl
pip3 install torchvision
Could not find a version that satisfies the requirement torch>=1.1.0 (from torchvision) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
No matching distribution found for torch>=1.1.0 (from torchvision)
I feel like I may of downgraded my gpu when I tried conda install fast ai
and then I tried pip and it couldnt find a file C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\caffe2\python\serialized_test\data\operator_test
I finally got to the point where it said successfully installed six, pillow, and torch but torch is at 0.3 which is incompatiable.
pip3 install https://download.pytorch.org/whl/cu100/torch-1.0.1-cp37-cp37m-win_amd64.whl
pip3 install torchvision
expected to install pytorch or fastai nothing seems to work
You may try installing the course by creating a conda environment provided anaconda is already installed in your windows machine.
conda update conda
conda create -n fastai_conda python=3.6
conda activate fastai_conda
conda install fastai pytorch=1.0.0 -c fastai -c pytorch -c conda-forge
Or for installing CPU version you can use the below commands after the environment is created
conda install -c pytorch pytorch-cpu torchvision
conda install -c fastai fastai
You can check if installation went right with this command
python -m fastai.utils.show_install
You may further need to install ipykernel to use the conda environment in your jupyter notebook.For that activate environment and run the following commands:
conda install nb_conda_kernels
python -m ipykernel install --user --name fastai_v1 --display-name "fastai v1"
conda install ipywidgets

Installing PyTorch via Conda

Objective: Create a conda environment with pytorch and torchvision. Anaconda Navigator 1.8.3, python 3.6, MacOS 10.13.4.
What I've tried:
In Navigator, created a new environment. Tried to install pytorch and torchvision but could not because the UI search for packages does not find any packages available matching pytorch, torch, torchvision, or similar strings.
conda install pytorch torchvision -c pytorch
conda update --all
pytorch 0.3.1, torch 0.3.1, and torchvision 0.2.0 now appear as installed in the root environment. However, the root environment is no longer cloneable; the clone button is gray/disabled (it used be enabled/cloneable). I could use the root environment as a fallback but the main point of conda is to be able to create separate and disposable environments. What am I missing?
UPDATE -----------------
Running conda install -c pytorch pytorch yields:
# All requested packages already installed. But if I activate the pytorch environment and list the packages therein, there is no package containing the word "torch". If I then do conda search pytorch I get PackagesNotFoundError: The following packages are not available from current channels: - pytorch. If I activate the base environment and then do conda list then pytorch is in the package list for base. So how does one create a separate environment containing pytorch?
You seem to have installed PyTorch in your base environment, you therefore cannot use it from your other "pytorch" env.
Either:
directly create a new environment (let's call it pytorch_env) with PyTorch: conda create -n pytorch_env -c pytorch pytorch torchvision
switch to the pytorch environment you have already created with: source activate pytorch_env and then install PyTorch in it: conda install -c pytorch pytorch torchvision
I struggled with this and was reminded to RTFM (Read The F'ing Manual) documentation...
See Verify the installation with import torch not pytorch. which is from Pytorch

Installing tensorflow on anaconda/mac?

I can not find a solution to install tensorflow on anaconda/mac.
When i try: conda install tensorflow,
I get:
UnsatisfiableError: The following specifications were found to be in conflict:
- blaze -> numba -> numpy=1.13
- tensorflow
Use "conda info " to see the dependencies for each package.
I tried reinstalling numpy, and could not find any relevant documentation.
On mac use following command:
conda install -c conda-forge tensorflow
This will install the latest Tensorflow on your system. if you wish to upgrade it to newer version then you can use the following command
conda update -f -c conda-forge tensorflow
I have had success installing tensorflow through pip...
pip install tensorflow
or, if you have all of the proper libraries...
pip install tensorflow-gpu
But if you have already removed numpy form the anaconda install, you might be in for a long day because almost all of the numeric packages require it. If the above pip install doesn't work, you might want to start from a clean anaconda install.
I have installed tensorflow using -
pip install tensorflow
Or, you can use Anaconda in following way -
Open Anaconda Navigator
On Left side go to Environments
Create a new environment (eg :- tensorflow_tf), select python 3.7
then select Not installed and Search "tensorflow"
click on tensorflow and apply

Pip list shows only one version of `torch`, yet conda list shows two

pip list
conda list
I once install torch 0.1.12, then I remove it, and reinstall it.
How can I remove the 0.1.12 version?
If you install torch 0.1.12 with
conda install pytorch torchvision cuda80 -c soumith,
then just try
conda uninstall pytorch torchvision cuda80 -c soumith.
I tested on my mac and it successfully removed pytorch and all its dependencies, also pytorch 0.1.12 never shows in conda list later.
P.S.: a virtual environment is highly recommended with anaconda.

Resources