You are not logged in.

#1 2022-08-24 17:41:11

an4rki_
Member
Registered: 2022-08-16
Posts: 50

[SOLVED] Switching GPUs optimus-manager.

I am running Arch (not using any display manager) on a optimus laptop and decided to use optimus-manager to manage my NVIDIA card and the iGPU.
According to this guide, I have installed the optimus-manager package from AUR and set dynamic_power_management=fine in the config file to enable Runtime D3 power management (link).

After doing all this, I rebooted and checked if the optimus-manager service was enabled and it was, so I ran optimus-manager --switch hybrid and I got the following error message:

[an4rki@zangetsu ~]$ optimus-manager --switch hybrid
ERROR: a GPU setup was initiated but Xorg post-start hook did not run.
Log at /var/log/optimus-manager/switch/switch-20220824T224102.log
If your login manager is GDM, make sure to follow those instructions:
https://github.com/Askannz/optimus-manager#important--gnome-and-gdm-users
If your display manager is neither GDM, SDDM nor LightDM, or if you don't us
ki:
https://github.com/Askannz/optimus-manager/wiki/FAQ,-common-issues,-troubles
Cannot execute command because of previous errors.

So I went to the FAQ section. And as I thought, I was missing something, I have to run /usr/bin/prime-offload after starting the X server and run /usr/bin/prime-switch as root after it has stopped.

So my question is where do I add these two run commands, in .bash_profile or .xinitrc? And how do I run the second command as root? for e.g.- add sudo ./usr/bin/prime-switch in the file, then how am I supposed to supply my password?

Thanks.

Last edited by an4rki_ (2022-08-25 07:28:18)


"A computer is like air conditioning - it becomes useless when you open Windows." - Linus Torvalds
Arch + DWM

Offline

#2 2022-08-24 19:34:33

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,527

Re: [SOLVED] Switching GPUs optimus-manager.

/usr/bin/prime-offload in your ~/.xinitrc
You could run /usr/bin/prime-switch in https://wiki.archlinux.org/title/Xinit#xserverrc
Don't "exec" /usr/bin/Xorg (otherwise the script will end there) and configure your sudoers to NOPASSWD for that command and your user.

Offline

#3 2022-08-25 06:02:37

an4rki_
Member
Registered: 2022-08-16
Posts: 50

Re: [SOLVED] Switching GPUs optimus-manager.

seth wrote:

/usr/bin/prime-offload in your ~/.xinitrc
You could run /usr/bin/prime-switch in https://wiki.archlinux.org/title/Xinit#xserverrc
Don't "exec" /usr/bin/Xorg (otherwise the script will end there) and configure your sudoers to NOPASSWD for that command and your user.

After adding my .xinitrc looks like this:

/usr/bin/prime-offload &
slstatus &
exec dwm

And this is my .xserverrc:

sudo /usr/bin/prime-switch

I configured my sudoers file to run /usr/bin/prime-switch as root with no password and finally I rebooted. Immediately after logging back in I got the following message:

Arch Linux 5.19.3-arch-1 (tty1)

zangetsu login: an4rki
password:
Last login: Thu Aug 25 11:14:29 on tty1

xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
-bash: ./usr/bin/prime-offload: No such file or directory
[an4rki@zangetsu ~]$_


"A computer is like air conditioning - it becomes useless when you open Windows." - Linus Torvalds
Arch + DWM

Offline

#4 2022-08-25 06:20:52

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,527

Re: [SOLVED] Switching GPUs optimus-manager.

You should probably not fork /usr/bin/prime-offload and you completely shredded your xserverc.
You shall not "exec" /usr/bin/Xorg, but you still have to run it first (and /usr/bin/prime-offload afterwards)

Also it kinda looks like you typo'd "./usr/bin/prime-offload" (nb the leading dot)?

Edit: also your xinitrc is broken, see the last link below and pay attention to the note on what at least to include.

Last edited by seth (2022-08-25 06:37:37)

Offline

#5 2022-08-25 06:49:42

an4rki_
Member
Registered: 2022-08-16
Posts: 50

Re: [SOLVED] Switching GPUs optimus-manager.

seth wrote:

You should probably not fork /usr/bin/prime-offload and you completely shredded your xserverc.
You shall not "exec" /usr/bin/Xorg, but you still have to run it first (and /usr/bin/prime-offload afterwards)

Also it kinda looks like you typo'd "./usr/bin/prime-offload" (nb the leading dot)?

Actually, I am not able to understand what you are trying to say here. What do you mean by "fork"? And by shredding, do you mean that I completely deleted everything in there? I created a new xserverrc in ~/.xserverrc and added only the single sudo /usr/bin/prime-switch command in it. Should I just add this command in /etc/X11/xinit/xserverrc ? So after adding it should look like this:

#!/bin/sh
sudo /usr/bin/prime-swtich &
exec usr/bin/X -nolisten tcp "$@"

And I rechecked the error message and there is no typo. The leading dot is there in the message. And thanks for the quick reply.


"A computer is like air conditioning - it becomes useless when you open Windows." - Linus Torvalds
Arch + DWM

Offline

#6 2022-08-25 07:04:12

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,527

Re: [SOLVED] Switching GPUs optimus-manager.

The "&" forks the command, ie. runs it in the background.

So after adding it should look like this:

No.

#!/bin/sh
/usr/bin/X -nolisten tcp "$@" # not "exec" this, and there needs to be a leading "/"
sudo /usr/bin/prime-swtich # run this afterwards and don't mindlessly append "&" to lines

Better post your xinitrc as well.

Offline

#7 2022-08-25 07:14:10

an4rki_
Member
Registered: 2022-08-16
Posts: 50

Re: [SOLVED] Switching GPUs optimus-manager.

seth wrote:

The "&" forks the command, ie. runs it in the background.

So after adding it should look like this:

No.

#!/bin/sh
/usr/bin/X -nolisten tcp "$@" # not "exec" this, and there needs to be a leading "/"
sudo /usr/bin/prime-swtich # run this afterwards and don't mindlessly append "&" to lines

Better post your xinitrc as well.


Here's both the files after making changes:

.xinitrc

#optimus-manager
/usr/bin/prime-offload

#Other
slstatus &
exec dwm

/etc/X11/xinit/xserverrc

#!/bin/sh
/usr/bin/X -nolisten tcp "$@"
sudo /usr/bin/prime-switch      #optimus-manager

"A computer is like air conditioning - it becomes useless when you open Windows." - Linus Torvalds
Arch + DWM

Offline

#8 2022-08-25 07:24:24

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,527

Re: [SOLVED] Switching GPUs optimus-manager.

seth wrote:

your xinitrc is broken, see the last link below and pay attention to the note on what at least to include

And consider adding the "vt$XDG_VTNR" to your xserverrc (see the wiki again on why)

Offline

#9 2022-08-25 07:27:50

an4rki_
Member
Registered: 2022-08-16
Posts: 50

Re: [SOLVED] Switching GPUs optimus-manager.

Thanks, the issue has been solved and I also added vt$XDG_VTNR in xserverrc.


"A computer is like air conditioning - it becomes useless when you open Windows." - Linus Torvalds
Arch + DWM

Offline

Board footer

Powered by FluxBB