Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot restart kernel after kernel dies #7167

Closed
leiterenato opened this issue Aug 17, 2021 · 17 comments
Closed

Cannot restart kernel after kernel dies #7167

leiterenato opened this issue Aug 17, 2021 · 17 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel) verified Verification succeeded

Comments

@leiterenato
Copy link

Environment data

  • VS Code version: Version: 1.59.0
    Commit: 379476f0e13988d90fab105c5c19e7abc8b1dea8
    Date: 2021-08-04T23:14:40.191Z (1 wk ago)
    Electron: 13.1.7
    Chrome: 91.0.4472.124
    Node.js: 14.16.0
    V8: 9.1.269.36-electron.0
    OS: Darwin x64 20.6.0

  • Jupyter Extension version (available under the Extensions sidebar): v2021.8.1195043623

  • Python Extension version (available under the Extensions sidebar): v2021.8.1105858891

  • OS (Windows | Mac | Linux distro) and version: MacOS 11.5.1

  • Python and/or Anaconda version: Python 3.9.5 (also tested with 3.9.6, 3.8.10 and 3.7 - same issue)

  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): tested with conda and venv

  • Jupyter server running: The problem happens both locally and in a remote setup (remote VM)

Expected behaviour

I need to restart my kernel after a pip install.
I need to execute the following code and restart my kernel, without loosing connectivity to it.

import IPython  
app = IPython.Application.instance()  
app.kernel.do_shutdown(True) 

Actual behaviour

After executing the app.kernel.do_shutdown(True) I receive the following message:

Error: Session cannot generate requests
Error: Session cannot generate requests
at w.executeCodeCell (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:325139)
at w.execute (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:324460)
at w.start (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:320276)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async t.CellExecutionQueue.executeQueuedCells (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:334803)
at async t.CellExecutionQueue.start (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:334343)

If I restart the kernel using the "Restart" button from the UI interface, I still receive the same message.
I can only get my environment running again if I select another kernel and then select the original kernel again.

Steps to reproduce:

  1. Create an empty notebook and open in VScode (with the extension enabled).
  2. Enable the kernel
  3. On the first cell type a print('Hello World') to make sure it is working
  4. On the second cell execute the following code:
import IPython  
app = IPython.Application.instance()  
app.kernel.do_shutdown(True) 
  1. Include a new cell with a print('Hello world') to see the error message.

Logs

Please see the attached files.
kernel_restart_OK.txt
cell_exec_FAIL.txt
requirements.txt

@leiterenato leiterenato added the bug Issue identified by VS Code Team member as probable bug label Aug 17, 2021
@leiterenato
Copy link
Author

Follows a quick video to demonstrate this behavior.
https://user-images.githubusercontent.com/277946/129734512-1d72332a-c926-4e21-b79c-ddf3468af401.mov

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Aug 17, 2021

Thanks for filling this issue, I'm and to replicate this at my end.

@leiterenato
Copy link
Author

Thank you. Let me know if you need more information.

@DonJayamanne
Copy link
Contributor

As a temporary work around, you can close the notebook and re-open it, that will work.
I'll have a fix before the end of this week for you in VS Code Insiders (hope you can use VS Code insiders until this goes into stable)?

@leiterenato
Copy link
Author

That's great! Thank you very much,
Cheers

@greazer greazer added notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel) and removed needs-triage labels Aug 19, 2021
@greazer greazer added this to the August 2021 milestone Aug 19, 2021
@ThGouzias
Copy link

Hi, I am facing the same issue. Even if I close and re-open the notebook, the error message appears again at the same cell.

Some thoughts: I think what causes the issues is that I am trying to process a large amount of data. When running the same code but with subsets of my dataset, it works normally.

Are there any solutions yet?

@DonJayamanne
Copy link
Contributor

Sorry I wasn't able to get to this, but will be looking into fixing this soon.

@ThGouzias
Copy link

No worries at all. Thanks for taking the time to answer!

@momvart
Copy link

momvart commented Sep 5, 2021

I'm not sure this is the same problem or not. I get this error when some error happens in my code and instead of reporting the stack trace, the cell finishes successfully. But I'm not able to run any cell afterward and get the message included above.

@DonJayamanne
Copy link
Contributor

@momt99

Please could you file a separate issue. looks like you have some code in the cell that's causing the kernel to crash/die.

@DonJayamanne
Copy link
Contributor

Closing this issue as this has been fixed, and the fix is now avaialble in the insiders version of the extension (install VS Code insiders to get the insider version of the extesnion).

@IvanPalm
Copy link

IvanPalm commented Sep 8, 2021

@DonJayamanne
I had stumbled across the issue filed here so I got the latest version to overcome it.
I'm now using VS Code Insiders 1.61.0-insiders with Jupyter v2021.9.1001208778 on Ubuntu 20.04, and the error Kernel is dead occurs. Shall I open a separate issue to file this or are you already aware of it?

Thank you for the great work!

Screenshot from 2021-09-08 09-18-26

@DonJayamanne
Copy link
Contributor

@IvanPalm
Play could you file a new issues with sample code that causes the kernel to crash. This issue addresses restarting the kernel after it has died.

@DonJayamanne DonJayamanne changed the title Kernel session cannot generate requests after Kernel restart from cell (IPython.Application.instance().kernel.do_shutdown(True)) Cannot restart kernel after kernel dies Sep 8, 2021
@IvanPalm
Copy link

IvanPalm commented Sep 9, 2021

I just got back to the matter to file the issue but I could not replicate the error.
I tested on Code Insiders 1.61.0-insiders with Jupyter v2021.9.1001216636, v2021.9.1001208778 as well as on Code 1.60.0 with Jupyter v2021.8.2041215044. The outcome is the same I got when I landed to this conversation: Error: Session cannot generate requests. I will test also with other codes and file a new issue if the error occurs also there.

@Wang-Chbo
Copy link

Wang-Chbo commented Sep 10, 2021

I have the same issue.
If I run the code with Jupyter v2021.8.2041215044,when I run this demo(https://tensorflow.google.cn/text/tutorials/transformer?hl=zh_cn), Error: Session cannot generate requests will rise.
So I use an old version Jupyter, and this issue will disappear

@DonJayamanne
Copy link
Contributor

@Wang-Chbo
Part could you file a separate issue, with the os, python version & other information including the sample code you have mentioned. Oh yes, please do included the logs as well.

@microsoft microsoft locked as resolved and limited conversation to collaborators Sep 10, 2021
@greazer greazer added the verified Verification succeeded label Sep 29, 2021
@greazer
Copy link
Member

greazer commented Sep 29, 2021

I was able to restart a kernel after it had died. Both from the original repro as well as from a separate one that killed the kernel externally.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel) verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

8 participants