Optimus-manager wont work

Hi!
I had a working system where the switching between the iGPU and dGPU worked well.
Unfortunately I had to reinstall my system and the switching wont work.
Here is some info about my system:

$ lspci | grep -E "VGA|3D"
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics (rev 05)
01:00.0 3D controller: NVIDIA Corporation TU117M (rev a1)

$ mhwd -li
> Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
video-hybrid-intel-nvidia-prime            2020.11.30               false            PCI
           video-linux            2018.05.04                true            PCI
     video-modesetting            2020.01.13                true            PCI


Warning: No installed USB configs!

$ inxi -G
Graphics:  Device-1: Intel UHD Graphics driver: i915 v: kernel 
           Device-2: NVIDIA TU117M driver: N/A 
           Display: x11 server: X.Org 1.20.11 driver: loaded: modesetting resolution: 1920x1200~60Hz 
           OpenGL: renderer: Mesa Intel UHD Graphics (CML GT2) v: 4.6 Mesa 21.0.2 

How should fix it?

What’s the output of lspci -d 10de: -nn -k and sudo dmesg | grep -i nvidia?

$ lspci -d 10de: -nn -k
01:00.0 3D controller [0302]: NVIDIA Corporation TU117M [10de:1f99] (rev ff)
	Kernel modules: nouveau, nvidia_drm, nvidia

$ dmesg | grep -i nvidia
dmesg: read kernel buffer failed: Operation not permitted

Please run it with sudo as it was in my comment.

With sudo the output is nothing.
Now the X wont start. I must to send the startx command to get the X environment.

If a command outputs nothing, that’s also valuable information, so please post “nothing” in that case. Please run nvidia-modprobe, then sudo dmesg | grep -i nvidia again, and post the output.

nvidia-modprobe also gives nothing (with sudo).

Did you run sudo dmesg | grep -i nvidia after that? What was its output?

nvidia-modprobe and sudo dmesg | grep -i nvidia both of them gives nothing.

Okay, now what’s the output of lspci -d 10de: -nn -k?

$ lspci -d 10de: -nn -k
01:00.0 3D controller [0302]: NVIDIA Corporation TU117M [10de:1f99] (rev ff)
	Kernel modules: nouveau, nvidia_drm, nvidia

Anybody with advise that could make progress?

What’s the output of echo "0000:01:00.0" | sudo tee /sys/bus/pci/drivers/nvidia/bind?

I can answer at the evening.

tee: /sys/bus/pci/drivers/nvidia/bind: No such file or directory
0000:01:00.0

What’s the output of sudo modprobe nvidia && lsmod | grep nvidia?

nvidia              34181120  0

Now what’s the output of the above?

0000:01:00.0
tee: /sys/bus/pci/drivers/nvidia/bind: No such device

Do i need to do a fresh install?