CentOS服务器搭建anaconda3+tensorflow环境

  之前用自己的电脑跑程序,效果不是很好,老师分配了服务器结点,所以就在服务器上配置了一遍。作为小白,对Linux命令行并不是很熟,踩了不少坑,现在配置好了,记录一下过程。

一、安装Anaconda3

直接从官网下载非常慢,甚至连接不上,所以找了清华的镜像https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/,我选择了anaconda3-4.2.0-Linux-x86_64.sh.

执行wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-4.2.0-Linux-x86_64.sh

下载完后会出现如下图的提示,告诉你保存到了哪里,如图的Saving to:‘Anaconda3-4.2.0-Linux-x86_64.sh.2'

随后安装,执行命令:bash Anaconda3-4.2.0-Linux-x86_64.sh.2

然后一路回车就行

由于我的环境中没有bzip2,所以第一次操作出现了问题,安装一个就行

接着就要激活环境,输入export PATH=/root/anaconda3/bin:$PATH就好了。

二、安装tensorflow

首先创建tensorflow的环境

输入命令:conda create -n tensorflow

然后source activate tensorflow进入tensorflow环境

然后通过pip命令安装tensorflow,仍然使用了清华镜像https://mirrors.tuna.tsinghua.edu.cn/help/tensorflow/

找到合适的版本,我这里是cpu,python3.5,linux系统

输入命令:pip install --ignore-installed --upgrade https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/tensorflow-1.7.0-cp35-cp35m-linux_x86_64.whl

自己会装好,然后测试一下

//输入python进入,然后输入一下代码
import tensorflow as tf
hello=tf.constant('hello')
sess=tf.Session()
print(sess.run(hello))

正常输出则证明环境搭建好了。

输入命令:source deactivate 退出tensorflow环境

猜你喜欢

转载自blog.csdn.net/gyx1549624673/article/details/83930769