Installation error on Ubuntu 18.04

I have a laptop with a GTX1050, running Ubuntu 18.04.3 with GCC version 7.4.0, and am trying to install CUDA via the runfile. I initially got a warning about some files already existing, so I removed most of the existing Nvidia packages that showed up in dpkg. Here is the output of a couple relevant commands -

lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation GP107M [GeForce GTX 1050 Mobile] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GP107GL High Definition Audio Controller (rev a1)

dpkg -l | grep nvidia
nvidia-kernel-common-390 390.116-0ubuntu0.18.04.1

I didn’t try to remove the package above because the StackOverflow posts I found seemed to indicate it should not be removed.

After the command
sudo sh

I get a message that the installation failed, and I should check the /var/log/cuda-installer.log file. Here are the contents of that file -

[INFO]: Driver not installed.
[INFO]: Checking compiler version…
[INFO]: gcc location: /usr/bin/gcc

[INFO]: gcc version: gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)

[INFO]: Initializing menu
[INFO]: Setup complete
[INFO]: Components to install:
[INFO]: Driver
[INFO]: 418.87.00
[INFO]: Executing --ui=none --no-questions --accept-license --disable-nouveau --no-cc-version-check --install-libglvnd 2>&1
[INFO]: Finished with code: 256
[ERROR]: Install of driver component failed.
[ERROR]: Install of 418.87.00 failed, quitting

Really not sure where to go from here, any suggestions?

I disabled secure boot in my bios settings. After that the installation was successful.