微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ubuntu14.04系统中安装tensorflowcpu版

一.tensorflow的环境
ubuntu16.04的环境、系统自带pythond的环境
1、进入窗口的模式:
输入Python的命令,发现已经存在python
2、输入以下命令安装pip

   
   
  • 1
  • 1
sudo apt-get install python-pip python-dev


3、安装pip

   
   
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3
sudo pip install --upgrade https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.0rc1-cp27-none-linux_x86_64.whl 此处的链接为:https://github.com/tensorflow/tensorflow寻找自己需要的软件包

会出现如下的错误

4、此处需要更新pip

   
   
  • 1
  • 2
  • 1
  • 2
sulei@sulei:~$ pip install --upgrade pip


5、继续执行上面的命令

   
   
  • 1
  • 2
  • 1
  • 2
sudo pip install --upgrade https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.0rc1-cp27-none-linux_x86_64.whl

结果:

安装成功:

6、测试
进入python

   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
>>> import tensorflow as tf >>> hello = tf.constant('Hello,TensorFlow!') >>> sess = tf.Session() 2017-06-07 22:31:06.638258: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions,but these are available on your machine and Could speed up cpu computations. 2017-06-07 22:31:06.638339: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions,but these are available on your machine and Could speed up cpu computations. 2017-06-07 22:31:06.638376: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions,but these are available on your machine and Could speed up cpu computations. >>> print sess.run(hello) Hello,TensorFlow! >>> a = tf.constant(10) >>> b = tf.constant(32) >>> print sess.run(a+b) 42

7、IDEA的安装
好用的IDE有很多,本文介绍的是Komodo IDE的免费版Komodo Edit。在Linux下打开它的官网(点击链接http://komodoide.com/download/edit-linux64/#
下载解压后,进入解压目录;
在终端的命令下进入目录并进行

   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
sulei@sulei:~/文档/Komodo$ ./install.sh nter directory in which to install Komodo. Leave blank and press 'Enter' to use the default [~/Komodo-Edit-10]. Install directory: ============================================================================== Komodo Edit 10 has been successfully installed to: /home/sulei/Komodo-Edit-10 You might want to add 'komodo' to your PATH by adding the install dir to you PATH. Bash users can add the following to their ~/.bashrc file: export PATH="/home/sulei/Komodo-Edit-10/bin:$PATH" Or you Could create a symbolic link to 'komodo',e.g.: ln -s "/home/sulei/Komodo-Edit-10/bin/komodo" /usr/local/bin/komodo Documentation is available in Komodo or on the web here: http://docs.activestate.com/komodo Please send us any Feedback you have through one of the channels below: komodo-Feedback@activestate.com irc://irc.mozilla.org/komodo https://github.com/Komodo/KomodoEdit/issues Thank you for using Komodo. ==============================================================================

根据路径找到这个文件,并打开

进行设置:

补充:
1、安装virtualenv

   
   
  • 1
  • 2
  • 1
  • 2
sulei@sulei:~$ sudo pip install virtualenv


2、安装numpy和matplotlib

   
   
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3
sulei@sulei:~$ sudo pip install numpy sulei@sulei:~$ sudo pip install matplotlib


此处出现matplotlib的安装错误

如果matplotlib 装不上需要先安装其依赖的包libpng和freetype
安装libpng:

   
   
  • 1
  • 1
sudo apt-get install libpng-dev


安装freetype:

   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
cd ~/Downloads wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.10.tar.gz tar zxvf freetype-2.4.10.tar.gz cd freetype-2.4.10/ ./congfigure make sudo make install



安装matplotlib

   
   
  • 1
  • 1
sudo pip install matplotlib


安装成功
3、安装OpenCV
下载opencv的发行版源码:

   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
https://github.com/opencv/opencv/releases/tag/2.4.13.2 tar -vxzf opencv-2.4.13.2.tar.gz 安装编译源码的依赖: sudo apt-get install build-essential sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev


进入源码目录并配置:

   
   
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4
cd opencv-2.4.13.2/ mkdir release cd release cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

编译安装:

   
   
  • 1
  • 2
  • 1
  • 2
make sudo make install

进入Python Console,在Python Console中输入:

   
   
  • 1
  • 1
import cv2

如果没有报错,则说明opencv安装好了


第一步:安装pip工具

sudo apt-get install python-pip

第二步:安装tensorflow-cpu

sudo pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

或:sudo pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl

第三步:打开sublime-text3 使用SFTP连接Ubuntu系统出现如下错误

The SSH host key has changed. This Could indicate a potential security breach,or that the domain you are connecting to recently moved servers.If you are confident this is not a security breach you can delete the old host key and try again.1. Win XP: Start > Run > regedit.exe Win Vista/7: Start > regedit2. Expand to HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys and delete the entry including @22:10.0.83.202

打开windows7下按步骤打开并删除相应记录

第四步:linux上测试tensor测试文件

test.py

import numpy
import tensorflow as tf
hello = tf.constant("hello,tensorflow")
sess = tf.session()
PRint sess.run(hello)
a = tf.constant(10)
b = tf.constant(20)
print sess.run(a+b)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