Q:

How to install nVidia GeForce GTX 1050 Ti drivers for Ubuntu 18.04.03 LTS on Acer Predator Helios 300 laptop

I've recently purchased an Acer Predator Helios 300 laptop.
RAM 8GB
128 GB SSD
1 TB HDD
Intel i5 processor with integrated UHD graphics
NVidia Geforce GTX 1050 Ti 4 GB
For the last entire week I've been trying to install Ubuntu 18.04.03 LTS on this machine. (Single OS, no dual booting for me. ) It installs alright but the first boot requires setting 'nomdeset' as kernel option at the GRUB screen.
After first boot up, I tried to install nVidia graphics drivers in all the following ways and every time, after reboot, I see that Intel UHD drivers are running the display instead of the NVidia driver -

Installed drivers from.run file downloaded from NVidia's website.
'Additional Hardware' dialogue.
Installing NVidia drivers from the ppa
Removing, purging drivers, then 'update-initramfs - u' and install from recovery menu of the GRUB.
Installing official. run file using CC=gcc-7 flag.
Used different files from 'Additional Hardware' utility
Tried turning off Wayland from custom.conf
Blacklisting nouveau hasn't solved the issue. 
Tried many excellent answers from this forum. 

Nothing is working. Every time, either Ubuntu freezes after login screen or Intel UHD drivers take over display.
I tried nvidia-smi command. But sometimes it showed NVidia GPU info and sometimes it didn't ("could not communicate with driver, make sure you have installed correct one bla bla bla" )
Using prime-select has no effect.
The NVidia control panel shows NVidia as selected driver (most irritating!)
I'm officially at my wit's end. I really don't want freaking Windows 10 on my machine. I messed up my installion twice already. 
Please help me here friends. 

A:

How to install Ubuntu on Acer Predator Helios 300 laptop including installation of nVidia drivers (Only Ubuntu, no dual-boot instructions sorry.)

Boot into windows, download all bios updates from Acer's website, install all of them and reboot into Windows again to ensure that updates have successfully installed. Note down the Windows serial key somewhere safe in case if you wish to reinstall Windows or virtualize it inside Ubuntu!

First of all, access UEFI settings by pressing F2 key at bootup (This machine has the ugliest UEFI user interface I have ever seen. It looks almost like 10 year old BIOS) and open 'Security' tab. Here set an 'Supervisor' password. 
Then open 'Boot' tab and disable 'Secure boot'. (If 'Secure boot option is still disabled, save settings and reboot to UEFI settings again)
Then open 'Main' tab and change the' Touchpad' preference from 'Advanced' to 'Basic' (as shown in the image). Also set 'SATA Mode' to 'AHCI' from 'RST with Optane'. (You can change this later.)
Insert Ubuntu installation USB -> save UEFI settings and reboot -> Press F12 as Predator logo appears to go to boot disk selection (or F2 and then change boot order from UEFI settings) -> choose Ubuntu installation USB -> boot to Ubuntu GRUB screen -> select 'Try Ubuntu without installing' -> press 'e' key and set 'nomodeset' option in kernel option -> press F10 to boot into live Ubuntu.
Open 'Disks' utility and format the SSD completely. Choose 'Overwrite everything with zeros (slow)) option and GPT partitioning option.
Now install Ubuntu as usual (But remember to select 'Download updates' and 'third party packages' options)
Reboot freshly installed Ubuntu by again setting 'nomodset' in kernel options as before. 
After logging in, update and upgrade the system immediately
Edit /etc/default/grub and set the nomodeset kernel option by adding it to the line beginning GRUB_CMDLINE_LINUX_DEFAULT, for example:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"

Run sudo update-grub and reboot (DON'T GO FOR INSTALLING nVidia DRIVERS YET! THIS IS VERY IMPORTANT!)
After logging into updated system, open a terminal and add the following PPA (Yeah, this is mandatory if you want your nVidia card to work properly.)
sudo add-apt-repository ppa:aplattner/ppa
sudo add-apt-repository ppa:graphics-drivers/ppa

Then update and upgrade using sudo apt update && sudo apt upgrade.
Find your kernel version using uname -r command.
Now install xorg xorg-hwe-$(uname-r) linux-source-$(uname -r) linux-headers-$(uname -r) libvdpau binutils make gcc dkms and REBOOT.
After logging in, open up Software Centre and open Software Sources from its preferences.
Go to Additional hardware tab and let the drivers list load. Select the most recent driver and click Apply. Wait till the nVidia driver installs (DON'T OPEN ANY APPLICATION DURING INSTALLATION!). Reboot after installation of nVidia driver is complete.

Now do the following if you want to be able to select your preferred GPU (intel or nVidia) through prime-select command. 
I've taken these instructions from this devtalk.nvidia.com article
(Look for comment by user 'generix' on this page. A big THANK YOU to him/her!) --
Please delete /etc/X11/xorg.conf and modify /usr/share/X11/xorg.conf.d/10-amdgpu.conf
replacing only 
Driver "amdgpu"

with
Driver "modesetting"

Please add
Option "PrimaryGPU" "Yes"

inside the 'OutputClass' of /usr/share/X11/xorg.conf.d/10-nvidia.conf
Then create two files optimus.desktop in /etc/xdg/autostart/ and /usr/share/gdm/greeter/autostart/ containing
[Desktop Entry]
Type=Application
Name=Optimus
Exec=sh -c "xrandr --setprovideroutputsource modesetting NVIDIA-0; xrandr --auto"
NoDisplay=true
X-GNOME-Autostart-Phase=DisplayServer

This should enable the nvidia profile on Ubuntu.
Creating an /etc/X11/xorg.conf just containing -
Section "ServerLayout"
  Identifier "layout"
  Option "AllowNVIDIAGPUScreens"
EndSection

Then applications can be started using nVidia as GPU by running --
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia  *name_of_the_application*

I HOPE THIS HELPS PEOPLE WISHING TO INSTALL AND USE LINUX ON THIS LAPTOP.

