How to choose the VGA when setting up the X Server?

7,612

So I got everything to run on the Amazon-provided Ubuntu 14.04 AMI ubuntu-trusty-14.04-amd64 . Below is my setup code. I kept the old answer attached below as well, for people to find in Google.

    # setup kernel
    sudo apt-get update
    sudo apt-get install -y gcc make linux-generic

    # install X server and OpenGL tools
    sudo apt-get install -y xserver-xorg mesa-utils

    # disable Nouveau
    # via http://altinukshini.wordpress.com/2011/07/28/how-to-install-nvidia-drivers-in-ubuntu-linux/
    sudo echo 'blacklist nouveau' >> /etc/modprobe.d/blacklist.conf
    sudo echo 'options nouveau modeset=0' >> /etc/modprobe.d/blacklist.conf
    echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
    sudo update-initramfs -u

    # reboot to get kernel update and nouveau disabling activated
    sudo reboot now



    # install NVIDIA drivers

    # version was chosen because was "Latest Long Lived Branch version", which sounds stable
    # resources:
    #   http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using_cluster_computing.html
    #   http://www.nvidia.com/object/unix.html
    #   http://us.download.nvidia.com/XFree86/Linux-x86_64/340.46/README/index.html

    wget http://us.download.nvidia.com/XFree86/Linux-x86_64/340.46/NVIDIA-Linux-x86_64-340.46.run
    sudo /bin/bash ./NVIDIA-Linux-x86_64-340.46.run --accept-license --no-questions --ui=none
    sudo reboot now



    # setup xorg.conf
    # via https://stackoverflow.com/questions/19856192/run-opengl-on-aws-gpu-instances-with-centos
    sudo nvidia-xconfig -a --use-display-device=None --virtual=1280x1024

    # add missing BusID
    sudo sed -i 's/    BoardName      "GRID K520"/    BoardName      "GRID K520"\n    BusID          "0:3:0"/g' /etc/X11/xorg.conf



    # run x server and glxgears as test application

    sudo /usr/bin/X &
    DISPLAY=:0 glxgears

Old Post

Sadly I haven't found the answer myself yet, but here is some breadcrumbs on the way:

I installed the NVIDIA drivers

# from aws docs http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using_cluster_computing.html
sudo apt-get update
sudo apt-get install -y linux-generic
sudo reboot now

wget http://us.download.nvidia.com/XFree86/Linux-x86_64/343.22/NVIDIA-Linux-x86_64-343.22.run
sudo /bin/bash ./NVIDIA-Linux-x86_64-343.22.run
sudo reboot now

(if you get an error because of nouveau drivers, check here)

Next install XServer

sudo apt-get install -y xserver-xorg

And generate the xconfig (as per other stack overflow question)

sudo nvidia-xconfig -a --use-display-device=None --virtual=1280x1024

Weirdly this generates a file in /etc/X11/XF86Config, so I copied that to /etc/X11/xorg.conf, in order for X to pick it up.

Now running the Xserver gives the following error for me:

sudo /usr/bin/X :0 &
(WW) CIRRUS: No matching Device section for instance (BusID PCI:0@0:2:0) found

One answer in that stack overflow question says to choose the bus, which results in this error:

error setting MTRR (base = 0xe8000000, size = 0x00100000, type = 1) Invalid argument (22)

Whatever that means. Looking back at the log reveals, that apparently the NVIDIA driver is not loaded at all (although tried):

cat /var/log/Xorg.0.log
...
[  3136.163] Loading extension GLX
...
[  3136.163] (II) LoadModule: "nvidia"
[  3136.164] (WW) Warning, couldn't open module nvidia
[  3136.164] (II) UnloadModule: "nvidia"
[  3136.164] (II) Unloading nvidia
[  3136.164] (EE) Failed to load module "nvidia" (module does not exist, 0)

Now this post suggests, that the module path has to be set manually in the conf:

# find the path (maybe)
sudo find / | grep nvidia | grep modules
...    
usr/X11R6/lib/modules/
...

# put it into the conf file
vim /etc/X11/xorg.conf
...
Section "Files"
     ModulePath     "/usr/X11R6/lib/modules"
EndSection

Anyways, this seems to actually load the driver module and then crashes:

sudo /usr/bin/X :0 &
...
Loading extension GLX
(EE)
(EE) Backtrace:
(EE) 0: /usr/bin/X (xorg_backtrace+0x48) [0x7f65c7ea9d28]
(EE) 1: /usr/bin/X (0x7f65c7d01000+0x1aca19) [0x7f65c7eada19]
(EE) 2: /lib/x86_64-linux-gnu/libpthread.so.0 (0x7f65c6dfe000+0x10340) [0x7f65c6e0e340]
(EE) 3: /usr/X11R6/lib/modules/drivers/nvidia_drv.so (0x7f65bf75b000+0x88cb5) [0x7f65bf7e3cb5]
(EE) 4: /usr/X11R6/lib/modules/drivers/nvidia_drv.so (0x7f65bf75b000+0x69272) [0x7f65bf7c4272]
(EE) 5: /usr/X11R6/lib/modules/drivers/nvidia_drv.so (0x7f65bf75b000+0x55e43a) [0x7f65bfcb943a]
(EE) 6: /usr/bin/X (0x7f65c7d01000+0xaf67b) [0x7f65c7db067b]
(EE) 7: /usr/bin/X (xf86CallDriverProbe+0x5e) [0x7f65c7d89a5e]
(EE) 8: /usr/bin/X (xf86BusConfig+0x46) [0x7f65c7d8a3d6]
(EE) 9: /usr/bin/X (InitOutput+0x993) [0x7f65c7d982b3]
(EE) 10: /usr/bin/X (0x7f65c7d01000+0x596bb) [0x7f65c7d5a6bb]
(EE) 11: /lib/x86_64-linux-gnu/libc.so.6 (__libc_start_main+0xf5) [0x7f65c583dec5]
(EE) 12: /usr/bin/X (0x7f65c7d01000+0x44dde) [0x7f65c7d45dde]
Share:
7,612
Wagner Patriota
Author by

Wagner Patriota

Updated on September 18, 2022

Comments

  • Wagner Patriota
    Wagner Patriota almost 2 years

    I have 2 options of VGA:

    lspci | grep VGA
    00:02.0 VGA compatible controller: Cirrus Logic GD 5446
    00:03.0 VGA compatible controller: NVIDIA Corporation GK104GL [GRID K520] (rev a1)
    

    It's an instance of Ubuntu running on Amazon EC2.

    When I open my xserver I get the following message:

    (WW) CIRRUS: More than one matching Device section found: Autoconfigured Video Device cirrus
    

    In fact the X server gets open and it works. But with the resources of the "Cirrus Logic". I wanna be able to choose the VGA I want when open the X Server. How do I do that?

    • PS: The final goal here is to use OpenGL of NVIDIA. This is an Ubuntu running on Amazon AWS. It has GPU so it's supposed to have a way for me to use OpenGL on it.

    • PS2: Disable the Cirrus VGA is also very welcome. Is there a way to do that?

    • Mr.Lee
      Mr.Lee over 10 years
      I swear this isn't a silly question. Do you have more than one VGA port? What are you trying to accomplish physically?
    • Wagner Patriota
      Wagner Patriota over 10 years
      It's actually Ubuntu running in Amazon AWS. (I will update the post)
  • Timothée Jeannin
    Timothée Jeannin almost 9 years
    You just saved my life ! xD