Tensorflow安装手册

Tensorflow安装手册

tony:~ xdwang$ sudo easy_install pip
Password:
Searching for pip
Best match: pip 8.0.2
Adding pip 8.0.2 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Using /usr/local/lib/python2.7/site-packages
Processing dependencies for pip
Finished processing dependencies for pip

tony:~ xdwang$ sudo pip install --upgrade virtualenv
The directory '/Users/xdwang/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/xdwang/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting virtualenv
Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
100% |████████████████████████████████| 1.8MB 73kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
tony:~ xdwang$ sudo pip install --upgrade pip
The directory '/Users/xdwang/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/xdwang/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 94kB/s
Installing collected packages: pip
Found existing installation: pip 8.0.2
Uninstalling pip-8.0.2:
Successfully uninstalled pip-8.0.2
Successfully installed pip-9.0.1

tony:~ xdwang$ virtualenv --system-site-packages -p python3 /var/app/software/tensorflow/
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6'
New python executable in /var/app/software/tensorflow/bin/python3.6
Also creating executable in /var/app/software/tensorflow/bin/python
Installing setuptools, pip, wheel…done.

tony:~ xdwang$ source /var/app/software/tensorflow/bin/activate
(tensorflow) tony:~ xdwang$ easy_install -U pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
Downloading https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
Best match: pip 9.0.1
Processing pip-9.0.1.tar.gz
Writing /var/folders/0z/lfhw5hfn36zggb7cj6lkz43m0000gn/T/easy_install-rz0op5_h/pip-9.0.1/setup.cfg
Running pip-9.0.1/setup.py -q bdist_egg --dist-dir /var/folders/0z/lfhw5hfn36zggb7cj6lkz43m0000gn/T/easy_install-rz0op5_h/pip-9.0.1/egg-dist-tmp-lxopbz_5
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.landscape.yml'
warning: no previously-included files found matching 'pip/_vendor/Makefile'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'dev-requirements.txt'
warning: no previously-included files found matching 'appveyor.yml'
no previously-included directories found matching '.github'
no previously-included directories found matching '.travis'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'contrib'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
creating /private/var/app/software/tensorflow/lib/python3.6/site-packages/pip-9.0.1-py3.6.egg
Extracting pip-9.0.1-py3.6.egg to /private/var/app/software/tensorflow/lib/python3.6/site-packages
Adding pip 9.0.1 to easy-install.pth file
Installing pip script to /var/app/software/tensorflow/bin
Installing pip3 script to /var/app/software/tensorflow/bin
Installing pip3.6 script to /var/app/software/tensorflow/bin

Installed /private/var/app/software/tensorflow/lib/python3.6/site-packages/pip-9.0.1-py3.6.egg
Processing dependencies for pip
Finished processing dependencies for pip

