# problems setting up hybrid graphics

## Adel Ahmed

I'm using a lenovo b5400 with:

00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06)

01:00.0 3D controller: NVIDIA Corporation GF117M [GeForce 610M/710M/820M / GT 620M/625M/630M/720M] (rev a1)

I have successfully setyp the intel drivers and can start xfce

I have been trying to setup the hybrid graphic rendering to use nvidia's opengl and opencl, I have been using this document:

http://wiki.gentoo.org/wiki/NVIDIA_Driver_with_Optimus_Laptops

and 

http://us.download.nvidia.com/XFree86/Linux-x86_64/331.38/README/randr14.html

I've tried both xorg.conf files, created the .xinitrc but all I get is a black screen, with and without slim(startx manually)

I've installed the nvidia-drivers package; I get this error all the time though:

ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20140424/nsarguments-95)

don't know if this is related

thanks

----------

## Adel Ahmed

here's my /home/adel/.xinitrc:

xrandr --setprovideroutputsource modesetting NVIDIA-0

xrandr --auto

my first xorg.conf:

Section "ServerLayout"

    Identifier "layout"

    Screen 0 "nvidia"

    Inactive "intel"

EndSection

Section "Device"

    Identifier "nvidia"

    Driver "nvidia"

    BusID "PCI:1:0:0"

EndSection

Section "Screen"

    Identifier "nvidia"

    Device "nvidia"

    Option "AllowEmptyInitialConfiguration"

EndSection

Section "Device"

    Identifier "intel"

    Driver "modesetting"

EndSection

Section "Screen"

    Identifier "intel"

    Device "intel"

EndSection

the second one:

http://pastebin.com/zET9E0HY

----------

## Adel Ahmed

I also tried this xorg.conf out

Section "ServerLayout"

    Identifier "layout"

    Screen  0 "nvidia"

    Inactive "intel"

EndSection

Section "Device"

    Identifier "nvidia"

    Driver "nvidia"

    BusID "PCI:1:0:0"

EndSection

Section "Screen"

    Identifier "nvidia"

    Device "nvidia"

    # Uncomment this line if your computer has no display devices connected to

    # the NVIDIA GPU.  Leave it commented if you have display devices

    # connected to the NVIDIA GPU that you would like to use.

    Option "UseDisplayDevice" "none"

EndSection

Section "Device"

    Identifier "intel"

    Driver "modesetting"

    BusID "PCI:0:2:0"

EndSection

Section "Screen"

    Identifier "intel"

    Device "intel"

EndSection

but no dice

----------

## Adel Ahmed

help anyone?

----------

## Adel Ahmed

I'm giving up this method, ill be relying on switcheroo and bumblebee

bumblebee is great, I got 1200 FPs on glx gears instead of 60, I cannot run wine games however; says 32 bit opengl is not installed

I've also tried out nouveau, I'm getting 6k fps at the cost of not seeing the gears themselves  :Very Happy: , I'm working on it at the moment

I'll try nouveau first and then go back to bumble bee

I still need all the help I can get

----------

## Adel Ahmed

I have fixed nouveau rendering by enabling compositing, I'm getting 1500 FPS now, games are running with degraded performance!!!!!

I'll try getting back to nvidia-drivers

----------

## Adel Ahmed

help anyone?

----------

## Yamakuzure

nouveau can not handle 3D acceleration on new(er) cards and falls back to software rendering. Although I guess that your card should be supported.

However, the proprietary driver is much more painless with hybrid laptops.

If you use bumblebee, then try primusrun, too. (x11-misc/primus from the bumblebee overlay)

On my system with nvidia K2100M (quatro) I get:

```
 ~ $ optirun glxspheres64

Polygons in scene: 62464 (61 spheres * 1024 polys/spheres)

Visual ID of window: 0x20

Context is Direct

OpenGL Renderer: Quadro K2100M/PCIe/SSE2

276.954538 frames/sec - 309.081264 Mpixels/sec

282.511501 frames/sec - 315.282835 Mpixels/sec

277.820893 frames/sec - 310.048117 Mpixels/sec

 ~ $ primusrun glxspheres64

Polygons in scene: 62464 (61 spheres * 1024 polys/spheres)

Visual ID of window: 0x20

Context is Direct

OpenGL Renderer: Quadro K2100M/PCIe/SSE2

392.034528 frames/sec - 437.510533 Mpixels/sec

406.329255 frames/sec - 453.463449 Mpixels/sec

399.765486 frames/sec - 446.138282 Mpixels/sec
```

As this is a laptop, I am using the nvidia card only for wine applications, steam apps and vmware workstation when on AC power.

But: If you use primusrun and your application/game uses VBLANK, then primus shouldn't blank, too. In that case (highly degraded performance is an indicator) you should start your game with:

```
 $ vblank_mode=0 primusrun <your game here>
```

I had this with Mass Effect 1. Only ~10 FPS with nvidia and ~40FPS with intel. Now I am on ~60 FPS with nvidia. (Full screen 1920x1080, full details, full effects, anisoptric filtering enabled)

