一. 背景
今天尝试在conda创建的虚拟环境里安装tensorflow,使用如下代码进行安装
pip install tensorflow
但是会报错,如下:
$ pip install tensorflow
Downloading/unpacking tensorflow
Could not find any downloads that satisfy the requirement tensorflow
Cleaning up...
No distributions at all found for tensorflow
二. 解决方案
后来找了很多资料,发现可以直接用Anconda直接安装,并且实现并不需要预先知道tensorflow的路径。
1. 加载虚拟环境
source activate venv
2. 使用conda查询可安装包
(venv)$ anaconda search -t conda tensorflow-gpu
Using Anaconda API: https://api.anaconda.org
Packages:
Name | Version | Package Types | Platforms |
------------------------- | ------ | --------------- | --------------- |
HCC/tensorflow-gpu | 1.7.0 | conda | linux-64 |
aaronzs/tensorflow-gpu | 1.10.0 | conda | linux-64, win-64 |
acaprez/tensorflow-gpu | 1.5.0 | conda | linux-64 |
.
.
.
.(这里其实还有很多,就不贴出来了)
machine learning.
variant.
Found 23 packages
Run 'anaconda show <USER/PACKAGE>' to get installation details
3. 使用anaconda查看安装路径
anaconda show aaronzs/tensorflow-gpu
Using Anaconda API: https://api.anaconda.org
Name: tensorflow-gpu
Summary: TensorFlow helps the tensors flow
Access: public
Package Types: conda
Versions:
+ 1.3.0
+ 1.4.0rc1
+ 1.4.0
+ 1.5.0
+ 1.6.0
+ 1.7.0
+ 1.8.0
+ 1.7.1
+ 1.9.0
+ 1.10.0
To install this package with conda run:
conda install --channel https://conda.anaconda.org/aaronzs tensorflow-gpu
4. 进行安装
conda install --channel https://conda.anaconda.org/aaronzs tensorflow-gpu=1.10.0