question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jupyter over remote ssh sometimes becomes slow and/or unresponsive

See original GitHub issue

Environment data

  • VS Code version: 1.62.3 (Universal)
  • Jupyter Extension version (available under the Extensions sidebar): v2021.10.1101450599
  • Python Extension version (available under the Extensions sidebar): v2021.11.1422169775
  • OS (Windows | Mac | Linux distro) and version: Mac
  • Python and/or Anaconda version: 3.7.12
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Jupyter server running: Remote

Expected behaviour

I expect code cells to begin executing immediately and (for simple code snippets) to finish executing immediately (e.g. print(‘hello’))

Actual behaviour

Once the jupyter notebook starts to contain a non-trivial amount of stuff, I start to observe the following behaviors: (1) code cells that contain simple tasks (e.g. print('hello')) start taking several seconds or more to complete, (2) it may take several seconds or even minutes for vscode to even visually show that it will start executing a code cell, and (3) in severe cases, the whole vscode editor will become unresponsive and I will need to force shut it down.

Steps to reproduce:

Below is code for a jupyter notebook that contains a minimal example. The problems start to appear once you’ve cycled through the code cells 2 or 3 times. I think one of the main contributing factors to this issue are just notebooks that have a lot of “stuff” in them. To demonstrate that, the last code block prints 50 scatter plots as pngs, which the native jupyter lab server over the browser handles just fine… but vscode seems to have issues. Moreover, in this simple example I have observed instances where it starts to take a while to save the notebook and the editor may even become unresponsive.

Other things to note:

  • I am running this jupyter notebook on an AWS EC2 instance with ~90GB memory 48 CPUs (using a AWS linux ami: ami-083ac7c7ecf9bb9b0).
  • I have not yet observed these same issues when I have the kernel running on my local mac machine.
Jupyter example

# %%
# %load_ext autoreload
# %autoreload 2

import pandas as pd
import plotly.express as px
import numpy as np
import plotly.io as pio
pio.renderers.default='jupyterlab+notebook'
pd.set_option("display.max_columns", 20)

# %%
data = pd.DataFrame(np.random.random(size=(1000,1000)))

# %%
data

# %%
print('hello')

# %%
for i in range(50):
    fig = px.scatter(x=data[i], y=data[i+1])
    fig.show(renderer='png')
    

Logs

Here is a screenshot where it takes almost 3 seconds for a simple print statement. I’ve seen worse in some of my code related to real projects, though. This is just what I was able to reproduce with a minimal example.

Screen Shot 2021-11-22 at 4 48 27 PM

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:26
  • Comments:31 (6 by maintainers)

github_iconTop GitHub Comments

10reactions
johnros-pagayacommented, Aug 30, 2022

I also experience the same. I observed that:

  • It happens with Jupyter notebooks, but not in the Interactive window.
  • It does not happen if you connect to a Jupyter kernel that is not managed by VScode.
  • It happens when your notebooks has many figures.

I hope these may help diagnose the problem.

10reactions
NixGDcommented, Jan 8, 2022

Also having this issue with jupyter over ssh, in a notebook that has a decent number of plots.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jupyter notebooks in remote SSH projects render very slow
Jupyter notebooks in PyCharm's remote SSH projects render very slow for me. Scrolling through a notebook that isn't running (connected to a Jupyter...
Read more >
VScode ssh connection breaks when my jupyter notebook ...
Since I have a terrible upload speed it, needing to upload some MB's every time messes with my connection, making everything slow and...
Read more >
Remote Access to IPython Notebooks via SSH - Coderwall
We will do this by opening an SSH tunnel. This tunnel will forward the port used by the remotely running IPython instance to...
Read more >
Jupyter Notebook Setup on a Remote Server Then in Visual ...
I decided to go with the secure localhost configuration and then had to use ssh to forward the remote Notebook listening port to...
Read more >
Access apps like Jupyter notebook remotely using SSH tunnels
With TeamViewer you send the entire picture of the desktop so it can often be unresponsive, especially if you're on a bad connection....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found