ubuntu16.04下安装tensorflow(二)

xiaoxiao2021-02-28  158

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

sudo apt-get install python-pip python-dev

3、安装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寻找自己需要的软件包

会出现如下的错误:

4、此处需要更新pip

sulei@sulei:~$ pip install --upgrade pip

5、继续执行上面的命令

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

结果: 安装成功:

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

7、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. ==============================================================================

根据路径找到这个文件,并打开 进行设置:

补充: 1、安装virtualenv

sulei@sulei:~$ sudo pip install virtualenv

2、安装numpy和matplotlib

sulei@sulei:~$ sudo pip install numpy sulei@sulei:~$ sudo pip install matplotlib

此处出现matplotlib的安装错误: 如果matplotlib 装不上需要先安装其依赖的包libpng和freetype 安装libpng:

sudo apt-get install libpng-dev

安装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

安装matplotlib

sudo pip install matplotlib

安装成功 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

进入源码目录并配置:

cd opencv-2.4.13.2/ mkdir release cd release cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

编译安装:

make sudo make install

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

import cv2

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

转载请注明原文地址: https://www.6miu.com/read-62678.html

最新回复(0)