Jupyter Notebooks predicting always the same class with GPU and pretrained Keras checkpoint

When I predict on a pre-trained VGG16 based checkpoint with load_weights I am always getting the same class and output tensor. This only happens when I use my GPU (I have 2 GPUs).

If, on the other hand, I only use my CPU by setting:

os.environ["CUDA_VISIBLE_DEVICES"] = "-1" 

I get the expected results. This happens for me in Jupyter Notebooks, but it does not happen in google colab. In google colab I get accurate results no matter what.

  • I am using Keras 2.4.3
  • Tensorfow 2.4.1
  • CUDA 11.2