[Solved] error: Raw kernel process exited code: 3221226505

1. Error Description:

After installing CUDA, when using jupyter notebook in Visual Studio code, whether using TensorFlow or PyTorch, an error will be reported when the model-related code is involved:

info 10:44:12.758: kill daemon
error 10:44:12.758: Raw kernel process exited code: 3221226505
error 10:44:12.768: Error in waiting for cell to complete [Error: Canceled future for execute_request message before replies were done
	at t.KernelShellFutureHandler.dispose (c:\Users\Eddie\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:2:32353)
	at c:\Users\Eddie\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:2:51405
	at Map.forEach (<anonymous>)
	at y._clearKernelState (c:\Users\Eddie\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:2:51390)
	at y.dispose (c:\Users\Eddie\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:2:44872)
	at c:\Users\Eddie\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:24:251157
	at t.swallowExceptions (c:\Users\Eddie\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:29:120529)
	at dispose (c:\Users\Eddie\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:24:251135)
	at t.RawSession.dispose (c:\Users\Eddie\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:24:256072)
	at processTicksAndRejections (node:internal/process/task_queues:96:5)]
warn 10:44:12.771: Cell completed with errors {
  message: 'Canceled future for execute_request message before replies were done'
}

(1) Remind

Looking at the previous text of error in the log, CUDA and cuDNN can be adjusted.

warn 10:44:12.276: StdErr from Kernel Process 2022-07-27 10:44:12.27561
warn 10:44:12.276: StdErr from Kernel Process 7: I tensorflow/stream_executor/cuda/cuda_dnn.cc:384]
warn 10:44:12.277: StdErr from Kernel Process  Loaded cuDNN version 8401

error 10:44:12.756: Disposing session as kernel process died ExitCode: 3221226505, Reason: c:\Users\Eddie\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\traitlets.py:2392: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
  warn(
c:\Users\Eddie\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\traitlets.py:2346: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '59483b09-e83e-4bf0-a9b6-82301995d744' instead of 'b"59483b09-e83e-4bf0-a9b6-82301995d744"'.
  warn(
2022-07-27 10:44:06.428210: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-07-27 10:44:07.682221: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1532] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 1335 MB memory:  -> device: 0, name: NVIDIA GeForce MX150, pci bus id: 0000:01:00.0, compute capability: 6.1
2022-07-27 10:44:12.275617: I tensorflow/stream_executor/cuda/cuda_dnn.cc:384] Loaded cuDNN version 8401

Look carefully at the contents of error. It seems that the error is in jupyter, but it is not.

error 10:44:12.768: Error in waiting for cell to complete [Error: Canceled future for execute_request message before replies were done
	at t.KernelShellFutureHandler.dispose (c:\Users\Eddie\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:2:32353)
	at c:\Users\Eddie\.vscode\extensions\ms-toolsai.jupyter-2022.6.1201981810\out\extension.node.js:2:51405

2. Solution:

(1) Use the browser to run jupyter to check the errors (it is recommended to skip)

It is recommended to skip this step! The explanation here is only to record the complete error resolution steps.

Use the command to install jupyter,

pip install jupyter

Open the .ipynb file in the browser and run it again. The error is different from that in Visual Studio Code:

Could not locate zlibwapi.dll

(2) Install Zlib

Install Zlib as this tutorial. the error will be solved!

Read More: