了解 `conda install`(频道和包)

Understanding `conda install` (channel and packages)

我正在尝试安装 fastai,但我不明白他们要用 conda install 做什么。

fastaiman page说:

conda install -c fastai -c pytorch -c anaconda fastai gh anaconda

这是否意味着: 要使用的频道是 fastaipytorchanaconda 而要安装的包是 [ =13=、ghanaconda 分别是?我认为他们基本上想要安装 pytorchfastai。但他们甚至没有提到 pytorch 包。

conda install好像是这样写的:

conda install -c <package-name>

是的,差不多就是这些了。我会翻译命令

conda install -c fastai -c pytorch -c anaconda fastai gh anaconda

作为祈使句

While prioritizing the Anaconda Cloud channels fastai, pytorch, and anaconda, in that order, ensure that the current environment has some version of each of the packages fastai, gh, and anaconda installed.

Channels 告诉 Conda 去哪里搜索包,并且顺序优先(first > last)。由于未提供 URL,仅提供频道名称(例如 pytorch),Conda 将假定这些频道托管在 Anaconda Cloud 上(例如 PyTorch channel)。不能作为选项(例如 -c)或选项参数(pytorch)解析的所有内容都被解释为要安装的包(例如,gh)。

PyTorch

至于pytorch没有被提及,它被列为fastai包的依赖:

$ conda search --info -c fastai fastai=2.0.13
Loading channels: done
fastai 2.0.13 py_0
------------------
file name   : fastai-2.0.13-py_0.tar.bz2
name        : fastai
version     : 2.0.13
build       : py_0
build number: 0
size        : 141 KB
license     : Apache Software
subdir      : noarch
url         : https://conda.anaconda.org/fastai/noarch/fastai-2.0.13-py_0.tar.bz2
md5         : bca97ff1932c61aeed960d9cd8dea9fc
timestamp   : 2020-09-17 04:24:42 UTC
dependencies: 
  - fastcore >=1.0.5
  - fastprogress >=0.2.4
  - matplotlib
  - packaging
  - pandas
  - pillow
  - pip
  - python
  - pytorch >=1.6.0
  - pyyaml
  - requests
  - scikit-learn
  - scipy
  - spacy
  - torchvision >=0.7

因此不需要在安装命令中明确指定。

最小环境

我会注意到,除非您需要环境中的完整 Anaconda 发行版,否则我会鼓励使用更精简的安装并将其保存在专用环境中,例如,

conda create --name my_fastai_env -c fastai -c pytorch -c anaconda fastai

仍将提供 fastai 中的所有内容,而没有 anaconda 元包中默认提供的所有额外包。