TensorFlow is Google’s open-source library which enables you to develop and train deep learning models. Whilst most of the install guides focus on installing the CPU version, which is your regular
pip install, today I want to focus on installing it’s bigger, much more powerful brother — the GPU version.
The main reason why you’d want to use GPU version instead of the CPU one is speed — there’s an incredible speed improvement if you decide to train models on GPU and I don’t wont to go in the reasons why — as this is an How to guide instead of Why to guide.
On top of everything, the setup will be done on Windows 10 x64 machine. So no Linux here, as I know installation on Linux is fairly trivial.
Without further ado, let’s jump right in. The next section will briefly discuss what you’ll need.
In this entire process we’ll need to download and install three tools:
The following sections will focus on how to install each individual tool.
Now we won’t be really using Visual Studio, but some components of the Nvidia CUDA Toolkit require it, so it is what it is.
Visual Studio can be downloaded from this link, and from here it’s easy to download the Community edition:
When installing you don’t need to check any additional components — leave everything as is and click on Next a couple of times. In about 5 to 10 minutes the installation should finish. You won’t need to touch the Visual Studio ever again, Tensorflow-wise.
This Toolkit enables you to create high-performance GPU-accelerated applications. In can be downloaded from this link, just make sure to select everything I have selected and then click on Download button down below.
It’s slightly over 2 GB in size, so depending on your internet speed it could take a while.
Once downloaded you can run the .exe file, it will ask you to extract the contents into some temporary folder. Once the installation begins you can stick with the Express option:
And after a couple of minutes, Nvidia CUDA Toolkit will be installed!
Up next, Nvidia cuDNN.
Nvidia cuDNN is a GPU-accelerated library for deep neural networks. It can be downloaded from this link. Keep in mind that you will need to create an account, but you can just log in with Google and you’re good to go.
Upon login, you will be redirected to the page below — click on Download cuDNN 7.6.5 for CUDA 10.0:
It is a ZIP file, maybe 250MB in size so it should download quickly. Once downloaded you can unzip the contents˛(that is the 3 directories inside) to your CUDA installation directory — which will be in:
C:\Program Files\Nvidia GPU Computing Toolkit\CUDA\v10.0
if you haven’t changed anything upon the installation. And that’s it. Setup done!
We’ve completed the tedious setup process, now it’s only time to do a simple pip install. By the time of writing this article, the latest GPU enabled TensorFlow version was 2.0.0 RC1.
To install it, open up the Command Prompt and execute the following (I assume you have Python installed):
pip install tensorflow-gpu=2.0.0-rc1
If you fail to provide the version it will install version 1.14, which we don’t want.
And that’s it, it will take some time to download (300+ MB), but TensorFlow should now be installed on your machine. Let’s just quickly verify that claim:
As you can see, I opened the Python shell inside the Command Prompt, imported TensorFlow and checked if GPU is available. The function called return True, and you can also see my GPU colored yellow on the bottom of the prompt.
Having a thin and light laptop is nice — you can go anywhere without messing up your back. But what’s even cooler than not having back issues is having a powerful laptop capable of training neural networks on the GPU.
This article shouldn’t take you more than 5 minutes to read front to back, and 15 minutes to install and configure everything, provided you have a decent internet speed.
Thanks for reading. Have fun — I know I will.