Ubuntu16+Anaconda3+tensorflow(cpu),深度学习环境搭建

摘要:

  1. 引言
  2. Anaconda3安装
  3. tensorflow(cpu)安装
  4. spyder安装
    1.引言
    最近需要研究基于深度学习的语义分割,了解到语义分割有二维与三维的领域。还是先了解一下二维语义分割方面的,选定了deeplab和mobileNet。所以先搭建一下简单的深度学习环境,算是新手入门。
    WINDOWS10+ubuntu16.04双系统
    NVIDIA 940m显卡,2GB独立显存
    用下面命令查看电脑显卡,笔记本无法用台式机,所以以下都是cpu版本的配置
ubuntu-drivers devices

2.Anaconda安装
这个是用来管理 python库,看网上说这个是非必要安装,但不安装以后会麻烦。
ubuntu自带python版本为2.7.12,自己安装过python3.5.2.之前搜了很久没有搜到python3.5对应的anaconda,就安装了anaconda3-5.0.1(对应python3.6)代码如下:

wget https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh
bash Anaconda3-5.0.1-Linux-x86_64.sh #安装Anaconda

source ~/.bashrc  #刷新,立即生效

安装好这个之后才搜到python3.5对应的版本,懒得卸载重装了,放上安装方式:
python3.5对应anaconda3安装
(1)下载,官网下载较慢,推荐清华的镜像网站下载anaconda下载
python3.5建议下载Anaconda3 4.1.1或者4.2.0两个版本
如 anaconda3-4.2.0-linux-x86_64.sh。
(2)安装,打开终端,输入:

bash Anaconda3-4.1.1-Linux-x86_64.sh

中间要输入yes/no时输入yes,回车,选择默认安装地址home/用户名/anaconda3
(3)配置环境,终端输入sudo gedit ~/.bashrc,在末尾加上

export PATH="/home/用户名/anaconda3/bin:$PATH"
//用户名根据具体情况修改

然后更新,

source ~/.bashrc

更新后输入conda -v,若无报错则显示成功。
3.tensorflow(cpu)安装
网上有多种安装方式,源码安装,pip安装,我选择anaconda安装。
(1)跟换下载源,为了使下载或更新更快

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

(2)安装CPU版本的tensorflow

conda install -c https://conda.anaconda.org/jjhelmus tensorflow

安装完成后测试是否成功,在python中导入,不报错就算成功

(tensorflow) hy@hy-win:~$ python
import tensorflow as tf

在这里插入图片描述(3)安装完成后退出conda环境

(tensorflow) hy@hy-win:~$ source deactivate

4.spyder安装

hy@hy-win:~$ source activate tensorflow
(tensorflow) hy@hy-win:~$ conda install spyder

安装完成后在终端输入spyder就可出现界面,而且依赖于python3.5

------------------------------分割线-----------------------------------------------------------------------------
之后想要安装什么很简单,只要在tensorflow环境下,
conda install ***
比如我用的python3.5其默认的没有matplotlib这个库,那么只要安装
conda install matplotlib
ok!成功导入

猜你喜欢

转载自blog.csdn.net/qq_43265072/article/details/105051866
今日推荐