通过 Conda 安装 PyTorch [英] Installing PyTorch via Conda

查看:33
本文介绍了通过 Conda 安装 PyTorch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:使用 pytorch 和 torchvision 创建 conda 环境.Anaconda 导航器 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,但无法安装,因为 UI 搜索包没有找到任何与 pytorch、torch、torchvision 或类似字符串匹配的可用包.
  • conda install pytorch torchvision -c pytorch
  • conda update --all

pytorch 0.3.1、torch 0.3.1 和 torchvision 0.2.0 现在显示为已安装在根环境中.但是,root 环境不再是可克隆的;克隆按钮是灰色/禁用的(它曾经被启用/可克隆).我可以使用根环境作为后备,但 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 产生:# 所有请求的包已经安装. 但是如果我激活 pytorch 环境并列出其中的包,则没有包含torch"一词的包.如果我然后执行 conda search pytorch 我得到 PackagesNotFoundError: The following packages are not available from current channels: - pytorch.如果我激活 base 环境然后执行 conda list 那么 pytorch 就在 base 的包列表中.那么如何创建一个单独的包含 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