TensorFlow (CPU Only) : Install2018/06/28 |
Install TensorFlow which is Machine Learning Library by Google.
To use TensorFlow, it's possible to select APIs for some languages like Python, C, Java, Go.
On this example, use Python 2.7. (The version requirements is Python 2.7 or Python 3.3 and later)
Furthermore on this example, Install officially provided binary module.
For binary module, it provides GPU supported and no GPU supported version. On here, install no GPU supported version. |
|
[1] | Install Python. |
root@dlp:~# apt -y install python2.7 python-pip python-setuptools python2.7-dev
|
[2] | Install TensorFlow. |
root@dlp:~# pip install --upgrade tensorflow requests Collecting tensorflow Downloading https://files.pythonhosted.org/packages/c6/0e/8af18d9169ed4f1a1c72cd50defd95b8382a12f2cf7cb9b76ba053db79ad/tensorflow-1.8.0-cp27-cp27mu-manylinux1_x86_64.whl (49.1MB) 100% |#############################| 49.1MB 24kB/s ..... ..... Successfully installed absl-py-0.2.2 astor-0.6.2 backports.weakref-1.0.post1 bleach-1.5.0 certifi-2018.4.16 chardet-3.0.4 enum34-1.1.6 funcsigs-1.0.2 futures-3.2.0 gast-0.2.0 grpcio-1.12.1 html5lib-0.9999999 idna-2.7 markdown-2.6.11 mock-2.0.0 numpy-1.14.5 pbr-4.0.4 protobuf-3.6.0 requests-2.19.1 setuptools-39.2.0 six-1.11.0 tensorboard-1.8.0 tensorflow-1.8.0 termcolor-1.1.0 urllib3-1.23 werkzeug-0.14.1 wheel-0.31.1 |
[3] | Verify installation with a common user. For the messages [CPU supports ***], it's no ploblem. It means TensorFlow Binary has compiled without CPU feature listed in the messages. |
ubuntu@dlp:~$ vi hello_tensorflow.py import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello)) python ./hello_tensorflow.py 2018-06-27 19:38:36.923028: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA Hello, TensorFlow! |
[4] | Try to experience TensorFlow to run officially provided basic Model. |
ubuntu@dlp:~$ mkdir tensorflow ubuntu@dlp:~$ cd tensorflow ubuntu@dlp:~/tensorflow$ git clone https://github.com/tensorflow/models.git ubuntu@dlp:~/tensorflow$ export PYTHONPATH="$PYTHONPATH:$(pwd)/models" ubuntu@dlp:~/tensorflow$ cd models/official/mnist ubuntu@dlp:~/tensorflow/models/official/mnist$ python mnist.py 2018-06-27 19:43:53.182546: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA I0628 19:43:53.187784 140599304931136 tf_logging.py:116] Using default config. ..... ..... I0628 10:50:06.031625 140599304931136 tf_logging.py:116] Finished evaluation at 2018-06-28-01:50:06 I0628 10:50:06.032596 140599304931136 tf_logging.py:116] Saving dict for global step 24000: accuracy = 0.9922, global_step = 24000, loss = 0.028149871 Evaluation results: {'loss': 0.028149871, 'global_step': 24000, 'accuracy': 0.9922} |
[5] | To use TensorBoard, it's possible to visualize the results of learnings. By default results are outputs unser /tmp directory, so specify it like follows. After running TensorBoard, access to the URL (server's hostname or IP address):6006, then it's possible to see visualized results. |
ubuntu@dlp:~$ tensorboard --logdir=/tmp/mnist_model 2018-06-28 11:02:01.882544: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA |
Sponsored Link |
|