Imran's personal blog

November 21, 2016

Steps to Install TensorFlow with GPU on Windows

Filed under: Uncategorized — ipeerbhai @ 1:11 am

I normally use Encog and a self-written learning framework for when I do audio pipeline learning.  I’ve been tempted by CNTK and TensorFlow.  CNTK uses tools whose license is, sadly, too restrictive.  TensorFlow’s ecosystem is more in-line with what I need.

I’m a windows guy, and I can use TensorFlow(TS) via docker.  But, I want to use my GPU.  I have a CUDA compliant GPU on one of my machines along with Windows 10 and Visual Studio Community.  The official readme is designed for VS Pro, not community.  The key difference is that VS Community doesn’t officially support TensorFlow 32 bit with CUDA, only 64 bit.

Here’s the steps I’ve figure out so far:

Prerequisites.

You’ll need SWIG, CUDA, the Nvidea NN library for Cuda, Git, CMake, Python3.5 and numpy 1.11.  You can use Anaconda to satisfy the python/numpy requirement.  Install Anaconda, then conda install numpy in an elevated command prompt.  The rest, you’ll have to download installers and install.  Oh, and Visual Studio Community 2015.  I’ll assume a default install drive of C:  I’ve adapted the steps from the official Github here:

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/cmake/README.md

You’ll want to read that first, as the changes are pretty minor.

Also, if you have python 2.7, then remove Python 2.7 from your path — it’ll interfere with CMAKE.

Steps

  1. launch a CMD window and setup the environment.
    1. Put all the above pre-reqs in your path environment variable, except for Visual Studio.
    2. run “C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat”  ( This is changed from official docs )
    3. Put CMAKE in your path: set PATH=”%PATH%;C:\Program Files\CMake\bin” ( different than docs)
  2. Git pull tensorflow, change into the CMAKE dir, then build this CMAKE invocation line:
    1. cd /d “C:\temp\tensorflow\tensorflow\contrib\cmake\build”
    2. cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release -DSWIG_EXECUTABLE=”C:/tools/swig/swig.exe” -DPYTHON_EXECUTABLE=C:/Users/%USERNAME%/AppData/Local/Continuum/Anaconda3/python.exe -DPYTHON_LIBRARIES=C:/Users/%USERNAME%/AppData/Local/Continuum/Anaconda3/libs/python35.lib -DPYTHON_INCLUDE_DIR=”C:/Program Files/Anaconda3/include” -DNUMPY_INCLUDE_DIR=”C:/Program Files/Anaconda3/lib/site-packages/numpy/core/include” -Dtensorflow_ENABLE_GPU=ON -DCUDNN_HOME=”C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0″
  3. In theory, you can MSBuild the resulting vcproj from step 2.  I’ve found some build breaks, so I’ll update this post when I’ve figure it out.  Here’s the list so far:
    1. Severity Code Description Project File Line Suppression State
      Error C1083 Cannot open include file: ‘tensorflow/cc/ops/image_ops.h’: No such file or directory tf_label_image_example c:\temp\tensorflow\tensorflow\examples\label_image\main.cc 38
    2. Severity Code Description Project File Line Suppression State
      Error C1083 Cannot open include file: ‘tensorflow/cc/ops/array_ops.h’: No such file or directory tf_tutorials_example_trainer c:\temp\tensorflow\tensorflow\cc\ops\standard_ops.h 19
    3. Severity Code Description Project File Line Suppression State
      Error LNK1104 cannot open file ‘Debug\tf_core_gpu_kernels.lib’ grpc_tensorflow_server C:\temp\tensorflow\tensorflow\contrib\cmake\build\LINK 1
    4. Severity Code Description Project File Line Suppression State
      Error LNK1104 cannot open file ‘Debug\tf_core_gpu_kernels.lib’ pywrap_tensorflow C:\temp\tensorflow\tensorflow\contrib\cmake\build\LINK 1

 

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: