在Ubuntu 18.04上安装Tensorflow(CPU)

更新时间:2019-10-21 11:42:46
5666077-8931e1c3c7a746aa.jpg

前言

最近想要学习tensorflow框架,我的系统为Ubuntu18.0.4,所以就需要在电脑上安装tensorflow,所以这里就把我的安装过程给记录下来。


安装过程

首先输入查看自己的Python版本,可以使用Python%Python3(p小写)命令进入Python,就可以看到自己是否有安装Python3了,不过这个版本的Ubuntu应该预装了Python3,所以直接看下一步就好了。


第一步,更换国内源,俗话说:磨刀不误砍柴工,我们首先把源换成阿里的,这也可以在下载tensorflow的时候更快一点。
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup   # 备份源        sudo gedit /etc/apt/sources.list  # 编辑,如果没有gedit可以使用apt安装一下

清空之前的内容,输入以下内容:

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

保存退出

更新apt:

    sudo apt-get update
二、安装Tensorflow(Python3.6.7/CPU)
sudo apt-get install python3-pip python3-dev
sudo pip3 install tensorflow


安装就是这么简单!

Ubuntu

推荐小说