Problems getting GPU to run in Jupyter Notebook

Hello Forum,
I have been struggling with this issue for a week, making gradual progress, but now I just don’t see a way forward. I used the instructions on setting up a conda environment with cuda, cudnn etc., and it worked to the point where the GPU is recognized and should be able to run. Picture proof:
Screenshot 2023-03-19 202916

However, when I ran a simple LSTM, which is the type where I would eventually really need the speed boost, my GPU remained idle, while Python would run 50% CPU power only. That even happens if I place a tf.config.set_visibledevices([], 'GPU'), so it seems parts of the tensorflow internal settings just get ignored?
I can’t diagnose where the problem lies. Any help appreciated.


Welcome to the Tensorflow Forum!

Generally a model needs to be big enough in order to profit from GPU acceleration.

If you would like a particular operation to run on a device of your choice, you can use with tf.device to create a device context. For more details please refer to Use a GPU  |  TensorFlow Core

Also to find out which devices your operations and tensors are assigned to, put tf.debugging.set_log_device_placement(True) as the first statement of your program.

Thank you!

Thank you chunduriv, I think that worked.
I enabled the logging and placed a with tf.device('/device:GPU:0'): on the network, which resulted in this message:

I suppose it really was too small, although it still took 2-4 minutes on CPU.
However, I am seeing at least 8% GPU usage now, and the log agrees that many tasks are now performed with the GPU in charge.

Thank you again!

Problems getting GPU to run in Jupyter Notebook can be quite frustrating. One of the main issues is that the GPU needs to be compatible with the version of Jupyter Notebook that is installed. If the GPU is too old or too new, it may not be supported. Additionally, the GPU may need to be configured properly in order to work with Jupyter Notebook. This can involve making sure that the correct drivers are installed and that the correct settings are enabled. Furthermore, the GPU may need to be enabled in the Jupyter Notebook configuration file. All of these problems can be difficult to troubleshoot and can be time-consuming to resolve. In some cases, it may

Hmm, it really seems then like one would be better off simply doing the training old school through some python script directly. Which is a possibility, but just uncomfortable, since data viewing and decisions on changes are more easily done live in notebooks.

I had my GPU running at 16% later on the particular test task by the way, but it actually took a bit longer this way than purely on CPU, so something isn’t right still.
If this trend continues for the real problems as well, I will have to switch. Thank you for the pointers Jospeh-MAck. It seems too much hassle to get functionality that I otherwise already posses elsewhere.

1 Like

There are several reasons why you might be experiencing issues getting a GPU to run in Jupyter Notebook. Here are a few possible solutions:

  1. Check the installation: Ensure that you have installed the necessary libraries and dependencies, including CUDA and cuDNN. You should also check that the GPU driver is installed and up to date.
  2. Verify GPU access: Check that your GPU is being detected and accessed by the system. You can use the command nvidia-smi in the terminal to verify this.
  3. Specify the device: When creating a TensorFlow session, you can specify the device to use. For example, you can set with tf.device('/device:GPU:0'): to run the code on the first GPU.
  4. Check memory usage: GPU memory usage can be a common issue when running complex models or large datasets. You can use tf.config.experimental.list_physical_devices('GPU') to list available GPUs and check their memory usage.
  5. Restart the kernel: If you encounter issues during runtime, you can try restarting the kernel to clear any errors or conflicts that may have occurred.
    If none of these solutions work, it may be helpful to consult the documentation or forums for the specific GPU and software you are using, or seek help from a professional in the field.

I have GPU in my system and it was working fine in PyCharm but not showing in Jupyter Notebook, where i have installed 2.12 version of TensorFlow
TensorFlow version 2.10 worked for me


Welcome to the Tensorflow Forum!

Could you please share details of the operating system?

Thank you!