简体   繁体   English

为什么我不能使用 pip 安装 cudatookkit=10.1 但可以使用 conda?

[英]Why can't I install cudatookkit=10.1 using pip but can using conda?

$ pip install cudatoolkit==10.1
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement cudatoolkit==10.1 (from versions: none)
ERROR: No matching distribution found for cudatoolkit==10.1

This failed.这失败了。 However, the conda works:但是,康达有效:

$ conda install cudatoolkit=10.1
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /data0/congmin/miniconda

  added / updated specs:
    - cudatoolkit=10.1


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ca-certificates-2021.5.25  |       h06a4308_1         112 KB
    certifi-2021.5.30          |   py38h06a4308_0         138 KB
    conda-4.10.1               |   py38h06a4308_1         2.9 MB
    cudatoolkit-10.1.243       |       h6bb024c_0       347.4 MB
    openssl-1.1.1k             |       h27cfd23_0         2.5 MB
    ------------------------------------------------------------
                                           Total:       353.1 MB

I need to use pip to install, because I want to put it in requirements.txt.我需要使用pip来安装,因为我想把它放在requirements.txt中。

pip relies on https://pypi.org/ as the default package repository. pip 依赖于https://pypi.org/作为默认的 package 存储库。

Anaconda has it's own repository Anaconda 有自己的存储库

cudatoolkit is not a package in pypi. cudatoolkit不是 pypi 中的 package。 So pip cannot find any such package.所以 pip 找不到任何这样的 package。

It is available in the conda repository.它在 conda 存储库中可用。

The reason why cudatoolkit is not available in pypi is because it's not a python packge. cudatoolkit在 pypi 中不可用的原因是它不是 python 包。 It is a toolkit from nvidia that needs a C compiler to exist in your system.它是来自 nvidia 的工具包,需要 C 编译器才能存在于您的系统中。 Pip was never intended to handle such cases, whereas Anaconda is. Pip 从未打算处理这种情况,而 Anaconda 是。

See this blog post from Anaconda for details:有关详细信息,请参阅Anaconda 的此博客文章

This highlights a key difference between conda and pip.这突出了 conda 和 pip 之间的关键区别。 Pip installs Python packages whereas conda installs packages which may contain software written in any language. Pip 安装 Python 软件包,而 conda 安装可能包含以任何语言编写的软件的软件包。

As far as adding to requirements.txt is concerned.就添加到 requirements.txt 而言。 If you are using conda in your target system as well you could just export your conda environment to an environment.yml file and then clone the envrionment in your target machine.如果您也在目标系统中使用 conda,您可以将 conda 环境导出到 environment.yml 文件,然后在目标机器中克隆环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM