How to install Nvidia drivers to use CUDA without also installing X11?
Solution 1
This worked for me (on Ubuntu 16.04):
sudo apt-get install nvidia-cuda-toolkit lightdm-
lightdm
is the windows manager that nvidia-*
installs. The dash at the end tells apt-get
to uninstall the package but dependency resolution figures out not to install it in the first place. This still installed xserver-common
(so you still get some X11 stuff) but it did not enable graphical booting. (Adding xserver-common-
resulted in broken dependencies.)
PS. You're probably past this problem but this answer is for future internet generations.
Solution 2
The way to do this on recent versions of Ubuntu:
sudo apt install --no-install-recommends nvidia-cuda-toolkit nvidia-headless-440 nvidia-utils-440
This won't install any X11 packages at all. Replace 440
with the driver version you want. nvidia-utils
gives you nvidia-smi
which is a CLI tool to show GPU utilization and temperature and other such information.
If nvidia-smi
returns an error, check /lib/modprobe.d/blacklist-nvidia.conf
and comment out the line alias nvidia off
. Then you can enable the driver with sudo modprobe nvidia
.
Solution 3
sudo apt-get -s install --no-install-recommends nvidia-current
seem to be rather sparse with the dependencies on my box, but it already has a full graphical environment.
What you could in theory do is:
- Let apt-get download the pkg without install:
sudo apt-get -d install nvidia-current
- Pick up the desired deb from the cache:
ls /var/cache/apt/archives/ | grep nvidia-
- Install using dpkg, ignoring relevant dependencies:
dpkg -i --ignore-depends=package1,package2 package3.deb
Dependencies are of course there for a reason, if I where in your situation I'd just let apt
do its thing. Some X11-software won't hurt you much unless you run it.
Solution 4
If running (say, Blender on a headless server, you don't need all those dependencies.
Download the CUDA drivers from as a runfile from: https://developer.nvidia.com/cuda-downloads
Run sudo sh cuda_8.0.44_linux.run
(or newer version)
Download the NVIDIA drivers from http://www.nvidia.com/Download/index.aspx?lang=en-us
Run: sudo sh /backup/iso/NVIDIA-Linux-x86_64-367.44.run
(or newer version)
Note: Every time you update to a newer kernel, you'll have to reload the driver for that kernel. So you may want to add the "-a" (accept license terms) flag after going through them once.
My setup:
- headless Xubuntu 16.04
- dual GeForce 970 cards
- Blender 2.78
Enjoy!
Related videos on Youtube
en4bz
Updated on September 18, 2022Comments
-
en4bz over 1 year
I have a headless box that will be used for CUDA computing. I installed Ubuntu server 16.04.1 but when I try to install the nVidia drivers via apt-get it also wants me to install X11 and other GUI components.
How can I just install the driver and CUDA libs without installing X11 and friends?
Ideally without downloading the run file directly from nVidia. I'd like to use debian packages if possible.
-
Ciro Santilli OurBigBook.com over 7 yearsLook at the package dependencies. X11 should be there. A generic solution could be: askubuntu.com/questions/74523/… The sad truth is that compute is still far from mainstream and often overlooked.
-
-
OpenPrivacy over 7 yearsMany unneeded dependencies not installed this way:
» apt-get -s install nvidia-current | grep newly
0 upgraded, 65 newly installed, 0 to remove and 0 not upgraded. -
Ricardo Magalhães Cruz almost 6 yearsThank you. I can vouch that
ligthdm-
works, even when installing from the official deb. -
Dennis Mungai about 5 yearsDoes this work with the official CUDA repo developer.nvidia.com/cuda-downloads on Ubuntu 18.04LTS?
-
Dennis Mungai almost 5 yearsFollowing up with that logic, then installing CUDA on a headless system on Ubuntu 18.04LTS could be accomplished via:
apt-get install cuda gdm3-
. This would be via the cuda repo for Ubuntu. Test and report back. -
dannysauer about 4 yearsSkipping the
nvidia-settings
graphical nVidia tool cuts things down a lot for me (on 19.10). I'd like to also skip the xserver-xorg-video-nvidia-* package, but that's a hard requirement for the driver, which pulls in the X server junk. So,sudo apt install nvidia-driver-435 nvidia-settings-
is about the best bet, IMO. Addnvidia-cuda-toolkit
onto that package list to get the useful cuda parts. -
Admin almost 2 yearsMore up-to-date:
sudo apt-get install nvidia-headless-510
.