通过Conda安装PyTorch [英] Installing PyTorch via Conda
问题描述
目标:使用pytorch和torchvision创建一个conda环境. Anaconda Navigator 1.8.3,python 3.6,MacOS 10.13.4.
Objective: Create a conda environment with pytorch and torchvision. Anaconda Navigator 1.8.3, python 3.6, MacOS 10.13.4.
我尝试过的事情:
- 在Navigator中,创建了一个新环境.尝试安装pytorch和torchvision,但由于用户界面搜索软件包找不到与pytorch,torch,torchvision或类似字符串匹配的任何可用软件包,因此无法进行安装.
-
conda install pytorch torchvision -c pytorch
-
conda update --all
- 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和torchvision 0.2.0现在显示为在根环境中安装.但是,根环境不再是可克隆的.克隆按钮为灰色/禁用(以前是启用/可克隆).我可以将根环境用作后备环境,但是conda的主要目的是能够创建单独的且可处理的环境.我想念什么?
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 -----------------
运行conda install -c pytorch pytorch
会产生:
# All requested packages already installed.
但是,如果我激活了pytorch
环境并在其中列出了软件包,则没有包含单词"torch"的软件包.如果再执行conda search pytorch
,我将得到PackagesNotFoundError: The following packages are not available from current channels: - pytorch
.如果我激活base
环境然后执行conda list
,则pytorch在基本软件包列表中.那么如何创建一个包含pytorch的单独环境?
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?
推荐答案
您似乎已在基本环境中安装了PyTorch,因此无法在其他"pytorch"环境中使用它.
You seem to have installed PyTorch in your base environment, you therefore cannot use it from your other "pytorch" env.
要么:
-
使用PyTorch直接创建一个新环境(简称为
pytorch_env
):conda create -n pytorch_env -c pytorch pytorch torchvision
切换到已使用以下命令创建的pytorch环境:source activate pytorch_env
,然后在其中安装PyTorch:conda install -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
这篇关于通过Conda安装PyTorch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!