----------

## Adel Ahmed

thanks, I've tried primus application;

primus can indeed run wine games but here's the problem:

$primusrun glxspheres64

Polygons in scene: 62464

Visual ID of window: 0x20

Context is Direct

OpenGL Renderer: GeForce GT 720M/PCIe/SSE2

62.419087 frames/sec - 53.947569 Mpixels/sec

60.007769 frames/sec - 51.863514 Mpixels/sec

$optirun glxspheres64 

Polygons in scene: 62464

Visual ID of window: 0x20

Context is Direct

OpenGL Renderer: GeForce GT 720M/PCIe/SSE2

138.040458 frames/sec - 119.305607 Mpixels/sec

the same applies for game fps

did you have this problem too

----------

## Yamakuzure

No... That's weird. Are you running compiz?

Maybe some of the ideas here can help: Worse performance with nvidia gpu than with integrated intel.

Basically I used the archi linux guide on bumblebee to set up things and went the virtualgl way.

Oh, and I am using only the live ebuilds from the bumblebee overlay:

```
 # eix --installed-from-overlay bumblebee

[I] sys-power/bbswitch

     Available versions:  0.7 0.8 (**)9999[1] {KERNEL="linux"}

     Installed versions:  9999[1](13:15:57 19.11.2014)(KERNEL="linux")

     Homepage:            https://github.com/Bumblebee-Project/bbswitch

     Description:         Toggle discrete NVIDIA Optimus graphics card

[I] x11-misc/bumblebee

     Available versions:  3.2.1 (**)9999[1] {+bbswitch VIDEO_CARDS="nouveau nvidia"}

     Installed versions:  9999[1](09:26:13 18.11.2014)(bbswitch VIDEO_CARDS="nvidia -nouveau")

     Homepage:            http://bumblebee-project.org https://github.com/Bumblebee-Project/Bumblebee

     Description:         Service providing elegant and stable means of managing Optimus graphics chipsets

[I] x11-misc/virtualgl

     Available versions:  2.3.3 **9999[1] (**)9999-r1[1] {ssl ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}

     Installed versions:  9999-r1[1](08:45:52 24.11.2014)(ssl ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32")

     Homepage:            http://www.virtualgl.org/

     Description:         Run OpenGL applications remotely with full 3D hardware acceleration

[I] x11-misc/primus [1]

     Available versions:  (**)9999 {ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}

     Installed versions:  9999(09:26:32 18.11.2014)(ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32")

     Homepage:            https://github.com/amonakov/primus

     Description:         Faster OpenGL offloading for Bumblebee

[1] "bumblebee" /var/lib/layman/bumblebee
```

----------

## Adel Ahmed

Ok I unmerged my original bumblebee in favour of the layman one

the guide helped a little

I was looking at nvidia-config with optirun vs primusrun

optirun gpu utilization is 70%~ while the primusrun gpu utilization is 25% 

at least that gives me a hint on where to look

I appreciate your help, any further help would be even greater

----------

## Adel Ahmed

I still have no idea why  primus run cannot utilize the GPU, help anyone?

----------

## Yamakuzure

 *blakdeath wrote:*   

> I still have no idea why  primus run cannot utilize the GPU, help anyone?

 It does utilize it or it would not work at all. My bet is a vblank conflict. Both primus and the application wait for vertical blank. Try with "vblank_mode=0" and with deactivated vertical blank in your application. And maybe take a look into driconf.

----------

## Adel Ahmed

now I get nothing when I run optirun glxgears:

adel@localhost ~ $ optirun -v glxgears

[   56.338490] [INFO]Configured driver: nvidia

----------

## Ant P.

Try the following:

```
LIBGL_ALWAYS_SOFTWARE=1 glxgears
```

That shows how fast glxgears runs when your driver setup is broken, as software rendering ignores vsync. You can compare other things to that to know when it's working right.

----------

## Yamakuzure

I just had a weird experience.

As I wrote, the performance in Mass Effect 1 was abysmal until I started with vblank_mode=0. Yesterday I tried a game and the performance was down the drain again. It appears that primusrun ignored the vblank setting, or something else enforced a vsync. I had to disable vsync in Mass Effect to get to the old performance.

There is either something wrong with my setup, but I didn't really change anything, or something in the bumblebee/primusrun/wine path is enforcing "outside" vertical sync no matter what.

I haven't figured out, yet, what it is.

----------

## Adel Ahmed

here's what I'm getting at the moment:

optirun -vvv glxgears

[   25.785642] [DEBUG]Reading file: /etc/bumblebee/bumblebee.conf

[   25.786150] [INFO]Configured driver: nvidia

[   25.786359] [DEBUG]optirun version 3.2.1 starting...

[   25.786385] [DEBUG]Active configuration:

[   25.786402] [DEBUG] bumblebeed config file: /etc/bumblebee/bumblebee.conf

[   25.786421] [DEBUG] X display: :8

