Witko / nvidia-xrun

Utility to run separate X with discrete nvidia graphics with full performance
GNU General Public License v2.0
488 stars 69 forks source link

Implement USE_BBSWITCH option #137

Open MicroDroid opened 5 years ago

MicroDroid commented 5 years ago

On my system, both methods crash and do not turn off GPU correctly (it stays on, despite being not even visible in lspci). Other times it even causes tee to become a zombie process using 100% of CPU forever, making me have to restart my entire machine.

After some trial and error, bbswitch seemed to be the only stable and working solution. The turn_off_gpu.sh script bundled with acpid didn't work either.

Thus, I implemented this feature and tested it on my machine, so far it works flawlessly without issues.

ghost commented 5 years ago

I would very much like this and I have adjusted my setup to use bbswitch (turning off any included powersave features) because the bbswitch method allows me to have my intel x server, switch to another tty, bbswitch ON the card and use it, bbswitch OFF and return to first tty like nothing happened.

With the included method, the card sometimes comes up on its own (maybe the system does a PCI rescan) and also there is no way to check if the card is off.

Of note is the fact that there is no need for nvidia-xrun to run anything with bbswitch on startup (like the systemd service it has right now). You can set the bbswitch module to load on boot by itself and turn the card off.

On Arch you can do this wih 2 files: /etc/modules-load.d/bbswitch.conf (load bbswitch on startup)

bbswitch

and /etc/modprobe.d/bbswitch.conf: (turn off the card on load)

options bbswitch load_state=0
MicroDroid commented 5 years ago

@JpegXguy nvidia-xrun is designed specifically to be used in another tty, so no, bbswitch is mandatory for that.

That said, I also had the auto power on issue, it turned out to happen when I unplug my laptop, removing laptop-mode-tools did fix that.

I still eventually had to use bbswitch though due to the said zombie process issue.

osleg commented 5 years ago

Oh lol I just did the same in #139 -_-

MicroDroid commented 5 years ago

Funny how the implementation is the same too lol

ghost commented 5 years ago

@JpegXguy nvidia-xrun is designed specifically to be used in another tty, so no, bbswitch is mandatory for that.

That said, I also had the auto power on issue, it turned out to happen when I unplug my laptop, removing laptop-mode-tools did fix that.

I still eventually had to use bbswitch though due to the said zombie process issue.

Your implementation is fine, and what I'd be using if it got merged. My previous comment was about the handy reality that we wouldn't need a systemd service at boot to turn off the card, like the one used right now by nvidia-xrun

MicroDroid commented 5 years ago

@JpegXguy ah yeah that's right. Though relevant to your issues I'm also having a problem where GPU fails to unload modules unless I close all other running sessions. So running in a tty would end up failing to unload modules unless I am signed out of other sessions.

Not sure if you had that issue

MicroDroid commented 5 years ago

Something makes me think gdm or something is locking the modules as soon as they are loaded

osleg commented 5 years ago

per my observation it happens only if you try to switch to running session when you have nvidia-xrun running. Though I didn't test it throughly and it might require more testing.

On Thu, 24 Oct 2019, 12:49 Yousef Sultan, notifications@github.com wrote:

Something makes me think gdm or something is locking the modules as soon as they are loaded

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Witko/nvidia-xrun/pull/137?email_source=notifications&email_token=AABSW2MNRLR3373ZTPMIKPDQQFVSDA5CNFSM4JBMRAE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECEN2KY#issuecomment-545840427, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABSW2L24WPK357GHKRAHF3QQFVSDANCNFSM4JBMRAEQ .

ghost commented 5 years ago

@JpegXguy ah yeah that's right. Though relevant to your issues I'm also having a problem where GPU fails to unload modules unless I close all other running sessions. So running in a tty would end up failing to unload modules unless I am signed out of other sessions.

Not sure if you had that issue

I had this when I tried using nouveau for the powermanagement. Currently I switch to another tty, bbswitch on and do my job. Then bbswitch off. Never switch back to the tty with the other Xserver before the nvidia session ends. Seems like X doesn't notice the card if I do that.

MicroDroid commented 5 years ago

Ahh yes, you both were right! I'll make another PR to put this in README as well