最近在學習google新開源的深度學習框架tensorflow。發現安裝它的時候,須要依賴python2.7.X;我以前一直使用的linux是centos。而centos不更新了,裏面的自帶的python通常都是python2.6如下的。不只如此,系統裏面不少組件又依賴python2.6,因此致使你都不能替換掉它。無奈之下,選擇ubuntu了。下面介紹一下使用ubuntu安裝tensorflow遇到的一些問題。python
一、ubuntu沒法用Winscp鏈接linux
解決辦法:ubuntu
(1)、採用橋接的方式進行上網(因爲是用虛擬機安裝的操做系統)centos
(2)、利用ps -e |grep ssh 查看是否有sshd進程開啓。若是沒有則須要安裝openssh-serverapi
安裝的方式:sudo apt-get install openssh-serverbash
啓動相應的進程:/etc/init.d/ssh start框架
(3)、此時須要reboot系統python2.7
(4)、因爲ubuntu最初root的用戶是沒有被激活的,因此須要經過修改root用戶密碼來激活root用戶。ssh
完成便可鏈接了。學習
二、安裝tensorflow。
因爲個人ubuntu是最新版的(ubuntu-16.04-desktop-amd64),裏面自帶的python是2.7.11。所以知足要求。因爲tensorflow有三種安裝方式,這裏採用的是pip安裝方式。下面開始安裝tensorflow:
(1)首先安裝pip
sudo apt-get install python-pip python-dev
(2)利用pip安裝tensorflow
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl
安裝好了後,以下圖所示:
根據上面黃色的提示,叫我升級pip:因而我就按照他的要求升級了,執行:pip install --upgrade pip
三、檢驗tensorflow是否安裝成功
經過下面一段代碼來測試tensorflow是否安裝成功:
$ python ... >>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() >>> print(sess.run(hello)) Hello, TensorFlow! >>> a = tf.constant(10) >>> b = tf.constant(32) >>> print(sess.run(a + b)) 42 >>>
下面是我執行的結果以下圖所示:
四、安裝python-numpy ,python-scipy,python-matplotlib
sudo apt-get install python-numpy
sudo apt-get install python-scipy
sudo apt-get install python-matplotlib
驗證是否安裝成功:(以下圖所示)