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

Blank screen with latest nvidia drivers #18

Closed davidcortesortuno closed 5 years ago

davidcortesortuno commented 8 years ago

Hi, I'm using Arch and I updated to the latest Nvidia drivers https://www.archlinux.org/packages/extra/x86_64/nvidia/

Now, when I run nvidia-xrun openbox-session I only get a black screen. Is is something with the nvidia-xorg.conf file ?

ethragur commented 8 years ago

Hey,

Had the same problem after the update as well. Do you have bumblebee installed? Or the bumblebeed.service running? I fixed it by disabling and uninstalling it

Witko commented 8 years ago

Hi @davidcortesortuno, in general nvidia-xrun does not work well with bumblebee installed. Some people here wrote that it works for them but for me there was a library issue. If you want to keep bumblebee just upload the Xorg.log file, we can try to have a closer look there.

ghost commented 8 years ago

Hi

I have been having the same problem. Here is the log file... Can you please help diagnose?

Many thanks. log.txt

davidcortesortuno commented 8 years ago

Hi, mm I see. If I uninstall bumblebee how can I let the Intel card working by default? Because only installing nvidia will make my laptop use that. Or is that a distro specific issue?

ethragur commented 8 years ago

If you uninstall bumblebee your Intel card will still be the default card. bumblebee is only needed for optirun/primusrun. If you do a normal startx the xserver will run on the intel card.

For games or other opengl applications you will need to start another xserver with nvidia-xrun

davidcortesortuno commented 8 years ago

mm but nvidia xrun needs Nvidia drivers I guess. So installing them will make the system to use the Nvidia card by default, or am I wrong?

ghost commented 8 years ago

Uninstalling bumblebee solves the issue. X starts and is using the intel card. However, I lose power management as the nvidia card stays on. bbswitch is installed but cant disable the card even though it is not in use which means unecessary battery drain. I guess bumblebee handles the power management side perfectly, whereas nvidia-xrun handles performance perfectly. If only both could work together.

davidcortesortuno commented 8 years ago

How can you tell if you are using the intel card if the nvidia stays on? :O

ghost commented 8 years ago

xorg.conf is only setup for the intel card

Witko commented 8 years ago

Hi guys, as far as i know bumblebee uses bbswitch too. Currently i also have this issue that nvidia stays on cat /proc/acpi/bbswitch 0000:01:00.0 ON So i will dig a bit into it. It was definetely working before.

Which card is used by default is defined in your default xorg.conf.

ghost commented 8 years ago

Hi, without bumbleebee installed bbswitch will not switch off unless nvidia, nvidia_modeset and nvidia_drm are unloaded with rmmod. With bumblebee installed, I only get the blank screen on starting up. Is it something to do with nvidia_drm? This is the only NEW issue since updating nvidia drivers and seems to be preventing nvidia-xrun starting up with bumblebee installed or quitting correctly without bumblebee installed.

ghost commented 8 years ago

Ubelievable - simply adding modprobe nvidia_drm to the script solves the problem - along with rmmod nvidia_drm of course. With these changes, I can have bumblee and nvidia-xrun on the same system. Everything working perfectly and I reconfigured bbswitch to work correctly as well. I only prefer to keep bumblebee as it offers a mid level of performance, if you like, without the need to log into another xsession.

Witko commented 8 years ago

Hi @sjseventyeight thats great news. I've got this change on the todo list for quite some time. If you have a working solution you can paste the changes here or do a patch or whatever so i can update the scripts.

Thank you!

ghost commented 8 years ago
DRY_RUN=0
function printHelp {
  echo "Utility to run games and applications in separate X on discrete Nvidia graphic card"
  echo "Usage: "
  echo "nvidia-xrun [<options>] <app>"
  echo "Options: "
  echo "  -d    Dry run - prints the final command but does not execute it"
}

function execute {
  if [ $DRY_RUN -eq 1 ]
    then
    echo ">>Dry run. Command: $*"
  else
    eval $*
  fi
}

if [[ $EUID -eq 0 ]]; then
   echo "This script must not be run as root" >&2
   exit 1
fi

if [ "$1" == "-d" ]
  then
    DRY_RUN=1
    shift 1
fi

