linux-Anaconda+conda创建python-tensorflow虚拟环境

Anaconda 安装包可以到清华 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下载可选择之前的版本。或者https://www.anaconda.com/download/#linux官网下载地址,最新版本。
(https://repo.continuum.io/archive/index.html)这里也有下载地址,可以使用命令下载,如下

 wget https://repo.continuum.io/archive/Anaconda3-5.3.0-Linux-x86_64.sh
##这是python3的,可以去上面的链接里,找到适合自己系统python版本的,比如
#wget https://repo.continuum.io/archive/Anaconda2-5.3.0-Linux-x86_64.sh
#按照需求自己选

不添加镜像,或者添加清华镜像https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/好处是下载快(其实我感觉差不多速度)自行选择。清华镜像添加是执行下面几句

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

然后执行

 bash Anaconda2-5.1.0-Linux-x86_64.sh

Anaconda is partnered with Microsoft! Microsoft VSCode is a streamlined
code editor with support for development operations like debugging, task
running and version control.
To install Visual Studio Code, you will need:
  - Administrator Privileges
  - Internet connectivity

Visual Studio Code License: https://code.visualstudio.com/license

Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]

#让你安装VS,不安,输入no

然后我们接下来创建虚拟环境

# 创建一个名为S2P的环境,指定Python版本是2.7
conda create --name S2P python=2.7

#查看刚才创建的所有环境
conda list env(指的是哪些包)
conda info --envs(指的是创建环境的名称)

# activate激活S2P
source activate S2P
# 激活后,会发现terminal输入的地方多了S2P的字样,实际上,此时系统做的事情就是把默认环境从PATH中去除,再把当前2.7加入PATH


python --version
# 可以看到系统已经切换到了2.7的环境

# 如果想返回默认的python环境,运行

source deactivate S2P


# 删除刚才创建的环境S2P
conda remove --name S2P --all

接下来在虚拟环境中安装tensorflow

 anaconda search -t conda tensorflow #查看版本和资源

然后决定你想要下载哪个版本

naconda show cjj3779/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.4.0

To install this package with conda run:
     conda install --channel https://conda.anaconda.org/cjj3779 tensorflow-gpu

根据提示,我们可以执行

 conda install --channel https://conda.anaconda.org/cjj3779 tensorflow-gpu

或者
(可以查看这个网站,下载比较受欢迎的tensorflow-gpu版本)[https://anaconda.org/search?q=tensorflow-gpu]

当然,还可以选择清华的镜像站,但是有时候会不稳定,不显示你想要版本的.whl文件

https://mirrors.tuna.tsinghua.edu.cn/help/tensorflow/
#这里有各种资源,可以直接下在后缀名为.whl的tensorflow版本

那么还有更好的方法,请移步与pypi,搜索tensorflow-gpu,找到你想要的版本

https://pypi.org/
import tensorflow as tf
tf.__version__
tf.__path__

执行上面两句话验证tensorflow,出现版本号就可以了

可能出现的问题!command not found: conda
解决方案:export PATH=~/anaconda3/bin:$PATH

了解更多关于《计算机视觉与图形学》相关知识,请关注公众号:

下载我们视频中代码和相关讲义,请在公众号回复:计算机视觉课程资料

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值