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.

Must restart system to switch to nvidia

See original GitHub issue

Describe the bug Can switch to nvidia driver if I set it as startup. Can switch back to intel and relogin to apply. Cannot switch to nvidia unless a full restart is applied. No error trying to switch to nvidia in session, but it just doesn’t switch. Modprobe error in the gpu_setup.log below.

System info

  • Arch 5.4.15-arch1-1
  • KDE
  • Dell G3, nvidia 1050M GTX
  • latest Git version (optimus-manager-git)

Logs boot_setup.log gpu_setup.log prime_setup.log

pacman -Q | grep nvidia
nvidia 440.44-15
nvidia-utils 440.44-3
[root@xonq /]# lsmod | grep "kms\|drm"
nvidia_drm             49152  5
nvidia_modeset       1118208  7 nvidia_drm
drm_kms_helper        212992  2 nvidia_drm,i915
drm                   520192  9 drm_kms_helper,nvidia_drm,i915
agpgart                53248  2 intel_gtt,drm
syscopyarea            16384  1 drm_kms_helper
sysfillrect            16384  1 drm_kms_helper
sysimgblt              16384  1 drm_kms_helper
fb_sys_fops            16384  1 drm_kms_helper
[root@xonq modprobe.d]# grep LoadModule /var/log/Xorg.0.log
[     8.725] (II) LoadModule: "glx"
[     8.741] (II) LoadModule: "nvidia"
[     8.751] (II) LoadModule: "modesetting"
[     8.758] (II) LoadModule: "fb"
[     8.760] (II) LoadModule: "wfb"
[     8.761] (II) LoadModule: "ramdac"
[     8.774] (II) LoadModule: "glxserver_nvidia"
[     8.914] (II) LoadModule: "glamoregl"
[     9.165] (II) LoadModule: "fb"
[     9.244] (II) LoadModule: "dri2"
[     9.746] (II) LoadModule: "libinput"

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
ahegazycommented, May 12, 2020

Figured out the problem as per the FAQ you have to

I do not use a display manager (I use startx or xinit) Just like above, you must make sure to run /usr/bin/prime-offload (as normal user) just after the X > server is started, and /usr/bin/prime-switch (as root) after it has stopped.

so prime-switch needed to run as root after every Xserver exit, without display manager you have to make it run manually to make the switch,

Auto

  • In the ~/.xinitrc you run your window manager for example exec i3 replace it with only i3
  • Edit the /etc/sudoers adding this line YourUserName ALL = NOPASSWD: /usr/bin/prime-switch to prevent it from requiring a password when writing sudo /usr/bin/prine-switch
  • after the window manager running command write your sudo /usr/bin/prime-switch Then end of the .xinitrc will be
i3
sudo /usr/bin/prime-switch

-that’s it

Problem with this

  • when switching from nvidia to intel, we run prime-switch before the xserver is fully killed so this error is produced Setting up base state Unloading modules ['nvidia_drm', 'nvidia_modeset', 'nvidia'] (if loaded) Cannot setup GPU : kernel setup error : Cannot unload modules ['nvidia_drm', 'nvidia_modeset', 'nvidia'] : Failed to execute 'modprobe -r nvidia_drm nvidia_modeset nvidia' : modprobe: FATAL: Module nvidia_drm is in use.

soultion

  • Instead of making it run at the end of xserver, run it before running xserver
  • So i have my .bash_profile having the startx command
  • before it add sudo /usr/bin/prine-switch
  • so my .bash_profile is
#
# ~/.bash_profile
#
[[ -f ~/.bashrc ]] && . ~/.bashrc

if systemctl -q is-active graphical.target && [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]];
then 
    sudo /usr/bin/prime-switch
    exec startx
fi

Manually

  • add this option to optimus-manager.conf auto_logout=no
  • this prevents auto logout when switching, so after the switch command, run /usr/bin/prime-switch as root
1reaction
khuedoancommented, Jun 10, 2020

Thanks @ahegazy, your solution works great!

Also if anyone using sudo with password like me, you can add this line to /etc/sudoers with visudo to allow the sudo /usr/bin/prime-switch command to run without a password:

%wheel ALL=(ALL) NOPASSWD: /usr/bin/prime-switch
Read more comments on GitHub >

github_iconTop Results From Across the Web

NVIDIA installer cannot continue, a system restart is required ...
This is for those of us who are struggling to get the installer to work as it simply wont work but restarting the...
Read more >
PC Automatically Restart and turn off after NVIDIA Driver ...
After i update my NVIDIA Drivers from 419.67 to 425.31, my PC Suddenly restart or even turn off automatically without any warning, BSOD,...
Read more >
Manage 3D Settings (reference) - NVIDIA
To allow the "Preferred Graphics Processor" settings to take effect, you must restart the program. Restore button (bottom corner) restores the default ...
Read more >
How to Reset a Graphics Card on Windows - groovyPost
To restart your graphics card, press the Windows key + Ctrl + Shift + B combination on your keyboard. Your screen will briefly...
Read more >
"Something went wrong. Try restarting GeForce Experience ...
Press the Windows Key on your keyboard. · Type “msconfig” (no quotes), then hit Enter. The System Configuration window should come up. ·...
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