Installing NVIDIA graphics drivers on Linux has never been easy for me! I bought a notebook with NVIDIA GTX 1050 GPU recently and installed Kubuntu 16.04. I had to wait for more than a month for NVIDIA to release drivers that supported the notebook 1050 variant.
.runfile directly from NVIDIA's website here. I ran the installation:
$ sudo sh NVIDIA-Linux-x86_64-381.22.run
When I rebooted, I got a black screen! Not surprising with NVIDIA and Linux! I had to uninstall it to get back to work:
$ sudo sh NVIDIA-Linux-x86_64-381.22.run --uninstall
$ sudo apt install nvidia-381
Reboot and I got a new error message in a GUI dialog box:
The system is running in low-graphics mode Your screen, graphics card, and input device settings could not be detected correctly. You will need to configure these yourself.
I had to uninstall it to get back to work:
$ sudo apt purge nvidia-381
.rundriver and installed it without OpenGL:
$ sudo sh NVIDIA-Linux-x86_64-381.22.run --no-opengl-files
After rebooting, I found that I still had a desktop. That was a big relief! I proceeded to download and install CUDA:
$ sudo sh cuda_8.0.61_375.26_linux.run
I took care to not install the graphics driver that comes along with the CUDA installer. That is it! I was able to compile and run the CUDA samples. Running
./deviceQuery from the samples showed the GTX 1050 and that is all I wanted! :)