Fix Blank Screen Nvidia Optimus Laptop Linux and Cuda

Image for post
Image for post

Checklist

Image for post
Image for post
Find your card’s compute capability at https://en.wikipedia.org/wiki/CUDA or check using their website https://www.nvidia.com/download/index.aspx?lang=en-us.
Image for post
Image for post
Go to https://docs.nvidia.com/deploy/cuda-compatibility/index.html and check which cuda version supports base on Nvidia driver version.
Image for post
Image for post
Go to https://docs.nvidia.com/deploy/cuda-compatibility/index.html and check which cuda version supports base on compute capability. If it is 2.x Fermi or lower, you have to try Cuda 8 and lower if it still does not work.

Restore Default

sudo su
apt install aptitude
aptitude search nvidia
aptitude search cuda
aptitude search bumblebee
aptitude search primus
apt-get purge 'nvidia.*'
apt-get purge 'cuda.*'
apt-get purge 'bumblebee.*'
apt-get purge 'primus.*'
apt-get install 'nouveau.*'

Install Nvidia Video Driver

apt update
apt full-upgrade
lspci -v
apt install nvidia-kernel-dkms
apt install nvidia-smi
reboot

Fixing Blank Screen After Nvidia Driver Installation

apt show nvidia-kernel-dkms
aptitude search nvidia
apt install nvidia-legacy-390xx-kernel-dkms
reboot
apt install mesa-opencl-icd
reboot
apt install nvidia-opencl-icd
reboot
apt install bbswitch-dkms bumblebee-nvidia
nano /etc/bumblebee/bumblebee.conf
nano /etc/bumblebee/xorg.conf.nvidia
reboot
lspci -v
nvidia-smi
lsmod
glxgears
glxdemo
glxinfo

Install Cuda Toolkit

apt show nvidia-cuda-toolkit
apt install nvidia-cuda-toolkit
nvcc -V
type nvcc
ls /usr/lib/nvidia-cuda-toolkit
dpkg -i [your deb package].deb
apt-key add /var/cuda...../[...].pub (which will be shown on your terminal)
apt update && apt install cuda-toolkit-8-0
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/cuda/bin"
LD_LIBRARY_PATH="/usr/local/cuda/lib64:/usr/local/cuda/targets/x86_64-linux/lib"
reboot
nvcc -V
apt install gcc-5 g++-5
sudo ln -s $(which gcc-5) /usr/local/bin/gcc
sudo ln -s $(which g++-5) /usr/local/bin/g++
hash -r
sudo rm /usr/local/bin/gcc /usr/local/bin/g++
hash -r
sudo chmod +x cuda_8.0.61_375.26_linux.run
sudo sh cuda_8.0.61_375.26_linux.run --override
Follow the command-line prompts
Do you accept the previously read EULA?
accept/decline/quit: accept
You are attempting to install on an unsupported configuration. Do you wish to continue?
(y)es/(n)o [ default is no ]: yes
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
(y)es/(n)o/(q)uit: no
Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: yes
Enter Toolkit Location
[ default is /usr/local/cuda-8.0 ]:
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: yes
Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: yes
Enter CUDA Samples Location
[ default is /home/fajarpurnama ]: /usr/local/cuda-8.0/samples
Edit /etc/environment, edit and add the following lines:PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/cuda/bin"
LD_LIBRARY_PATH="/usr/local/cuda/lib64:/usr/local/cuda/targets/x86_64-linux/lib"

this blog contains all my articles licensed under creative commons attribution customized sharealike (cc-by-sa) where you can sell but mention the open one here

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store