Installing proprietary NVIDIA drivers, particularly packages like the CUDA toolkit, often requires specific system preparation. A common prerequisite is the disabling of the default open-source Nouveau kernel driver for NVIDIA graphics hardware.
Attempting installation while Nouveau is active can lead to errors, as indicated by messages within installer logs like /var/log/nvidia-installer.log
, stating that the Nouveau driver is in use.
This article outlines several methods derived from common practices to successfully disable the Nouveau driver, clearing the path for a smooth NVIDIA driver installation.
Understanding the Conflict
The Nouveau driver provides open-source 3D acceleration for NVIDIA graphics cards. While suitable for general desktop use, it conflicts with the proprietary NVIDIA drivers, which require exclusive control over the hardware.
The NVIDIA installer actively checks for loaded Nouveau modules and will typically abort if it detects them, necessitating manual intervention to prevent Nouveau from loading during system boot.
Configuration changes are typically made within the /etc/modprobe.d/
directory, which contains files instructing the system on how to handle kernel modules.
After modifying these configurations, the initial RAM filesystem (initramfs), used during the early stages of booting, must be updated to incorporate these changes.
Methods to Disable the Nouveau Driver
Multiple approaches exist to prevent the Nouveau driver from loading. Below are distinct methods commonly employed.
Read: How to Display Your Graphics Card Information on Ubuntu 24.04
Method 1: Using `blacklist` and `modeset` Options
This approach involves creating a configuration file to instruct the module loading system to ignore Nouveau and prevent it from controlling display modes.
- Create a new configuration file within
/etc/modprobe.d/
. A common name isblacklist-nouveau.conf
, although other.conf
filenames within this directory will work.sudo nano /etc/modprobe.d/blacklist-nouveau.conf
Note: While
blacklist-nouveau.conf
is used here, any filename ending in.conf
placed in/etc/modprobe.d/
can serve this purpose. Consistency often favors descriptive names. - Add the following lines to the file:
blacklist nouveau options nouveau modeset=0
The
blacklist nouveau
line suggests that the module loading system should not load the Nouveau driver automatically. Theoptions nouveau modeset=0
line aims to prevent Nouveau from initializing display modes early in the boot process. - Regenerate the kernel initramfs to apply the changes.
sudo update-initramfs -u
- Reboot the system for the changes to take effect.
sudo reboot
Method 2: Comprehensive Blacklisting and Aliasing
This method expands on the blacklisting approach, adding more directives and potentially including prerequisite package installations for systems where kernel modules might need recompilation (like during NVIDIA driver installation).
- (Optional) Ensure no previous NVIDIA packages interfere. If necessary, remove existing installations:
sudo apt-get remove nvidia* && sudo apt autoremove
- (Optional) Install packages often required for building kernel modules. This might be needed for the subsequent NVIDIA driver installation itself:
sudo apt-get install dkms build-essential linux-headers-generic
- Edit or create a blacklist configuration file, for example,
/etc/modprobe.d/blacklist.conf
:sudo vim /etc/modprobe.d/blacklist.conf
- Insert the following lines to comprehensively block Nouveau:
blacklist nouveau blacklist lbm-nouveau options nouveau modeset=0 alias nouveau off alias lbm-nouveau off
These lines add further blacklist entries and use `alias off` to reinforce the disabling of the Nouveau module.
- (Potentially Redundant) Explicitly set the modeset option in another file (though this may be covered by step 4):
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
Note that the file
nouveau-kms.conf
might not exist initially; this command will create it if necessary. - Update the initramfs:
sudo update-initramfs -u
- Reboot the system:
sudo reboot
Read: How to display your sound card details using the terminal on Ubuntu 22.04
Method 3: Forcing Module Load Failure with `install /bin/false`
This technique offers a more definitive way to prevent a module from being loaded via `modprobe` by replacing the command to install the module with a command that always fails (`/bin/false`).
- Create or overwrite a configuration file in
/etc/modprobe.d/
. Ensure this file contains only the following directive:echo 'install nouveau /bin/false' | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
This command writes the single line `install nouveau /bin/false` into the specified file, replacing any existing content.
- Update the initramfs:
sudo update-initramfs -u
- Reboot the system:
sudo reboot
This method directly prevents the `nouveau` module from being successfully loaded through standard mechanisms.
System-Specific Initramfs Update Commands
The command to update the initramfs varies across different Linux distributions:
- Debian/Ubuntu:
sudo update-initramfs -u
- Fedora:
sudo dracut --regenerate-all -f
- Arch Linux:
sudo mkinitcpio -p
(e.g.,sudo mkinitcpio -p linux
. Find your preset file in/etc/mkinitcpio.d/
).
Verification and Post-Reboot Steps
After applying one of the methods and rebooting:
- Attempt the NVIDIA driver installation again (e.g., run the
cuda_*.run
installer). It should now proceed past the Nouveau driver check. - To specifically test Method 3’s effectiveness, you can try manually loading the Nouveau module:
sudo modprobe nouveau
If the `install nouveau /bin/false` directive is working correctly, this command should fail, confirming the module cannot be loaded. In contrast, using only the `blacklist` directive might still allow manual loading via `modprobe`.
- In some environments, it may still be necessary to stop the graphical display manager before running the NVIDIA installer from a text console (TTY). Access a TTY (e.g., using Ctrl+Alt+F1 through F6) and stop the display service (e.g.,
sudo service lightdm stop
,sudo systemctl stop gdm
, or similar, depending on your desktop environment).
Potential Considerations:
- Occasionally, applying these changes might lead to unexpected boot issues, such as a black screen, particularly if fallback display drivers are not configured correctly. Proceed with caution, especially on critical systems.
- Removing temporary X server lock files (e.g., in
/tmp
) has sometimes been reported as a necessary additional step, though this is less common.
Conclusion
Disabling the Nouveau kernel driver is a frequent requirement when installing proprietary NVIDIA drivers on Linux systems. The methods outlined above, involving modifications to modprobe.d
configurations and updating the initramfs, provide effective ways to prevent the Nouveau driver from loading.
Using either ‘blacklist’ with ‘modeset=0’ or the more forceful ‘install /bin/false’ directive should resolve conflicts and allow the NVIDIA driver installation to proceed successfully.
If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.