Introduction
We are going to install tensorflow-gpu
from scratch on a Windows 10 machine. You will find all the right version numbers. All the traps to dodge. All the solutions to the problems I encountered.
My system is:
- Windows 10 64
- Nvidia GeForce 1070
Installing everything
Python
You need Python3.5.4
.
Go to https://www.python.org/downloads/release/python-354rc1/
I downloaded the Windows x86-64 executable installer
This should give you:
$ python --version Python 3.5.4
$ pip --version pip 9.0.3 from [...]\local\programs\python\python35\lib\site-packages (python 3.5)
Visual Studio
VB 2017
Visual studio is not really required but it is useful to know if your CUDA
installation is working.
- Go to https://www.visualstudio.com/downloads and get the
2017 community
edition. - Install it.
2015 pack
- On this page: https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017 get the Microsoft Visual C++ Redistributable for Visual Studio 2017
- From there install the
VC++ 2015.3 v140 toolset for desktop (x86,x64)
.
CUDA
Main documentation: https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html
Install
Through this process this was the biggest challenge because I installed CUDA-9.1
but it is not compatible with tensorflow 1.7.0
.
Uninstalling CUDA-9.1
was not easy and I am still battling with artifact and conflicts.
DO NOT INSTALL CUDA-9.1
Thanks for https://github.com/tensorflow/tensorflow/issues/17101 for the help !
Go to https://developer.nvidia.com/cuda-90-download-archive to download CUDA-9.0
and install it.
If you have an issue with it hanging, try:
- Disabling
Avast
- Uncheck
visual studio integration
.
Issues with NSight
If you had to disable visual studio integration
to install CUDA
.
For CUDA-9.0
, you need NSight-5.3
.
Go to https://developer.nvidia.com/nsight-visual-studio-edition-5_3 and download https://developer.nvidia.com/rdp/assets/nsight-visual-studio-5_3-general-win10-64-driver
I am still having issues right now and have an open message here: https://devtalk.nvidia.com/default/topic/1031732/visual-studio-integration-9-0-fail-to-install-after-removing-cuda-9-1/#5249049.
I will update as I get news.
Stay tuned.
Add a path to the environment variable PATH in Windows 10
You need to add the right folder to the PATH environment variable. It is a bit convoluted to do that on windows.
- Right click on
Computer
Properties
Advanced system settings
- In the tab
Advanced
, click onEnvironment Variables...
- Click on the line with
Variable
isPath
- Click
Edit...
- In the new opened windows click
New
.
- Add
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin
.
Testing if it works
Following the main documentation.
- Open
C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.0\1_Utilities\deviceQuery\deviceQuery_vs2017.sln
withvisual studio 2017
. - In the Visual Studio UI, you should see
debug
at the top. - Switch it to
Release
. - And then in the menu bar:
Build
->Build Solution
. - That should produce an
exe
file atC:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.0\bin\win64\Release
. - Launch the binary through the
cmd
. - You can reproduce this step with
C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.0\1_Utilities\bandwidthTest
.
Various Issues
Wrong package
Right click on the project in Visual Studio
and in the properties
where it says VC++ 2017
, try using the 2015 one
instead.
Python – Install tensorflow-gpu
You need to install tensorflow-gpu
, keras
and you will be ready to go.
Just do:
$ python -m pip install --upgrade pip
$ pip install tensorflow-gpu
$ pip install keras
And you should be good to go.
Testing
import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello))
Execute that.
Miscellanious
CUBLAS_STATUS_ALLOC_FAILED
Solution found at https://github.com/tensorflow/tensorflow/issues/7072.
Solution:
from keras.backend.tensorflow_backend import set_session config = tf.ConfigProto( gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.8) # device_count = {'GPU': 1} ) config.gpu_options.allow_growth = True session = tf.Session(config=config) set_session(session)
This will solve the memory issue on the GPU.
Thanks a ton! This really helped me through the process, do update the article if you figure out how to get visual studio integration to work (I still get the CUDA 9.0.props not found error).
If you find a way, please share it as well ! I am still looking for a solution without having to reinstall my whole OS.
did anybody found a solution ???
This solution from oregonduckman worked for me for the props problem:
https://devtalk.nvidia.com/default/topic/1033111/cuda-setup-and-installation/cuda-9-1-cannot-install-due-to-failed-visual-studio-integration/post/5259359/#5259359
Thank you for the tutorial, its really helpful!
Thank you for sharing this post !