[   25.786439] [DEBUG] LD_LIBRARY_PATH: /usr/lib64/opengl/nvidia/lib:/usr/lib32/opengl/nvidia/lib:/usr/lib/opengl/nvidia/lib

[   25.786460] [DEBUG] Socket path: /var/run/bumblebee.socket

[   25.786478] [DEBUG] Accel/display bridge: auto

[   25.786496] [DEBUG] VGL Compression: proxy

[   25.786514] [DEBUG] VGLrun extra options: 

[   25.786532] [DEBUG] Primus LD Path: /usr/lib/primus:/usr/lib32/primus

[   25.786623] [DEBUG]Using auto-detected bridge virtualgl

[   25.980201] [INFO]Response: No - error: [XORG] (EE) NVIDIA(GPU-0): Failed to initialize the NVIDIA GPU at PCI:1:0:0.  Please

[   25.980214] [ERROR]Cannot access secondary GPU - error: [XORG] (EE) NVIDIA(GPU-0): Failed to initialize the NVIDIA GPU at PCI:1:0:0.  Please

[   25.980218] [DEBUG]Socket closed.

[   25.980229] [ERROR]Aborting because fallback start is disabled.

[   25.980233] [DEBUG]Killing all remaining processes.

----------

## Adel Ahmed

journalctl entry:

Dec 06 08:18:45 localhost kernel: vgaarb: this pci device is not a vga device

Dec 06 08:18:45 localhost kernel: nvidia 0000:01:00.0: irq 48 for MSI/MSI-X

Dec 06 08:18:45 localhost kernel: ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20140424/nsarguments-95)

Dec 06 08:18:45 localhost kernel: ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20140424/nsarguments-95)

Dec 06 08:18:45 localhost kernel: ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20140424/nsarguments-95)

Dec 06 08:18:45 localhost kernel: ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20140424/nsarguments-95)

Dec 06 08:18:45 localhost kernel: ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20140424/nsarguments-95)

Dec 06 08:18:45 localhost kernel: ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20140424/nsarguments-95)

Dec 06 08:18:45 localhost kernel: ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20140424/nsarguments-95)

Dec 06 08:18:45 localhost kernel: ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20140424/nsarguments-95)

Dec 06 08:18:45 localhost kernel: ACPI Warning: \_SB_.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20140424/nsarguments-95)

Dec 06 08:18:45 localhost kernel: NVRM: RmInitAdapter failed! (0x25:0x28:1193)

Dec 06 08:18:45 localhost kernel: NVRM: rm_init_adapter failed for device bearing minor number 0

Dec 06 08:18:45 localhost kernel: NVRM: nvidia_frontend_open: minor 0, module->open() failed, error -5

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470592] [ERROR][XORG] (EE) NVIDIA(GPU-0): Failed to initialize the NVIDIA GPU at PCI:1:0:0.  Please

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470604] [ERROR][XORG] (EE) NVIDIA(GPU-0):     check your system's kernel log for additional error

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470607] [ERROR][XORG] (EE) NVIDIA(GPU-0):     messages and refer to Chapter 8: Common Problems in the

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470611] [ERROR][XORG] (EE) NVIDIA(GPU-0):     README for additional information.

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470614] [ERROR][XORG] (EE) NVIDIA(GPU-0): Failed to initialize the NVIDIA graphics device!

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470618] [ERROR][XORG] (EE) NVIDIA(0): Failing initialization of X screen 0

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470621] [ERROR][XORG] (EE) Screen(s) found, but none have a usable configuration.

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470625] [ERROR][XORG] (EE)

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470628] [ERROR][XORG] (EE) no screens found(EE)

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470632] [ERROR][XORG] (EE)

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470636] [ERROR][XORG] (EE) Please also check the log file at "/var/log/Xorg.8.log" for additional information.

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470639] [ERROR][XORG] (EE)

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470644] [ERROR][XORG] (EE) Server terminated with error (1). Closing log file.

Dec 06 08:18:45 localhost bumblebeed[1471]: [ 2764.470647] [ERROR]X did not start properly

xorg.log: http://pastebin.com/h0Ny5aWf

----------

## Adel Ahmed

sometimes I get this  error in journalctl:

Dec 06 12:25:22 localhost systemd-udevd[1036]: worker [1051] /devices/pci0000:00/0000:00:01.0/0000:01:00.0 timeout; kill it

Dec 06 12:25:22 localhost systemd-udevd[1036]: seq 1083 '/devices/pci0000:00/0000:00:01.0/0000:01:00.0' killed

Dec 06 12:25:26 localhost kernel: bbswitch: enabling discrete graphics

----------

## Yamakuzure

Huh? I got this too before I set my laptop to unload nvidia_nvu module before going to sleep. Do you hibernate your machine? removing the nvidia module and re-inserting it should fix that issue.

Oh, and I prefer glxspheres64 (comes with virtualgl) over glxgears.

----------

## Adel Ahmed

you're right, removing and reinserting the moddule helped, now back to debugging the primus run performance

----------

