Kernel of jupyter notebook die when calling vgg16 model predict


i can detect and use my GPU card if i use tensorflow bert, or tensorflow model.sequential for example ,

i can reproduce in my jupyter notebook the code lines in the website

but if i try to use tensorflow keras VGG16 (pretrained model) when i use model.predict, the kernel die.

I hope someone may help me to resolve this problem in order to use VGG16 for a classification of images.

i listed below all the information i was able to find

  • the code, and the type of error,
  • the list of packages in my conda environment,
  • my system and the list of programs installed (microsoft visual ++, python, anaconda, nvidia)
  • my jupyter notebook version and a verif for the installation of cuda

sincerely yours,

about the issue with keras model VGG16 and VGG19

for downloading the picture

import tensorflow as tf
from tensorflow.keras.models import Model, Sequential
from tensorflow.keras.applications.vgg16 import VGG16
import numpy as np

with hyperparameter include_top = False, the problem still remind the same

base_model = VGG16(weights=‘imagenet’, include_top=True)

from tensorflow.keras.preprocessing.image import load_img, img_to_array
from keras.preprocessing import image
from tensorflow.keras.applications.vgg16 import preprocess_input, decode_predictions

img_path = “./little-cute-maltipoo-puppy-royalty-free-image-1652926025.jpg”
img = load_img(img_path, target_size=(224, 224))
x = img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)


the problem occurs at this step

preds = base_model.predict(x)
decode_predictions(preds, top = 3)

Error message : “Kernel restarting” “The kernel appears to have died. It will restart automatically.”

about my conda env

(mygpuenv) ./raoul>conda list

packages in environment at ./anaconda3\envs\mygpuenv:

Name Version Build Channel

