Skip to content

Instantly share code, notes, and snippets.

@pavan71198
Last active May 22, 2023 20:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pavan71198/763bbc469f16a52db7225144474a60cd to your computer and use it in GitHub Desktop.
Save pavan71198/763bbc469f16a52db7225144474a60cd to your computer and use it in GitHub Desktop.
Installing Bumblebee + Nvidia drivers + Nvidia CUDA Toolkit in Ubuntu 18.04 LTS

Installing and setting up Bumblebee + Nvidia drivers + Nvidia Cuda Toolkit in Ubuntu 18.04 LTS

  1. Install bumblebee and nvidia-drivers using this command

    sudo apt install nvidia-driver-390 bumblebee-nvidia
    
  2. Select Intel as your primary display driver

    sudo prime-select intel
    
  3. Make these changes to the Library paths in /etc/bumblebee/bumblebee.conf (because of the changes for GLVND in nvidia driver) and ensure that nvidia driver is selected

    # The Driver used by Bumblebee server. If this value is not set (or empty),
    # auto-detection is performed. The available drivers are nvidia and nouveau
    # (See also the driver-specific sections below)
    Driver=nvidia
    
    [driver-nvidia]
    LibraryPath=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu
    XorgModulePath=/usr/lib/x86_64-linux-gnu/nvidia/xorg,/usr/lib/xorg/modules,/usr/lib/xorg/modules/input
    
  4. Ensure that the file /etc/modprobe.d/blacklist-nvidia.conf has the following contents or else create it with this contents

    This is required to stop system from loading nvidia drivers automatically before calling optirun and for optirun to unload nvidia drivers after exiting

    blacklist nvidia
    blacklist nvidia-drm
    blacklist nvidia-modeset
    alias nvidia-drm off
    alias nvidia-modeset off
    

    also ensure that the line alias nvidia off is not present. If you haven't changed anything after the installation, this should be set directly by the prime-select command.

  5. Ensure that the file /etc/modprobe.d/nvidia-graphics=drivers.conf has the following contents or else create it with this contents.

    This is required to stop system from loading nouveau drivers automatically.

    blacklist nouveau
    blacklist lbm-nouveau
    alias nouveau off
    alias lbm-nouveau off
    

    If you haven't changed anything after the installation, this should be set directly during installation of nvidia-driver-390 package.

  6. Ensure that the GRUB_CMDLINE_LINUX_DEFAULT variable in grub config /etc/defualt/grub has these kernel parameters (and ensure that nvidia-drm.modeset=1 kernel parameter isn't there in it)

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nouveau.runpm=0"
    

    If you haven't changed anything after the installation, this should be set directly by the prime-select command.

  7. Disable nvidia-fallback.service using this command or else this service loads the nouveau driver when nvidia fails.

    systemctl disable nvidia-fallback.service
    
  8. Add this line to /etc/environment for applications with 3D rendering to work

    __GLVND_DISALLOW_PATCHING=1
    
  9. Update initramfs and grub using these command to update the blacklist driver details

    sudo update-initramfs -u -k all
    sudo update-grub
    
  10. Now reboot and ensure that everything is working fine by running (you need to install mesa-utils to run glxheads)

    optirun glxheads
    optirun nvidia-smi
    
  11. Install Nvidia CUDA Toolkit now with this command.

    sudo apt install nvidia-cuda-toolkit
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment