Cuda 10.2 installation problems on ubuntu 18.04

Installed Nvidia driver for GTX 1050ti from:
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=runfilelocal

I Downloaded Installer for Linux Ubuntu 18.04 x86_64, with installation Instructions:

wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run

sudo sh cuda_10.2.89_440.33.01_linux.run

On the screen:
 End User License Agreement                                                  │
│  --------------------------   
.....
Description                                                                             │
│                                                                                              │
│  This package contains the operating system driver and   
│ Do you accept the above EULA? (accept/decline/quit):      

I typed accept, 
CUDA INSTALLER
│ - [X] Driver                                                                   │
│      [X] 440.33.01                                                           │
│ + [X] CUDA Toolkit 10.2                                               │
│   [X] CUDA Samples 10.2                                             │
│   [X] CUDA Demo Suite 10.2                                        │
│   [X] CUDA Documentation 10.2                                  │
│   Options                                                                       │
│   Install 

I 'Enter' Select on install
and got:

 Installation failed. See log at /var/log/cuda-installer.log for details.
 I followed  pre-installation actions.


 on file cuda-installer.log 

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

[INFO]: gcc version: gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 

[INFO]: Initializing menu
[INFO]: Setup complete
[INFO]: Components to install: 
[INFO]: Driver
[INFO]: 440.33.01
[INFO]: Executing NVIDIA-Linux-x86_64-440.33.01.run --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 440.33.01 failed, quitting

I have gcc version
```i don't understand?. I have  spend a lot of  time trying it in different ways, and the installations failure. 
 The ubuntu installation is clean

Hi there,

I have an Acer Nitro 5 laptop with a GTX 1050 card. I struggled for a while with CUDA 10.2, and eventually gave up, and installed Linux Mint 19.3 which is based on Ubuntu 18.04 LTS, so much the same.

To successfully install CUDA, I switched to the latest available NVIDIA driver available with the distro.

Add:

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update

And update. Go to driver manager and select the Nvidia driver, the latest one available. It should say NVIDIA 435.21 at this time (April 2020, for Ubuntu 18.04 Bionic and derivative distributions).

After I switched to the latest nvidia driver I rebooted. I checked nvidia-smi to make sure it loaded and worked OK, and it actually said CUDA 10.1 on there. I had no idea if it was expecting CUDA 10.1, but I downloaded that runfile instead of CUDA 10.2.

Once I ran the cuda-10.1-xxx.run and had the menu, I unchecked the driver (version 418.xx, older than the current driver) and installed. It worked fine. I also went ahead and compiled all the samples in the CUDA toolkit. (Make sure /usr/local/cuda-10.1/bin is on your path so nvcc can be found, put /usr/local/cuda-10.1/lib64 in /etc/ld.so.conf and run sudo ldconfig). You may need to set CUDA_ROOT/–cuda-root and/or the CUDA includes directory for some software, for example compiling pycuda if pip install pycuda fails.

Don’t upgrade anything after installing Ubuntu or Linux Mint 19.3. I found updating the system with sudo apt update ; sudo apt upgrade to be very problematic. Especially if the kernel or anything to do with graphics is updated.

SO make sure you have all nvidia and cuda packages uninstalled to begin with. Settle on the latest nvidia driver and reboot, check it with nvidia-smi. Download the CUDA 10.1 toolkit run file, and run it and deselect the driver from the install options. Just install the CUDA toolkit, samples and documentation.

It should work now. Driver nvidia 435.21 is known to work with CUDA toolkit 10.1 update 1. I haven’t been able to get CUDA toolkit 10.2 to work yet, maybe because I already had a broken Ubuntu install and too many failed attempts to install the nvidia driver and CUDA. This works for both Ubuntu 18.04 and Mint 19.3 though. Just make a snapshot of your system before and after installation, and don’t sudo apt upgrade after that!

Good luck.