Installing nvidia-drm-kmod on FreeBSD

   The nvidia-drm-kmod is a brand new open-source driver which is a FreeBSD port of Linux's nvidia-drm.ko file that interfaces with DRM subsystem. While Intel and AMD GPU drivers have already official drm-kmod drivers, Nvidia is still stuck with proprietary drivers until the introduction of nvidia-drm-kmod. The main purpose for this driver is to make Wayland compositor to work correctly albeit there are some issues. You can install it into your FreeBSD system instead of readily-made non-DRM Nvidia drivers, however, it is still in testing stage so expect some hiccups. Note that you will need to install outside the ports collection to make it work properly. You can also install it from ports collection, however, it needs a similar setup like here.



1. Gathering the kernel source tree files and drm-kmod source file.

i) Download the kernel source tree:
            $ git clone https://github.com/freebsd/freebsd-src/ /usr/src
      
     or download the kernel source tree according to your FreeBSD version:
      $ git clone  https://github.com/freebsd/freebsd-src/ --branch [version] /usr/src
     
     Example:
      $ git clone  https://github.com/freebsd/freebsd-src/ --branch stable/13 /usr/src

OR, you can just grab the kernel source package from installation disc or img file and paste into /usr/src directory, depending on your setup:

     Example: 

           $ cp /media/cdrom/usr/freebsd-dist/src.txz /
      $ cd / && tar -xvf src.txz

ii) Download the FreeBSD drm-kmod source file*:

          For FreeBSD 13.1* users:
          $ git clone https://github.com/freebsd/drm-kmod --branch 5.10-lts ~/git/drm-kmod
          For FreeBSD 14.0 -CURRENT users: 
          $ git clone https://github.com/freebsd/drm-kmod --branch master ~/git/drm-kmod
 
iii) Download the nvidia-drm-kmod source file*:
         $ git clone https://github.com/amshafer/nvidia-driver

*NOTE: If you planned to install it from the ports, skip that part


2. Setting Up Dependencies:

i) Installing linux compatibility packages and etc:

        $ pkg install linux-nvidia-libs linux_base-c7 nvidia-xconfig

ii) Activating linux emulator module:

         $ sysrc linux_enable="YES"

iii) Editing linux mount points in /etc/fstab, just copy and paste the line:

      linprocfs   /compat/linux/proc   linprocfs   rw    0    0
   linsysfs     /compat/linux/sys     linsysfs      rw    0     0

iv) Either mount it or just reboot it so it can be mount automatically later.

           $ mount /compat/linux/proc && mount /compat/linux/sys

v) Update the ports to before building nvidia-driver 535 version

          $ portsnap fetch && portsnap extract

vi) Installing the nvidia-driver version 535 first:

           $ cd /usr/ports/x11/nvidia-driver
           $ make install
           $ kldload nvidia-modeset 
      $ nvidia-xconfig 

If nvidia-driver package is setup correctly and able to display graphics, confirm the version that you are installing by running Nvidia X Settings Manager and look at its version. 


3. Editing the Makefile before starts compiling.

For some reasons at the time of writing, the nvidia-drm-kmod wil fail to install due to unable to point the exact directory of drm-kmod kernel source driver where it just points towards the root's own home directory instead of your local username directory. What you do need is to edit the Makefile inside the nvidia-driver directory and enter the full directory address of drm-kmod kernel source driver instead of holding the directory shell variables.

     Open up the file with text editor:

           $ nano ~/nvidia-driver/nvidia/src/nvidia-drm/Makefile

      Then, search and replace the line from:

       DRMKMODDIR ?= ${HOME}/git/drm-kmod

      To something like this:

       DRMKMODDIR ?= /home/[username]/git/drm-kmod

 PS: If you're planning to build it from ports, skip that part.

 

3. Installing and running up nvidia-drm-kmod

METHOD 1: Building from github source:

 After compiling the github source, navigate the directory and perform installation:

       $ cd nvidia-driver
       $ make && make install

The nvidia-drm-kmod will be loaded automatically after installation. If you see the kernel module fail to load error message while compiling on GUI, don't worry - you will need to load it on /etc/rc.conf file to be activated later and/or replace existing drm module or nvidia-driver module with nvidia-drm:

      $ sysrc kld_list+=nvidia-drm

 

METHOD 2: Installing from ports. 

Assuming that you have already updating the ports collection, navigate to the nvidia-drm port directory:

           $ cd /usr/ports/graphics/nvidia-drm-kmod
      $ make install
 
Add nvidia-drm module into /etc/rc.conf and replace any existing drm modules or nvidia-driver module with nvidia-drm
      $ sysrc kld_list+=nvidia-drm


4. Verifying the nvidia-drm-kmod installation

Setting up the graphical desktop and enable back login screen if disabled before installation. Then run the nvidia-smi command to display the GPU info inside the terminal:

        $ nvidia-smi

Also, open up Nvidia X Server Settings and verify that the GPU driver is installed correctly. Note that nvidia-drm-kmod is equipped with very, very latest of Nvidia GPU driver installed and this version isn't available on official FreeBSD package nor its ports yet.


 



       

Comments

Popular posts from this blog

Setting Up GPU Cards on FreeBSD 13

How To Setup Optical Drives on FreeBSD