TensorFlow | Install and Test

For more information about Tensorflow,please go to https://www.tensorflow.org

Python

Versions

Python 3.5.x/3.6.x 64-bit from python.org

Python 3 comes with pip3 package manager

Environment Variable

windows+R → cmd → sysdm.cpl → 高级 → 环境变量

C:\Python36\
C:\Python36\Scripts\

Specify a version

py -2/-3
Image

Requirements to run TensorFlow with GPU support

GPU card with CUDA Compute Capability 3.0 or higher for building from source and 3.5 or higher for our binaries.

控制面板 → NVIDIA控制面板 → 帮助 →get information about your GPU card

Go to this website to see wheater your GPU card suppport CUDA.

The NVIDIA drivers associated with CUDA Toolkit 9.0.

Update driver software of your GPU.

CUDA® Toolkit 9.0

download webside

Environment Variable

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64

Move files

Error : couldn’t open CUDA library cupti64_80.dll
Solution:

  • find files in

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\CUPTI\libx64

  • move to

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin

cuDNN v7.0

download webside

need login in and fill out the questionnaire

Move files

  • Copy \cuda\bin\cudnn64_7.dll to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin.
  • Copy \cuda\ include\cudnn.h to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include.
  • Copy \cuda\lib\x64\cudnn.lib to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64.

Installing with Anaconda

download website

run with administrative rights

C:> conda create -n tensorflow pip python=3.5/3.6
C:> conda activate tensorflow
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow-gpu 
(tensorflow)C:> python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))

OUTPUT : Hello, TensorFlow!

Test

Download examples of projects using Tensorflow from github.com/tensorflow

MNIST

Change the path code for Liunx to Windows

minst_with_summaries.py

  parser.add_argument(
      '--data_dir',
      type=str,
      #####add drive letter F
      default=os.path.join(os.getenv('TEST_TMPDIR', 'F:/tmp'),           
                           'tensorflow/mnist/input_data'),
      help='Directory for storing input data')
  parser.add_argument(
      '--log_dir',
      type=str,
      #####add drive letter F
      default=os.path.join(os.getenv('TEST_TMPDIR', 'F:/tmp'),         
                           'tensorflow/mnist/logs/mnist_with_summaries'),
      help='Summaries log directory')

Result

open browser with http://localhost:6006

tensorboard --logdir = F:/tmp/tensorflow/mnist/logs/mnist_with_summaries

Image

Comments
Write a Comment