如何解释“feature:/win-64::__cuda==11.1=0”等conda包规范?

Gqq*_*big 4 python installation anaconda conda

我运行 conda install 但它抛出以下错误:

UnsatisfiableError:发现以下规格与您的系统不兼容:

  • 功能:/win-64::__cuda==11.1=0

您安装的版本是:11.1

我不是问如何解决这个错误,而是问这个语句是什么意思?

我该如何阅读feature:/win-64::__cuda==11.1=0

什么是:/::__?什么是11.1=0

如果我安装的版本是 11.1,该软件包是否需要 cuda 版本 0?

Chr*_*ert 5

来自管理虚拟包的conda 文档:

管理虚拟包

“虚拟”包被注入到 conda 求解器中,以允许真实包依赖于系统上存在的无法由 conda 直接管理的功能,例如系统驱动程序版本或 CPU 功能。虚拟包不是真实的包,不会通过conda list. 相反,conda运行一小段代码来检测与包对应的系统功能是否存在。目前支持的虚拟包列表包括:

  • __cuda:显示驱动程序支持的 CUDA 最高版本。
  • __osx:OSX 版本(如果适用)。
  • __glibc:操作系统支持的glibc版本。

因此,feature指的是系统功能,在本例中指的是显示驱动程序的受支持版本。

根据conda 包规范__cuda==11.1意味着显示驱动程序必须与 cuda 版本 11.1、11.1.0、11.1.0.0 等之一完全匹配。

MatchSpecconda 包的查询语言

conda 源代码文件match_spec.py定义了该类MatchSpec。此类的文档字符串包括 conda 包的技术规范。

`MatchSpec` is, fundamentally, a query language for conda packages.  Any
of the fields that comprise a `PackageRecord` can be used to compose a 
`MatchSpec`.
 
`MatchSpec` can be composed with keyword arguments, where keys are any of 
the attributes of `PackageRecord`.  Values for keyword arguments are the 
exact values the attribute should match against.  Many fields can also be 
matched against non-exact values--by including wildcard `*` and `>`/`<` 
ranges--where supported.  Any non-specified field is the equivalent of a 
full wildcard match. 

`MatchSpec` can also be composed using a single positional argument, with 
optional keyword arguments.  Keyword arguments also override any 
conflicting information provided in the positional argument.  The 
positional argument can be either an existing `MatchSpec` instance or a 
string.  Conda has historically had several string representations for 
equivalent `MatchSpec`s.  This `MatchSpec` should accept any existing 
valid spec string, and correctly compose a `MatchSpec` instance.
    
A series of rules are now followed for creating the canonical string 
representation of a `MatchSpec` instance. The canonical string 
representation can generically be represented by 

    (channel(/subdir):(namespace):)name(version(build))[key1=value1,key2=value2]

where `()` indicate optional fields.  The rules for constructing a 
canonical string representation are:

    1. `name` (i.e. "package name") is required, but its value can be '*'.  
       Its position is always outside the key-value brackets.
    2. If `version` is an exact version, it goes outside the key-value 
       brackets and is prepended by `==`. If `version` is a "fuzzy" value 
       (e.g. `1.11.*`), it goes outside the key-value brackets with the 
       `.*` left off and is prepended by `=`.  Otherwise `version` is 
       included inside key-value brackets.
    3. If `version` is an exact version, and `build` is an exact value, 
       `build` goes outside key-value brackets prepended by a `=`.  
       Otherwise, `build` goes inside key-value brackets. `build_string` 
       is an alias for `build`.
    4. The `namespace` position is being held for a future conda feature.
    5. If `channel` is included and is an exact value, a `::` separator is 
       used between `channel` and `name`.  `channel` can either be a 
       canonical channel name or a channel url.  In the canonical string 
       representation, the canonical channel name will always be used.
    6. If `channel` is an exact value and `subdir` is an exact value, 
       `subdir` is appended to `channel` with a `/` separator.  Otherwise, 
       `subdir` is included in the key-value brackets.
    7. Key-value brackets can be delimited by comma, space, or 
       comma+space.  Value can optionally be wrapped in single or double 
       quotes, but must be wrapped if `value` contains a comma, space, or 
       equal sign.  The canonical format uses comma delimiters and single 
       quotes.
    8. When constructing a `MatchSpec` instance from a string, any 
       key-value pair given inside the key-value brackets overrides any 
       matching parameter given outside the brackets. 

When `MatchSpec` attribute values are simple strings, the are interpreted 
using the following conventions:
  - If the string begins with `^` and ends with `$`, it is converted 
    to a regex.
  - If the string contains an asterisk (`*`), it is transformed from a 
    glob to a regex.
  - Otherwise, an exact match to the string is sought.


Examples:
    >>> str(MatchSpec(name='foo', build='py2*', channel='conda-forge'))
    'conda-forge::foo[build=py2*]'
    >>> str(MatchSpec('foo 1.0 py27_0'))
    'foo==1.0=py27_0'
    >>> str(MatchSpec('foo=1.0=py27_0'))
    'foo==1.0=py27_0'
    >>> str(MatchSpec('conda-forge::foo[version=1.0.*]'))
    'conda-forge::foo=1.0'
    >>> str(MatchSpec('conda-forge/linux-64::foo>=1.0'))
    "conda-forge/linux-64::foo[version='>=1.0']"
    >>> str(MatchSpec('*/linux-64::foo>=1.0'))
    "foo[subdir=linux-64,version='>=1.0']"

To fully-specify a package with a full, exact spec, the fields
  - channel
  - subdir
  - name
  - version
  - build
must be given as exact values.  In the future, the namespace field will be 
added to this list.

Alternatively, an exact spec is given by 
'*[md5=12345678901234567890123456789012]'.
Run Code Online (Sandbox Code Playgroud)

回到原来的例子:

feature:/win-64::__cuda==11.1=0
Run Code Online (Sandbox Code Playgroud)

根据MatchSpec上面的定义:

  • feature- 虚拟包频道。
  • :/win-64- 虚拟包通道子目录,表明系统是64位版本的Windows操作系统。
  • ::- 由于channel包含该字段并且是精确值,因此在和::之间使用分隔符。channelname
  • __cuda- 虚拟包名称,在本例中指的是显示驱动程序规范。
  • ==- 精确的版本匹配约束。
  • 11.1- 精确version匹配,包括 11.1、11.1.0、11.1.0.0 等。
  • =0- 由于version是精确版本,并且build是精确值(在本例中为0),因此=会在前面添加一个符号。