Can't make NVidia GPU usable on Ubuntu 18.04 (Asus notebook)

I have already tried everything I could find to make Ubuntu 18.04 on Asus TUF FX504GE recognize the GTX 1050Ti in it. Nothing can make nvidia-smi outputs what it should.

I already tried:

  • Installing nvidia drivers on 18.04
    • Here dpkg-divert outputs nothing related to nvidia
  • Chapter 4. Installing the NVIDIA Driver (from NVidia)
    • Here I had to do that nouveau.modeset=0 editing on Grub lines to boot without any interface and run that .run downloaded from NVidia. It failed on nvidia preinstall stuff and, when I selected install anyway, although it installed the driver, by the end, it couldn't find nvidia-drm
  • Installing Linux on ASUS TUF FX504 GE
    • Although this link was gold to me, allowing me to install Ubuntu 18 (because 16 strangely cursed everything), this also didn't make GPU usable

I have:

  • Notebook Asus TUF Gaming FX504GE series, GTX 1050Ti

  • Kernel version: 5.3.0-26-generic

  • Ubuntu version: 18.04.03 LTS

  • Software & Updates

    Software & Updates

  • About Ubuntu:

    About Ubuntu

  • lshw video's output

$ sudo lshw -c video
  *-display UNCLAIMED       
       description: 3D controller
       product: GP107M [GeForce GTX 1050 Ti Mobile]
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list
       configuration: latency=0
       resources: memory:a3000000-a3ffffff memory:90000000-9fffffff memory:a0000000-a1ffffff ioport:4000(size=128) memory:a4000000-a407ffff
  *-display
       description: VGA compatible controller
       product: Intel Corporation
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 00
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm vga_controller bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: irq:143 memory:a2000000-a2ffffff memory:80000000-8fffffff ioport:5000(size=64) memory:c0000-dffff
  • NVidia related installed packages:
$ apt list --installed | grep -P 'nvidia|cuda'

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libnvidia-cfg1-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
libnvidia-common-415/bionic,bionic,now 415.27-0ubuntu0~gpu18.04.2 all [installed,automatic]
libnvidia-compute-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
libnvidia-decode-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
libnvidia-encode-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
libnvidia-fbc1-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
libnvidia-gl-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
libnvidia-ifr1-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
nvidia-compute-utils-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
nvidia-dkms-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
nvidia-driver-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed]
nvidia-kernel-common-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
nvidia-kernel-source-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
nvidia-prime/bionic-updates,bionic-updates,now 0.8.8.2 all [installed,automatic]
nvidia-settings/unknown,now 440.33.01-0ubuntu1 amd64 [installed,automatic]
nvidia-utils-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
xserver-xorg-video-nvidia-415/bionic,now 415.27-0ubuntu0~gpu18.04.2 amd64 [installed,automatic]
  • Xorg's log about NVidia
