Give me instructions on setting up my GPU drivers to work with TensorFlow-Python?

I have an Intel onboard graphics and NVIDIA 940MX on my laptop. I want to know which drivers should be installed to get maximum GPU performance off my laptop for GPU intensive processes.

Here is a screenshot showing the drivers available. Note the name of the NVIDIA card, on top, is hidden.

This should be alright, you’ll probably need to install cuda as well.

Yea I’ve installed CUDA and CUDNN. But I’ve noticed that Tensorflow doesn’t use the GPU for all of its processes. It sometimes uses CPU and sometimes GPU. It does use GPU to the brim at times. I’m concerned that the GPU isn’t being used all the time while the script containing Tensorflow code is running. Is this behaviour normal?

Some tasks can’t be run on a GPU or it doesn’t make sense to copy the tensors.

In your script, if you add the following line


you can see in the log to which device (CPU, GPU) the tensors are placed.

You can force the placement of tensors with:

with tf.device('/GPU:0'):

(Select the correct device, of course)

Thanks for the snippet. Also, the only device that gets mentioned in TensorFlow’s log is my NVIDIA card. Does that mean it’s using the NVIDIA card?

Also, can I make the actual name of the card it specifies as GPU:0? I couldn’t find any code online that could do that.

You can run nvidia-smi to determine which processes are using the GPU.

That’s directly from Use a GPU  |  TensorFlow Core