absl-py 0.15.0 pypi_0 pypi
astunparse 1.6.3 pypi_0 pypi
attrs 23.1.0 pypi_0 pypi
backcall 0.2.0 pypi_0 pypi
ca-certificates 2023.5.7 h56e8100_0 conda-forge
cachetools 4.2.4 pypi_0 pypi
certifi 2023.5.7 pypi_0 pypi
charset-normalizer 3.1.0 pypi_0 pypi
clang 5.0 pypi_0 pypi
click 8.1.3 pypi_0 pypi
colorama 0.4.6 pypi_0 pypi
cudatoolkit 11.2.2 h933977f_10 conda-forge
cudnn h3e0f4f4_0 conda-forge
cycler 0.11.0 pypi_0 pypi
cython 0.29.23 pypi_0 pypi
debugpy 1.6.7 pypi_0 pypi
decorator 5.1.1 pypi_0 pypi
dill 0.3.6 pypi_0 pypi
entrypoints 0.4 pypi_0 pypi
filelock 3.12.0 pypi_0 pypi
flatbuffers 1.12 pypi_0 pypi
fsspec 2023.5.0 pypi_0 pypi
gast 0.4.0 pypi_0 pypi
gensim 4.1.2 pypi_0 pypi
google-auth 1.35.0 pypi_0 pypi
google-auth-oauthlib 0.4.6 pypi_0 pypi
google-pasta 0.2.0 pypi_0 pypi
grpcio 1.54.2 pypi_0 pypi
h5py 3.1.0 pypi_0 pypi
huggingface-hub 0.14.1 pypi_0 pypi
idna 3.4 pypi_0 pypi
importlib-metadata 6.6.0 pypi_0 pypi
ipykernel 6.4.2 pypi_0 pypi
ipython 7.34.0 pypi_0 pypi
ipython-genutils 0.2.0 pypi_0 pypi
jedi 0.18.2 pypi_0 pypi
jinja2 3.0.2 pypi_0 pypi
joblib 1.2.0 pypi_0 pypi
jsonschema 4.17.3 pypi_0 pypi
jupyter-client 7.4.9 pypi_0 pypi
jupyter-core 5.3.0 pypi_0 pypi
keras 2.6.0 pypi_0 pypi
keras-preprocessing 1.1.2 pypi_0 pypi
kiwisolver 1.4.4 pypi_0 pypi
markdown 3.4.3 pypi_0 pypi
markupsafe 2.1.2 pypi_0 pypi
matplotlib 3.4.3 pypi_0 pypi
matplotlib-inline 0.1.6 pypi_0 pypi
nbformat 5.1.3 pypi_0 pypi
nest-asyncio 1.5.6 pypi_0 pypi
nltk 3.6.5 pypi_0 pypi
numpy 1.19.5 pypi_0 pypi
oauthlib 3.2.2 pypi_0 pypi
opencv-python pypi_0 pypi
openssl 1.1.1q h8ffe710_0 conda-forge
opt-einsum 3.3.0 pypi_0 pypi
packaging 23.1 pypi_0 pypi
pandas 1.3.4 pypi_0 pypi
parso 0.8.3 pypi_0 pypi
pickleshare 0.7.5 pypi_0 pypi
pillow 9.5.0 pypi_0 pypi
pip 23.0.1 py39haa95532_0
platformdirs 3.5.1 pypi_0 pypi
plotly 5.3.1 pypi_0 pypi
prompt-toolkit 3.0.38 pypi_0 pypi
protobuf 3.19.6 pypi_0 pypi
pyasn1 0.5.0 pypi_0 pypi
pyasn1-modules 0.3.0 pypi_0 pypi
pygments 2.15.1 pypi_0 pypi
pyparsing 3.0.9 pypi_0 pypi
pyrsistent 0.19.3 pypi_0 pypi
python 3.9.0 h6244533_2
python-dateutil 2.8.2 pypi_0 pypi
pytz 2023.3 pypi_0 pypi
pywin32 306 pypi_0 pypi
pyyaml 6.0 pypi_0 pypi
pyzmq 25.0.2 pypi_0 pypi
regex 2023.5.5 pypi_0 pypi
requests 2.30.0 pypi_0 pypi
requests-oauthlib 1.3.1 pypi_0 pypi
rsa 4.9 pypi_0 pypi
sacremoses 0.0.53 pypi_0 pypi
scikit-learn 1.2.0 pypi_0 pypi
scipy 1.10.1 pypi_0 pypi
seaborn 0.11.2 pypi_0 pypi
setuptools 66.0.0 py39haa95532_0
six 1.15.0 pypi_0 pypi
smart-open 6.3.0 pypi_0 pypi
sqlite 3.41.2 h2bbff1b_0
tenacity 8.2.2 pypi_0 pypi
tensorboard 2.6.0 pypi_0 pypi
tensorboard-data-server 0.6.1 pypi_0 pypi
tensorboard-plugin-wit 1.8.1 pypi_0 pypi
tensorflow 2.6.5 pypi_0 pypi
tensorflow-estimator 2.6.0 pypi_0 pypi
tensorflow-hub 0.12.0 pypi_0 pypi
termcolor 1.1.0 pypi_0 pypi
threadpoolctl 3.1.0 pypi_0 pypi
tokenizers 0.10.3 pypi_0 pypi
tornado 6.3.2 pypi_0 pypi
tqdm 4.65.0 pypi_0 pypi
traitlets 5.9.0 pypi_0 pypi
transformers 4.12.2 pypi_0 pypi
typing-extensions pypi_0 pypi
tzdata 2023c h04d1e81_0
urllib3 2.0.2 pypi_0 pypi
vc 14.2 h21ff451_1
vs2015_runtime 14.27.29016 h5e58377_2
wcwidth 0.2.6 pypi_0 pypi
werkzeug 2.3.4 pypi_0 pypi
wheel 0.38.4 py39haa95532_0
wrapt 1.12.1 pypi_0 pypi
zipp 3.15.0 pypi_0 pypi

about my system and GPU card

Système d’exploitation
-----> Windows 10 Famille 64-bit
Intel Core i7 8750H @ 2.20GHz
16,0 Go Canal-Simple Inconnu @ 1330 MHz (19-19-19-43)
Carte mère
Intel UHD Graphics 630 (ASUStek Computer Inc)
----> NVIDIA GeForce GTX 1050 (ASUStek Computer Inc)

about the list of programs required for tensorflow install

