1. 程式人生 > >centos下TensorFlow安裝

centos下TensorFlow安裝

1.首先安裝Python3(Linux系統自帶Python2,不要動它)

# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
# wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
# mkdir -p /usr/local/python3
# tar -zxvf Python-3.6.1.tgz
# cd Python-3.6.1
# ./configure --prefix=/usr/local/python3
# make
# make install
# ln -s /usr/local/python3/bin/python3 /usr/bin/python3

將/usr/local/python3/bin加入PATH

# vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH

按ESC,輸入:wq回車退出。

執行命令讓上一步的修改生效:

# source ~/.bash_profile

檢查Python3及pip3是否正常可用:

# python3 -V
Python 3.6.1
# pip3 -V
pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)

以上就是centos下Python3的正確安裝方式啦~

2、安裝TensorFlow

# sudo yum install python-pip python-dev
# pip3 install tensorflow

3、驗證

開啟Python3

輸入

import tensorflow

執行指令碼來檢查一下是否有正確安裝.