How to set up your NVIDIA GPU on your surface book 2 for machine learning!

Anasthasia Manu
5 min readDec 24, 2020
Photograph: Microsoft

Now before we begin I must state these are the steps I followed, and yes, I know the GPU on surface book 2 (15 inches) is not the best for intense machine learning, but it is kinda cool and tbh isn’t that crazy of an idea! I see that some avid people are already deep learning on their surface books [1] so I might as well do the same! So here we go!

Zeroth Step: Clean up your PC whilst you are here

Obviously, you can skip this step if you want but before I decide to download software or manipulate the systems on my PC, I like to do a little clean so I do not run into space issues. The best thing to do would be to trigger a disk clean-up, defrag the hard drive (if it hasn’t been defragged for some time), then search for the largest files on your drive and see if you really need them. Doing this I freed up 30 GB of space!

First Step: Is my laptop the same as yours?

I will be stating the steps in relation to the system I have which is shown below:

Processor: Intel(R) Core(TM) i7–8650U CPU @ 1.90GHz 2.11 GHz
Installed RAM: 16.0 GB
System: type 64-bit operating system, x64-based processor
Pen and touch: Pen and touch support with 10 touch points
Discrete graphics: NVIDIA GTX 1060 (6 GB)
Storage: 256 GB
Edition: Windows 10 Pro
Version: 20H2
OS build: 19042.685

Second Step: Look for compatible versions to use TensorFlow with GPU

Taken this straight from the TensorFlow website [2]:

The bits I’ve circled are the most important bits of information. To use TensorFlow with GPU you have to make sure you select the versions of Python, cuDNN, and CUDA to install. We will start off with python as this was the easiest for me.

Third Step: Install Python

Go to the python website and look for any version of python from 3.6 to 3.8. I have 3.6.8 installed (will probably upgrade to 3.8 when I have time, always keep your software updated — unless it messes with your projects😂). ENSURE YOU GET ANACONDA INSTALLED AS IT WILL MAKE THE OTHER STUFF EASY. On the home page currently, there should be a section that looks like the following:

Download the right version and make sure when it is installed you check the version by opening up a command prompt (can be opened by typing ‘Command Prompt’ into the start search bar for windows. You Mac people I don’t know) and typing the command ‘python --version’. Should see something like below:

Fourth Step: Install CUDA

The latest CUDA version as of writing this is 11.2, but as the compatibility table above shows, we need 11.0. To search for archive downloads of CUDA, go here [3]. Select the 11.0 version and follow the selection process for your PC. Your screens should look like the following:

N.B to download CUDA you need to have an NVIDIA developer account but you can easily sign up for that when prompted.

There should be some onscreen steps in order to download CUDA. Follow them through and when that is finished you should check your version by opening the command prompt again and typing the command ‘nvcc --version’. Should hopefully see something like this:

If you get stuck anywhere on your way downloading CUDA, see if you can find answers using their guidelines at [4].

Fifth Step: Install cuDNN

So now onto cuDNN, a little bit more tricky than CUDA as it requires some environment variables being set up. I found following the install guidelines by NVIDIA somewhat helpful [5], but I mainly used these two blogs to get me by, changing the version to cuDNN 8.0: Step 5 in [6] and [7]. Both will show you the files you need to move over from your cuDNN download to your NVIDIA GPU toolkit folders so follow carefully and ensure the environment variables are set properly!

Sixth Step: Install TensorFlow GPU

So there are two different versions of TensorFlow I have learned. The basic version, and the GPU version. Although both can technically be downloaded onto your PC at the same time, we only need the GPU version to execute TensorFlow using our NVIDIA GPU. This requires you to call on the good ol’ command prompt and run it as an administrator this time. Then in your computer folder (C:\) you can execute the following command ‘pip install --tensorflow-gpu ==2.4.0’ this will ensure that the version we need is installed and not a higher/lower version. I have also realized that I needed to also execute this command in anaconda prompt (should have had this installed as a part of the python install). In the anaconda prompt, you should also execute this same command there. There might be some issues with numPy or other package compatibility issues, just follow what the prompt states when these things happen as it will tell you what versions you will need to download in order to get stuff to work

Seventh Step: Test out your changes!

The easiest way to check if your stuff works is to open up any type of prompt (anaconda or command) and type in ‘python’. This will open up a python IDE where we can test! write the following lines, one by one to ensure everything passes properly:

import tensorflow as tf

tf.test.is_built_with_cuda()

tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None)

The last two statements should return true if your GPU is available. If so, congratulations!

To test out your new installation I suggest following this blog [8] to train some neural networks using Open AI and baselines!

This blog is mainly for me just in case my laptop goes weird and I have to set this up again but I hope some of you might find this informative!

References

[1] https://www.reddit.com/r/Surface/comments/7jed5s/book2_anyone_deep_learning_in_sb2_15/

[2] https://www.tensorflow.org/install/source_windows

[3] https://developer.nvidia.com/cuda-toolkit-archive

[4] Installation Guide Windows :: CUDA Toolkit Documentation (nvidia.com)

[5] https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#install-windows

[6] Installing Tensorflow with CUDA, cuDNN and GPU support on Windows 10 | by Dr. Joanne Kitson | Towards Data Science

[7] Blog Installing Tensorflow with CUDA, cuDNN and GPU support on Windows 10 (newzenler.com)

[8] Gym and Baselines on Windows — Samuel Arzt (arztsamuel.github.io)

--

--