Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 777
Ron Cohen Avatar asked Apr 21 '18 02:04

Ron Cohen


People also ask

Should I install PyTorch with Conda or PIP?

Package Manager To install the PyTorch binaries, you will need to use one of two supported package managers: Anaconda or pip. Anaconda is the recommended package manager as it will provide you all of the PyTorch dependencies in one, sandboxed install, including Python.


1 Answers

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

like image 139
RomualdM Avatar answered Oct 21 '22 14:10

RomualdM