Linux安装Anaconda、TensorFlow、Keras

1、安装anaconda

从清华镜像源下载需要的anaconda:
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
我下载的是红色框住的版本。
在这里插入图片描述
下载好之后通过xftp传到服务器上,并运行bash xxx.sh
在这里插入图片描述
安装过程中的截图如下,一路回车,输入y(yes)即可:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
注意最后一步询问是否安装vscode,一般输no,因为在服务器里面都是用vim编辑器的,没必要多装一个。在这里插入图片描述

# anaconda3(2),根据版本确定,Sweeneys为自己的用户名
export PATH="/home/Sweeneys/anaconda3/bin:$PATH" 

# 刷新环境变量
source ~/.bashrc

可以看到之后的python版本成功变为anaconda的版本
在这里插入图片描述
配置清华镜像源。

因为anaconda服务器在国外,安装package时候会很慢,甚至会经常出现连接不上服务器的情况,所以需将镜像源映射到国内清华镜像源(国内被授权的),命令如下:

# 添加Anaconda的TUNA镜像
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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes

# 若想恢复官方源,即使用如下命令
conda config --remove-key channels

2、安装TensorFlow

1、使用conda 创建一个新的环境:
在这里插入图片描述
激活该环境
在这里插入图片描述

采用pip安装相应版本的TensorFlow-gpu在这里插入图片描述
进入python查看安装是否成功以及版本是否正确
在这里插入图片描述

3、安装相应版本的keras

根据安装的TensorFlow安装相应版本的keras
在这里插入图片描述
如果使用conda激活环境出现如下错误:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If your shell is Bash or a Bourne variant, enable conda for the current user with
 
    $ echo ". /home/ubuntu/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
 
or, for all users, enable conda with
 
    $ sudo ln -s /home/ubuntu/anaconda3/etc/profile.d/conda.sh /etc/profile.d/conda.sh
 
The options above will permanently enable the 'conda' command, but they do NOT
put conda's base (root) environment on PATH.  To do so, run
    $ conda activate
in your terminal, or to put the base environment on PATH permanently, run
    $ echo "conda activate" >> ~/.bashrc
Previous to conda 4.4, the recommended way to activate conda was to modify PATH in
your ~/.bashrc file.  You should manually remove the line that looks like
    export PATH="/home/ubuntu/anaconda3/bin:$PATH"
^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^

这是由于conda的激活命令出了问题,解决方法如下:

# 激活环境
source activate
# 退出环境
source deactivate

随后解决问题,可以进行激活环境了:

conda activate your-env-name

查看python、tensorflow、keras对应的版本号网址如下:
https://tensorflow.google.cn/install/source
https://docs.floydhub.com/guides/environments/
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值