Install Tensorflow on Windows

The instructions below can be used to install precompiled version of tensorflow. To build tensorflow from source please follow the instructions in my previous post <http://www.shaneahmed.com/2017/07/build-tensorflow-on-windows.html>. After successful build you can follow the same instructions as for the precompiled version below. Make sure you use the correct path to tensorflow pip package .whl file.

Requirements:

  1. Python 3.5 Anaconda x64: https://repo.continuum.io/archive/Anaconda3-4.2.0-Windows-x86_64.exe
  2. CUDA 8.0 (For GPU Support):  https://developer.nvidia.com/cuda-downloads
  3. cuDNN v5.1 (For GPU support) : https://developer.nvidia.com/cudnn

Installation instructions:

  1. Install Anaconda in "C:\tools\", make sure you select Register Anaconda as system path for Python 3.5.
  2. Open command window. (Win+R -> cmd -> Enter)
  3. Enter the following commands
    C:\> conda create -n tensorflowCPU python=3.5
  4. Enter 'y' if asked to continue.
  5. Activate conda virtual environment by entering the following command.
    C:\> activate tensorflowCPU
  6. Enter the appropriate command below to install particular version of tensorflow.

    For latest version of tensorflow use the following command.

    (tensorflowCPU) C:\> pip install --upgrade tensorflow

    For version 1.2 of tensorflow use the following command. You can find the appropriate address for each version on pages with instructions at this link <https://www.tensorflow.org/versions/>

    (tensorflowCPU) C:\> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.2.1-cp35-cp35m-win_amd64.whl
  7. Enter the following commands to run tensorflow using python
    (tensorflowCPU) C:\> python
     >>> import tensorflow as tf
     >>> hello = tf.constant('Hello, TensorFlow!')
     >>> sess = tf.Session()
     >>> print(sess.run(hello))
     'Hello, TensorFlow!'
    
  8. The command should print 'Hello, TensorFlow!' if you have successfully installed tensorflow.

      For GPU support:

  1. Install CUDA v8.0.
  2. Extract cuDNN.
    • copy all files from bin folder to 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin'
    • similarly from include to 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include' 
    • and 'lib\x64' to  ''C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64'.
  3. Open command window. (Win+R -> cmd -> Enter)
  4. Enter the following commands
    C:\> conda create -n tensorflowGPU python=3.5
  5. Enter 'y' if asked to continue.
  6. Activate conda virtual environment by entering the following command.
    C:\> activate tensorflowGPU
  7. Enter the appropriate command below to install particular version of tensorflow.

    For latest version of tensorflow use the following command.

    (tensorflowGPU) C:\> pip install --upgrade tensorflow-gpu

    For version 1.2 of tensorflow use the following command. You can find the appropriate address for each version on pages with instructions at this link <https://www.tensorflow.org/versions/>

    (tensorflowGPU) C:\> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.2.1-cp35-cp35m-win_amd64.whl
  8. Enter the following commands to run tensorflow using python
    (tensorflowGPU) C:\> python
     >>> import tensorflow as tf
     >>> hello = tf.constant('Hello, TensorFlow!')
     >>> sess = tf.Session()
     >>> print(sess.run(hello))
     'Hello, TensorFlow!'
    
  9. The command should print 'Hello, TensorFlow!' if you have successfully installed tensorflow.
 

2 comments:

  1. Thank you!!! Perfect instruction!!!

    ReplyDelete
  2. will not cause any evaluation warnings. Download Activators from below links and follow the instruction given in the downloaded file. windows 10 activator

    ReplyDelete

How to run R code in Python

R is freely available language and computational tool which is very popular among the statisticians and bioinformatics community. In this p...