linux-Anaconda+conda创建python-tensorflow虚拟环境
发布日期:2021-05-09 12:08:18 浏览次数:7 分类:技术文章

本文共 2285 字,大约阅读时间需要 7 分钟。

Anaconda 安装包可以到清华 下载可选择之前的版本。或者官网下载地址,最新版本。

()这里也有下载地址,可以使用命令下载,如下

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#按照需求自己选

不添加镜像,或者添加清华镜像好处是下载快(其实我感觉差不多速度)自行选择。清华镜像添加是执行下面几句

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 streamlinedcode editor with support for development operations like debugging, taskrunning and version control.To install Visual Studio Code, you will need:  - Administrator Privileges  - Internet connectivityVisual Studio Code License: https://code.visualstudio.com/licenseDo you wish to proceed with the installation of Microsoft VSCode? [yes|no]#让你安装VS,不安,输入no

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

# 创建一个名为S2P的环境,指定Python版本是2.7conda create --name S2P python=2.7#查看刚才创建的所有环境conda list env(指的是哪些包)conda info --envs(指的是创建环境的名称)# activate激活S2Psource activate S2P# 激活后,会发现terminal输入的地方多了S2P的字样,实际上,此时系统做的事情就是把默认环境从PATH中去除,再把当前2.7加入PATHpython --version# 可以看到系统已经切换到了2.7的环境# 如果想返回默认的python环境,运行source deactivate S2P# 删除刚才创建的环境S2Pconda remove --name S2P --all

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

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

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

naconda show cjj3779/tensorflow-gpuUsing Anaconda API: https://api.anaconda.orgName:    tensorflow-gpuSummary: TensorFlow helps the tensors flowAccess:  publicPackage Types:  condaVersions:   + 1.4.0To 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版本)[

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

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

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

https://pypi.org/
import tensorflow as tftf.__version__tf.__path__

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

可能出现的问题!command not found: conda

解决方案:export PATH=~/anaconda3/bin:$PATH

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

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

转载地址:https://blog.csdn.net/CSS360/article/details/90107875 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Linux软件安装、卸载指令
下一篇:Linux安装搜狗拼音和谷歌拼音输入法

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2023年09月18日 20时00分04秒