Installing Tensorflow for CPU and GPU on a Windows machine (nvidia gpus).

I've recently been working quite a bit with Tensorflow.  Below are my notes on how to install Tensorflow on a Windows machine for both CPU and GPU.  The process was extremely painful for me my first time so these notes should be pretty useful for anyone starting out for the first time.


Step 1: Install the correct NVidia CUDA and CUDNN drivers:

As of 1/4/2018, I recommend pairing tensorflow 1.4, with CUDA 8.0 and CUDNN version 6.X

Step 2: Set up virtual environment for CPU Tensorflow and GPU Tensorflow and install the necessary packages.


You will need to have anaconda installed to run conda commands.
conda create --name tensorflow python=3.5
activate tensorflow==1.4.0
pip install tensorflow
conda create --name tensorflow-gpu python=3.5
activate tensorflow-gpu==1.4.0
pip install tensorflow-gpu
Note: you should only install either the cpu or gpu versions of Tensorflow, not both.  That's why it is beneficial to use virtual environments to separate the two installations.  The example above installs tensorflow 1.4.0, which pairs well with CUDA 8.0.  You can try tesnorflow 1.5.0 with CUDA 9.0/9.1 but I cannot guarantee that it works as I haven't tried it myself.

Step 3: Activate the virtual environment and begin using tensorflow!

activate tensorflow
activate tensorflow-gpu
Note: As of 2/26/2018, activating and deactivating conda environments seems to only work in cmd and not in windows powershell.

To Deactivate:

deactivate

Additional Notes

  • On Windows, Tensorflow 1.4 is only compatible with CUDA 8.0, not CUDA 9.X
  • run check_version.py (from my github repo) to check if all tensorflow components have been installed correctly.

Next Steps:

Official installation instructions:
//www.tensorflow.org/install/
After getting all of this working, I recommend working through some of the tutorials on the Tensorflow website:

Comments

Popular posts from this blog

grandmaster level chess AI using python - Part 2 (the code)

building a chess ai - part 4: learning an evaluation function using deep learning (keras)

Brief intro to recurrent neural networks