(tensorflow) tony:~ xdwang$ pip3 install --upgrade tensorflow
Collecting tensorflow
Downloading tensorflow-1.3.0-cp36-cp36m-macosx_10_11_x86_64.whl (39.8MB)
100% |████████████████████████████████| 39.8MB 30kB/s
Requirement already up-to-date: wheel>=0.26 in /private/var/app/software/tensorflow/lib/python3.6/site-packages (from tensorflow)
Collecting protobuf>=3.3.0 (from tensorflow)
Downloading protobuf-3.4.0-py2.py3-none-any.whl (375kB)
100% |████████████████████████████████| 378kB 153kB/s
Collecting tensorflow-tensorboard<0.2.0,>=0.1.0 (from tensorflow)
Downloading tensorflow_tensorboard-0.1.8-py3-none-any.whl (1.6MB)
100% |████████████████████████████████| 1.6MB 191kB/s
Collecting six>=1.10.0 (from tensorflow)
Downloading six-1.11.0-py2.py3-none-any.whl
Collecting numpy>=1.11.0 (from tensorflow)
Downloading numpy-1.13.3-cp36-cp36m- macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.5MB)
100% |████████████████████████████████| 4.6MB 114kB/s
Requirement already up-to-date: setuptools in /private/var/app/software/tensorflow/lib/python3.6/site-packages (from protobuf>=3.3.0->tensorflow)
Collecting html5lib==0.9999999 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Downloading html5lib-0.9999999.tar.gz (889kB)
100% |████████████████████████████████| 890kB 119kB/s
Collecting werkzeug>=0.11.10 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)
100% |████████████████████████████████| 317kB 143kB/s
Collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Downloading Markdown-2.6.9.tar.gz (271kB)
100% |████████████████████████████████| 276kB 162kB/s
Collecting bleach==1.5.0 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Downloading bleach-1.5.0-py2.py3-none-any.whl
Building wheels for collected packages: html5lib, markdown
Running setup.py bdist_wheel for html5lib ... done
Stored in directory: /Users/xdwang/Library/Caches/pip/wheels/6f/85/6c/56b8e1292c6214c4eb73b9dda50f53e8e977bf65989373c962
Running setup.py bdist_wheel for markdown ... done
Stored in directory: /Users/xdwang/Library/Caches/pip/wheels/bf/46/10/c93e17ae86ae3b3a919c7b39dad3b5ccf09aeb066419e5c1e5
Successfully built html5lib markdown
Installing collected packages: six, protobuf, html5lib, werkzeug, markdown, bleach, numpy, tensorflow-tensorboard, tensorflow
Successfully installed bleach-1.5.0 html5lib-0.9999999 markdown-2.6.9 numpy-1.13.3 protobuf-3.4.0 six-1.11.0 tensorflow-1.3.0 tensorflow-tensorboard-0.1.8 werkzeug-0.12.2

(tensorflow) tony:~ xdwang$ python3
Python 3.6.3 (default, Oct 4 2017, 06:09:15)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
/>>> import tesnorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tesnorflow'
/>>> import tensorflow as tf
/>>> hello=tf.constant('hello,tensorflow')
/>>> sess=tf.Session()
2017-10-26 19:21:48.857584: 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-10-26 19:21:48.857625: 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.
2017-10-26 19:21:48.857641: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-10-26 19:21:48.857655: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
/>>> print(sess.run(hello))
b'hello,tensorflow'

  • 启动tensorflow
    执行source /var/app/software/tensorflow/bin/activate脚本启动tensorflow
    tony:dl xdwang$ pwd
    /Users/xdwang/dl
    tony:dl xdwang$ ls
    fibo.py test1.py xianxinghuigui2.py
    tony:dl xdwang$ source /var/app/software/tensorflow/bin/activate
    (tensorflow) tony:dl xdwang$ pwd
    /Users/xdwang/dl
    (tensorflow) tony:dl xdwang$

在tensorflow虚拟机下安装IPython

source /var/app/software/tensorflow/bin/activate
(tensorflow) tony:~ xdwang$ pip3 install ipython
note:在tensorflow虚拟机中安装ipython之后,在intellij工程中引用import IPython就不会报错了。

tensorflow和intellij ieda集成设置

在intellij中集成tensorflow的步骤:
1,安装tensorflow3
2,安装intellij idea
3,在intellij idea中创建一个工程,在工程的 中指定Python SDK home path:/var/app/software/tensorflow/bin/python3.6
注:如果不知道tensorflow路径,可以写如下代码
(tensorflow) tony:~ xdwang$ python3
import tensorflow as tf
tf.version
'1.3.0'
tf.path
['/var/app/software/tensorflow/lib/python3.6/site-packages/tensorflow']

4,写一段测试代码试一下是否好使
import tensorflow as tf
hello=tf.constant('helloword')
sess=tf.Session()
print(sess.run(hello))


sennchi

猜你喜欢

转载自blog.csdn.net/weixin_34185364/article/details/87431100