一.tensorflow的环境 ubuntu16.04的环境、系统自带pythond的环境 1、进入窗口的模式: 输入Python的命令,发现已经存在python。 2、输入以下命令安装pip
sudo apt-get install python-pip python-dev 1 13、安装pip
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寻找自己需要的软件包 123 123会出现如下的错误:
4、此处需要更新pip
sulei@sulei:~$ pip install --upgrade pip 12 125、继续执行上面的命令
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 12 12结果: 安装成功:
6、测试 进入python
>>> 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 123456789101112 1234567891011127、IDEA的安装 好用的IDE有很多,本文介绍的是Komodo IDE的免费版Komodo Edit。在Linux下打开它的官网(点击链接http://komodoide.com/download/edit-linux64/#) 下载解压后,进入解压目录; 在终端的命令下进入目录并进行
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. ============================================================================== 12345678910111213141516171819202122232425262728293031 12345678910111213141516171819202122232425262728293031根据路径找到这个文件,并打开 进行设置:
补充: 1、安装virtualenv
sulei@sulei:~$ sudo pip install virtualenv 12 122、安装numpy和matplotlib
sulei@sulei:~$ sudo pip install numpy sulei@sulei:~$ sudo pip install matplotlib 123 123此处出现matplotlib的安装错误: 如果matplotlib 装不上需要先安装其依赖的包libpng和freetype 安装libpng:
sudo apt-get install libpng-dev 1 1安装freetype:
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 1234567 1234567安装matplotlib
sudo pip install matplotlib 1 1安装成功 3、安装OpenCV 下载opencv的发行版源码:
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 1234567 1234567进入源码目录并配置:
cd opencv-2.4.13.2/ mkdir release cd release cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. 1234 1234编译安装:
make sudo make install 12 12进入Python Console,在Python Console中输入:
import cv2 1 1如果没有报错,则说明opencv安装好了
sudo apt-get install python-pip
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
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 > regedit 2. Expand to HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys and delete the entry including @22:10.0.83.202
打开windows7下按步骤打开并删除相应记录
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)