$ cat /var/log/Xorg.0.log | grep -i nvidia
[    13.485] (**) OutputClass "nvidia" ModulePath extended to "/usr/lib/x86_64-linux-gnu/nvidia/xorg,/usr/lib/xorg/modules"
[    13.485] (**) OutputClass "Nvidia Prime" ModulePath extended to "/x86_64-linux-gnu/nvidia/xorg,/usr/lib/x86_64-linux-gnu/nvidia/xorg,/usr/lib/xorg/modules"
[    13.485] (**) OutputClass "Nvidia Prime" setting /dev/dri/card1 as PrimaryGPU
[    13.493] (II) Applying OutputClass "nvidia" to /dev/dri/card1
[    13.493]    loading driver: nvidia
[    13.493] (II) Applying OutputClass "Nvidia Prime" to /dev/dri/card1
[    13.493]    loading driver: nvidia
[    13.729] (==) Matched nvidia as autoconfigured driver 0
[    13.729] (II) LoadModule: "nvidia"
[    13.729] (II) Loading /usr/lib/x86_64-linux-gnu/nvidia/xorg/nvidia_drv.so
[    13.740] (II) Module nvidia: vendor="NVIDIA Corporation"
[    13.748] (II) NVIDIA dlloader X Driver  440.26  Sun Oct 13 17:46:52 UTC 2019
[    13.748] (II) NVIDIA Unified Driver for all Supported NVIDIA GPUs
[    13.748] (II) NOUVEAU driver for NVIDIA chipset families :
[    13.759] (II) NVIDIA(0): Creating default Display subsection in Screen section
[    13.759] (==) NVIDIA(0): Depth 24, (==) framebuffer bpp 32
[    13.760] (==) NVIDIA(0): RGB weight 888
[    13.760] (==) NVIDIA(0): Default visual is TrueColor
[    13.760] (==) NVIDIA(0): Using gamma correction (1.0, 1.0, 1.0)
[    13.760] (II) Applying OutputClass "nvidia" options to /dev/dri/card1
[    13.760] (II) Applying OutputClass "Nvidia Prime" options to /dev/dri/card1
[    13.760] (**) NVIDIA(0): Option "AllowEmptyInitialConfiguration"
[    13.760] (**) NVIDIA(0): Option "IgnoreDisplayDevices" "CRT"
[    13.760] (**) NVIDIA(0): Enabling 2D acceleration
[    13.761] (II) Loading sub module "glxserver_nvidia"
[    13.761] (II) LoadModule: "glxserver_nvidia"
[    13.761] (II) Loading /usr/lib/x86_64-linux-gnu/nvidia/xorg/libglxserver_nvidia.so
[    13.819] (II) Module glxserver_nvidia: vendor="NVIDIA Corporation"
[    13.819] (II) NVIDIA GLX Module  440.26  Sun Oct 13 17:44:48 UTC 2019
[    13.821] (II) NVIDIA: The X server does not support PRIME Render Offload.
[    13.825] (II) NVIDIA(0): NVIDIA GPU GeForce GTX 1050 Ti (GP107-A) at PCI:1:0:0 (GPU-0)
[    13.825] (--) NVIDIA(0): Memory: 4194304 kBytes
[    13.825] (--) NVIDIA(0): VideoBIOS: 86.07.50.00.59
[    13.825] (II) NVIDIA(0): Detected PCI Express Link width: 16X
[    13.825] (II) NVIDIA(0): Validated MetaModes:
[    13.825] (II) NVIDIA(0):     "NULL"
[    13.825] (II) NVIDIA(0): Virtual screen size determined to be 640 x 480
[    13.825] (WW) NVIDIA(0): Unable to get display device for DPI computation.
[    13.825] (==) NVIDIA(0): DPI set to (75, 75); computed from built-in default
[    13.980] (II) NVIDIA: Using 24576.00 MB of virtual memory for indirect memory
[    13.980] (II) NVIDIA:     access.
[    13.997] (II) NVIDIA(0): Setting mode "NULL"
[    13.999] (==) NVIDIA(0): Disabling shared memory pixmaps
[    13.999] (==) NVIDIA(0): Backing store enabled
[    13.999] (==) NVIDIA(0): Silken mouse enabled
[    13.999] (==) NVIDIA(0): DPMS enabled
[    13.999] (WW) NVIDIA(0): Option "PrimaryGPU" is not used
[    13.999] (II) NVIDIA(0): [DRI2] Setup complete
[    13.999] (II) NVIDIA(0): [DRI2]   VDPAU driver: nvidia
[  1363.870] (II) NVIDIA(0): Setting mode "NULL"
[  3115.004] (II) NVIDIA(GPU-0): Deleting GPU-0

UPDATE

For the 1000th time, I did sudo apt purge *nvidia*, and then sudo apt install nvidia-driver-440. And, trying a friend's advice, I also installed Bumblebee.

After this, nvidia-smi finally shows something:

Mon Jan 27 13:22:32 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.48.02    Driver Version: 440.48.02    CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 105...  Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   46C    P8    N/A /  N/A |      0MiB /  4042MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

Although it is already a great advance, seems like I can't use GPU processing yet... (stuff like glmark2 still runs on Intel)...


Solution 1:

Well, by the end, Bumblebee did the trick.

But, to make it work, after a lot of trials and errors, I did the following:

1. Purge EVERYTHING related to NVidia

What I mean: sudo apt purge *nvidia*

Note that I'm not doing nvidia* because it lefts behind stuff like libnvidia-whatever.so

2. Reboot

After this, the notebook was not booting properly: it was suddenly shutting down after some seconds of black screen. I had to edit GRUB before Ubuntu selection to set nouveau.modeset to 0 in order to proceed.

How to do it:

  • At grub screen, with the selection cursor over Ubuntu, press e to open a text editor
  • Append to the Linux line (separated by a space) this: nouveau.modeset=0
  • Press Ctrl-x to proceed the boot
  • This was enough to make the notebook boot properly and proceed with the NVidia's driver quest.

3. Install the NVidia driver

According to ubuntu-driver devices (this command hangs a little to show its output):

ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001C8Csv00001043sd000018FEbc03sc02i00
vendor   : NVIDIA Corporation
model    : GP107M [GeForce GTX 1050 Ti Mobile]
driver   : nvidia-driver-440 - third-party free recommended
driver   : nvidia-driver-415 - third-party free
driver   : nvidia-driver-430 - third-party free
driver   : nvidia-driver-435 - distro non-free
driver   : nvidia-driver-390 - third-party free
driver   : nvidia-driver-410 - third-party free
driver   : xserver-xorg-video-nouveau - distro free builtin

== /sys/devices/pci0000:00/0000:00:14.3 ==
modalias : pci:v00008086d0000A370sv00008086sd00000034bc02sc80i00
vendor   : Intel Corporation
manual_install: True
driver   : backport-iwlwifi-dkms - distro free

nvidia-driver-440 is recommended. So I installed it: sudo apt install nvidia-driver-440

4. Install Bumblebee

I followed the Setup for 14.04 and later on Bumblebee.

After the reboot, nvidia-smi was output (as I said on the question's update).

Then I tried to run some tensorflow-gpu test and it was running on GPU (as showed by nvidia-smi)!

Thank you all for all the help :)

Solution 2:

Have you tried going to the Software & Updates menu?

enter image description here

I installed my drivers during the installing of Ubuntu by allowing 3rd party drivers, but still had to come here to select it.

Hope it helps.