# Determine card product
lspci | grep -i nvidia
# Download the drive runfile from https://www.nvidia.com/Download/index.aspx
# switch the X Server off
sudo systemctl set-default multi-user.target
# Reboot. BUT, before rebooting
# Write down the follwing steps
# They will have to be typed in the terminal!
sudo sh <the drive run file> --no-opengl-files --dkms --no-drm
# Then, the at the following prompts, answer as following:
#
# - Prompt: The distribution-provided pre-installed script failed! ....
# Answer: Continue
#
# - Prompt: WARNING: The nvidia-drm module will not be installed.....
# Answer: OK
#
# - Prompt: Would you like ton register the kernel module sources with DKMS?....
# Answer: Yes
#
# - Prompt: Install NVIDIA’s 32-bit...
# Answer: No
# Activate both intel card and nvidia card
sudo prime-select intel
sudo prime-select nvidia
# Switch on X server
sudo systemctl set-default graphical.target
# Reboot
sudo reboot
However, after suspending/hibernating, for unknown reason, CUDA may not be available (torch.cuda.is_available() == False
), a workaround is execting
the following commands:
sudo rmmod nvidia_uvm
sudo modprobe nvidia_uvm
or, making it executed automatically by creating the following script file:
sudo touch /lib/systemd/system-sleep/reload-nvidia
sudo chmod 755 /lib/systemd/system-sleep/reload-nvidia
with the following content
#!/bin/sh
case $1 in
post)
case $2 in
suspend|hibernate)
rmmod nvidia_uvm
modprobe nvidia_uvm
;;
esac
;;
esac