Anaconda3 2023.03-1 (Python 3.10.9 64-bit) Anaconda, Inc. 2023.03-1
Microsoft ASP.NET Core 6.0.13 - Shared Framework (x64) Microsoft Corporation
Microsoft Update Health Tools Microsoft Corporation
Microsoft Visual C++ 2005 Redistributable Microsoft Corporation 8.0.56336
Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.17 Microsoft Corporation 9.0.30729
Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.6161 Microsoft Corporation 9.0.30729.6161
Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161 Microsoft Corporation 9.0.30729.6161
Microsoft Visual C++ 2010 x64 Redistributable - 10.0.40219 Microsoft Corporation 10.0.40219
Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219 Microsoft Corporation 10.0.40219
Microsoft Visual C++ 2012 Redistributable (x64) - 11.0.61030 Microsoft Corporation 11.0.61030.0
Microsoft Visual C++ 2012 Redistributable (x86) - 11.0.61030 Microsoft Corporation 11.0.61030.0
Microsoft Visual C++ 2013 Redistributable (x64) - 12.0.30501 Microsoft Corporation 12.0.30501.0
Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.30501 Microsoft Corporation 12.0.30501.0
Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.36.32532 Microsoft Corporation 14.36.32532.0
Microsoft Visual C++ 2015-2022 Redistributable (x86) - 14.36.32532 Microsoft Corporation 14.36.32532.0
Microsoft Windows Desktop Runtime - 6.0.13 (x64) Microsoft Corporation
NVIDIA Control Panel NVIDIA Corp. 8.1.964.0
NVIDIA CUDA Development 11.2 NVIDIA Corporation 11.2
NVIDIA CUDA Documentation 11.2 NVIDIA Corporation 11.2
NVIDIA CUDA Nsight NVTX 11.2 NVIDIA Corporation 11.2
NVIDIA CUDA Runtime 11.2 NVIDIA Corporation 11.2
NVIDIA CUDA Samples 11.2 NVIDIA Corporation 11.2
NVIDIA CUDA Visual Studio Integration 11.2 NVIDIA Corporation 11.2
NVIDIA GeForce Experience NVIDIA Corporation
NVIDIA Logiciel système PhysX 9.21.0713 NVIDIA Corporation 9.21.0713
NVIDIA Nsight Compute 2020.3.0 NVIDIA Corporation
NVIDIA Nsight Systems 2020.4.3 NVIDIA Corporation
NVIDIA Nsight Visual Studio Edition 2020.3.0.20315 NVIDIA Corporation
NVIDIA Pilote graphique 531.61 NVIDIA Corporation 531.61
NVIDIA Tools Extension SDK (NVTX) - 64 bit NVIDIA Corporation
PyCharm Community Edition 2022.2.3 JetBrains s.r.o. 222.4345.23
Python 3.10.11 (64-bit) Python Software Foundation 3.10.11150.0
Python Launcher Python Software Foundation 3.10.11150.0
Shared Add-in Support Update for Microsoft .NET Framework 2.0 (KB908002) Microsoft 1.0.0
Webp Image Extensions Microsoft Corporation 1.0.52351.0
Windows Print
Windows SDK AddOn Microsoft Corporation

about jupyter notebook

Server Information:

You are using Jupyter Notebook.

The version of the notebook server is: 6.5.2
The server is running on this version of Python:

Python 3.10.9 | packaged by Anaconda, Inc. | (main, Mar 1 2023, 18:18:15) [MSC v.1916 64 bit (AMD64)]

Current Kernel Information:

Python 3.9.0 (default, Nov 15 2020, 08:30:55) [MSC v.1916 64 bit (AMD64)] Type ‘copyright’, ‘credits’ or ‘license’ for more information IPython 7.34.0 – An enhanced Interactive Python. Type ‘?’ for help.

about nvidia cuda confirmation and cmd windows

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Nov_30_19:15:10_Pacific_Standard_Time_2020
Cuda compilation tools, release 11.2, V11.2.67
Build cuda_11.2.r11.2/compiler.29373293_0

Hi @dvd

Welcome to the Tensorflow Forum!

It seems the installed Python version and the Tensorflow version are not compatible to each other which could be the reason for this issue. Python 3.10 supports Tensorflow >=2.8 as mentioned in this tested build configuration.

Could you please try again by creating a new Tensorflow environment? You can refer to this TF install page and follow the step by step instructions given in the link.


Please make sure to install Tensorflow <=2.10 because TensorFlow 2.10 was the last TensorFlow release that supported GPU on native-Windows. Starting with TensorFlow 2.11 , you will need to install TensorFlow in WSL2 or install tensorflow or tensorflow-cpu and, optionally, try the TensorFlow-DirectML-Plugin

Let us know if the issue still persists. Thank you.

Hello Renu_Patel, thanks a lot for answering me, and i apologize for writing so late.

Indeed, i had to update tensorflow, it works with the version 2.12 with python 3.9.0. I don’t think this configuration allows to detect my gpu card with windows, but at least, i was in measure to call my CNN models and execute my cells, so…

i will test with pleasure your solutions when i will finish my distance training in data science field; the time is missing me for the projects for now.

Thanks a lot for your solutions,