if [ $# -eq 0 ]
  then
    printHelp
    exit 1
fi

# calculate current VT
LVT=`fgconsole`

# calculate first usable display
XNUM="-1"
SOCK="something"
while [ ! -z "$SOCK" ] 
do
  XNUM=$(( $XNUM + 1 ))
  SOCK=$(ls -A -1 /tmp/.X11-unix | grep "X$XNUM" )
done

NEWDISP=":$XNUM"

if [ ! -z "$*" ] # generate exec line if arguments are given
then 
  # test if executable exists
  if [ ! -x "$(which $1 2> /dev/null)" ] 
  then
    echo "$1: No such executable!"
    exit 1
  fi
  # generate exec line
  EXECL="$(which $1)"
  shift 1
  EXECL="$EXECL $*"
  EXECPH=""
else # prepare to start new X sessions if no arguments passed
  EXECL=""
  EXECPH="New X session"
fi

EXECL="/etc/X11/xinit/nvidia-xinitrc $EXECL"

COMMAND="xinit $EXECL -- $NEWDISP vt$LVT -nolisten tcp -br -config nvidia-xorg.conf -configdir nvidia-xorg.conf.d"

echo 'Waking up nvidia GPU'
execute "sudo tee /proc/acpi/bbswitch <<<ON"
echo 'Loading nvidia module'
execute "sudo modprobe nvidia"
execute "sudo modprobe nvidia_drm" #added this to startup
execute $COMMAND
echo 'Unloading nvidia module'
execute "sudo rmmod nvidia_drm nvidia_modeset nvidia" #and the same for shutdown
echo 'Turning off nvidia GPU'
execute "sudo tee /proc/acpi/bbswitch <<<OFF"
ghost commented 8 years ago

As above. Thanks again. Hope this works for everyone.

Mutant22 commented 8 years ago

Hello, I have similar problem. After last update of system I get black screen when using nvidia-xrun. I am using Manjaro linux, and got nvidia-xrun package from AUR. I think I am missing Source Output capability of nvidia card and my drivers don't have nvidia_drm module, only nvidia and nvidia_modeset. I tried removing bumblebee, same result. I dont know why, It was working great before the update.

DISPLAY=:1 xrandr --listproviders Providers: number : 2 Provider 0: id: 0x1f0 cap: 0x0 crtcs: 0 outputs: 0 associated providers: 0 name:NVIDIA-0 Provider 1: id: 0x45 cap: 0x2, Sink Output crtcs: 3 outputs: 3 associated providers: 0 name:modesetting

Thank you

Witko commented 8 years ago

Hi @Mutant22, could you paste here your X log?

Mutant22 commented 8 years ago

Here it is. Do you need some more information? Xorg.1.log.txt

Witko commented 8 years ago

Hi @Mutant22 , the log looks completely ok. Try to play around with the command nvidia-xrun uses - with the dry run you can see it and use by hand. Then try to remove/change params. Otherwise im not sure where the problem might be.

Did you also try the fix proposed by @sjseventyeight ?

Mutant22 commented 8 years ago

I will try to play with dry run. Yes, I tried fix mentioned by @sjseventyeight, but it wont find nvidia_drm module.

$ sudo modprobe nvidia_drm modprobe: FATAL: Module nvidia_drm not found in directory /lib/modules/4.5.4-1-MANJARO

I believe the black screen has something to do with missing Source Output capability of nvidia card. Nvidia documentation

I tried to start xserver via nvidia-xrun lxterminal. Then I switched to another tty and tried: DISPLAY=:1 xrandr --setprovideroutputsource modesetting NVIDIA-0 X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 35 (RRSetProviderOutputSource) Value in failed request: 0x1f0 Serial number of failed request: 16 Current serial number in output stream: 17

Maybe I will try Archlinux instead of Manjaro, or wait for another update of gpu drivers :). Thank you for your help.

Witko commented 8 years ago

Actually that's what nvidia-xrun does. It uses modesetting driver for intel and then selects NVIDIA as provider. If you have a look in nvidia-xinitrc you will see what is being done at init of X. And here you can see the config of the bus, modesetting driver etc. As I have nothing to catch on (no error in logs) its hard to suggest something. Try to run the command from dry run - maybe there is something interesting.

I've tried nvidia-xrun on my laptop yesterday, it worked.
Good luck!

seankhl commented 8 years ago

For what it's worth, I've gotten this to work with bumblebee present by using

sudo update-alternatives --config glx

before and after every time I use nvidia-xrun, to switch from bumblebee path to regular nvidia path (and back, afterward). If you try to use the regular nvidia path in a normal session afterward, even the login screen, X will crash, but your ttys will be fine so you can switch it back. I'm sure there is an automated way of doing these settings but I'm at wit's last end making this work at all.

Doing this allows it to work, although $LD_LIBRARY_PATH isn't being exported (should I see the nvidia paths as set in the config once my session has started?) and once in a while my $DISPLAY environment variable gets borked (not sure why). Also, I cannot run nvidia-settings, it just won't work. It prints heavily duplicated output for checking vdpau veresion etc and never opens, but the GPU turns on and runs full blast until I kill it. Otherwise it seems to be working correctly.

Unfortunately, I get good performance for about 45 seconds, then my GPU throttles and I'm only about 20% better than the Intel card :(. Not sure what to do about that.

Witko commented 8 years ago

Hi @seanlaguna , maybe we can together add support for systems with bumblebee installed. I dont know much about update-alternatives and bumblebee though.

seankhl commented 8 years ago

Hi @Witko, I made a fork with my configs. Unfortunately a good amount has to change for this to work with debian and bumblebee, as reflected, and I think the particulars of every indivdiual's system might make it quite hard to support any system with bumblebee. Please take a look and let me know what you think.

https://github.com/seanlaguna/nvidia-xrun

Witko commented 7 years ago

Thanks @seanlaguna , im not sure yet how to incorporate this nicely. An option would be to create a separate package for this - sth like nvidia-xrun-bumblebee where your configs would be.