« Previous | Next »

Nvidia X11 hardware acceleration on Ubuntu 18.04

19 Feb 2019

After reinstalling Windows 7, I set my laptop up to dual boot Xubuntu 18.04. My laptop has an integrated Intel i915 graphics chip and also an Nvidia GeForce GT 330M GPU. This post describes how I set up X11 to use the GPU.

Start by finding out which drivers are in use and available:

% ubuntu-drivers devices
... currently running nouveau
... recommends nvidia-340

Install the recommended driver and reboot:

% sudo apt-get install nvidia-340
% sudo shutdown -r now

After the reboot, VT-7 showed a black screen. VTs 1-6 were still available and the machine was otherwise functional. X.org.0.log recorded that the Nvidia driver had set (the graphics) mode to NULL.

To fix:

% sudo apt-get install nvidia-prime
% sudo prime-select nvidia
% sudo shutdown -r now

The X environment came back. To validate:

% inxi -G
Graphics:  Card-1: Intel Core Processor Integrated Graphics Controller
           Card-2: NVIDIA GT216M [GeForce GT 330M]
           Display Server: x11 (X.Org 1.19.6 ) drivers: modesetting,nvidia (unloaded: fbdev,vesa,nouveau)
           Resolution: 1920x1080@59.94hz
           OpenGL: renderer: GeForce GT 330M/PCIe/SSE2 version: 3.3.0 NVIDIA 340.107

There's a tool to switch between the Nvdia and Intel chips:

Nvidia Profile Switching


% glxgears -info
13122 frames in 5.0 seconds = 2624.275 FPS
13039 frames in 5.0 seconds = 2607.778 FPS
13916 frames in 5.0 seconds = 2783.134 FPS
11971 frames in 5.0 seconds = 2394.196 FPS

For comparison and contrast, an even older GPU-less laptop managed about ~60 FPS running glxgears.

As for Pharo, the OSWindow external operating system window examples, such as SDL2AthensDrawingExample, now only run in Nvidia mode and crash Pharo instantly in Intel mode:

The program 'pharo' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
  (Details: serial 100 error_code 2 request_code 154 minor_code 3)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
Tags: Linux