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

High GPU usage in Python Interactive #2878

Closed
stmax82 opened this issue Oct 17, 2019 · 11 comments
Closed

High GPU usage in Python Interactive #2878

stmax82 opened this issue Oct 17, 2019 · 11 comments
Assignees

Comments

@stmax82
Copy link

stmax82 commented Oct 17, 2019

Running the following piece of code in Python Interactive:

image

Results in >10% usage of my GPU (GTX 980 Ti):

image

(I haven't measured the impact, but I'd rather let pytorch use these 10% while the training loop is running...)

Other windows, like the terminal or even heavy scrolling in the code editor do not cause high GPU usage - for example heavily scrolling in the code window results in 1-2% GPU usage.. note that the code snippet above creates only 1 output per second, yet causes 10%.

Your Jupyter and/or Python environment

Please provide as much info as you readily know

  • Extension version: 2019.10.41019
  • VS Code version: 1.38
  • Setting python.jediEnabled: ?
  • Python and/or Anaconda version: 3.6.8
  • OS: Windows 10 1903
  • Virtual environment: conda base env
@rchiodo
Copy link
Contributor

rchiodo commented Oct 17, 2019

I would hazard a guess that a jupyter notebook would have the same GPU usage. You're updating a UI ever millisecond.

@stmax82
Copy link
Author

stmax82 commented Oct 17, 2019

@rchiodo time.sleep takes seconds.. not milliseconds. :/

@rchiodo
Copy link
Contributor

rchiodo commented Oct 17, 2019

This might be the problem we have of updating the rendering of every update. You can try the insider's build to see if it's any better as we addressed some UI update problems.

@rchiodo
Copy link
Contributor

rchiodo commented Oct 17, 2019

I'm not seeing any such GPU usage on my own machine though. Maybe Electron isn't GPU accelerated on my machine though.

You can disable it yourself I believe based on this issue here:
microsoft/vscode#52096

@stmax82
Copy link
Author

stmax82 commented Oct 17, 2019

@rchiodo I tried this at home now with a GTX 1070.. for some reason it's even worse here - GPU usage goes up to 30% when VS Code starts printing in the interactive window. As soon as I close the interactive window, it goes back down to almost 0%.

Here's a screenshot with GPU-Z, which shows some more details:

image

I also tried to disable GPU acceleration (just run code --disable-gpu). It helps, but now VS Code uses 15% CPU while printing 1 line per second...

image

@rchiodo
Copy link
Contributor

rchiodo commented Oct 17, 2019

Were you able to try the insider's build? It should eliminate some of our rendering.

Although that GPU usage may just be the progress bar across the top. It's certainly continually rendering, so any render fixes won't make a difference.

The css for that is here:

.monaco-progress-container.infinite .progress-bit {
	animation-name: progress;
	animation-duration: 4s;
	animation-iteration-count: infinite;
	animation-timing-function: linear;
	-ms-animation-name: progress;
	-ms-animation-duration: 4s;
	-ms-animation-iteration-count: infinite;
	-ms-animation-timing-function: linear;
	-webkit-animation-name: progress;
	-webkit-animation-duration: 4s;
	-webkit-animation-iteration-count: infinite;
	-webkit-animation-timing-function: linear;
	-moz-animation-name: progress;
	-moz-animation-duration: 4s;
	-moz-animation-iteration-count: infinite;
	-moz-animation-timing-function: linear;
	will-change: transform;
}

I put that into a jsfiddle. That should repro your GPU usage:
https://jsfiddle.net/6zfm9s5p/

@rchiodo
Copy link
Contributor

rchiodo commented Oct 17, 2019

Yeah that repros it for me in chrome. I guess we could have a setting that disables all animations.

@stmax82
Copy link
Author

stmax82 commented Oct 18, 2019

@rchiodo I tried the jsfiddle, it doesn't cause >10% GPU like VS Code does, but 2-4%.. not sure if that's really it?

I tried to enable developer mode in VS Code, find the progress container and hide or completely remove it from the DOM.. but I failed to find it in the DOM (I ended up at some empty iframe). Not sure how that works.

I tried the insiders build (2019.11.42782-dev), but GPU usage is exactly the same as before.

As for disabling all animations - that would be fine for me. But please add some static indicator instead that shows if a cell is still running. Maybe change the color of the "Interrupt IPython Kernel" to gray while no cell is running and red while a cell is running.. or some other icon that tells the user if something is still running.

@greazer
Copy link
Member

greazer commented Oct 18, 2019

Let's only show the cylon when we are performing an operation that is not running a cell. When running a cell we should just use the asterisk.

@rchiodo
Copy link
Contributor

rchiodo commented Oct 28, 2019

After doing some work to address this, part of the problem is this:

image

VS Code puts out a status indicator. On my machine this can be 25 to 30% of the GPU. You can disable this progress message by clicking on the "Progress Message" in the menu.

@IanMatthewHuff IanMatthewHuff self-assigned this Nov 1, 2019
@DavidKutu DavidKutu self-assigned this Nov 1, 2019
@DavidKutu
Copy link

My GPU usage shows around 5% while running that code. Validated

@lock lock bot locked as resolved and limited conversation to collaborators Nov 8, 2019
@microsoft microsoft unlocked this conversation Nov 14, 2020
@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants