Using CUDA with the native FreeBSD/amd64 NVIDIA driver

Nearly a year ago NVIDIA released a native GPU driver for FreeBSD/amd64.  At one point while testing an earlier BETA version of the driver (195.22) I played around with CUDA.  These notes are just a summary of the setup I used during my testing.  I built apps from the CUDA SDK on a Linux/i386 box and then ran them on a FreeBSD/amd64 box.  I will only cover setting up the FreeBSD box here.  For these tests I used version 2.3 of the CUDA SDK and toolkit for RHEL 4.x / i386.

  1. Setup Linux compatibility on the FreeBSD machine
    • Install a suitable linux_base package
    • Mount linprocfs(4) and linsysfs(4)
  2. Install the NVIDIA graphics driver and add missing libcuda.so symlink

    # cd /somepath/NVIDIA-FreeBSD-x86_64-195.22
    # make install
    # cd /compat/linux/usr/lib
    # ln -sf libcuda.so.1 libcuda.so

    The driver should attach to any NVIDIA GPUs or CUDA devices:

    nvidia0: on vgapci0
    vgapci0: child nvidia0 requested pci_enable_busmaster
    vgapci0: child nvidia0 requested pci_enable_io
    vgapci0: child nvidia0 requested pci_enable_io
    nvidia0: [GIANT-LOCKED]
    nvidia0: [ITHREAD]
    nvidia1: on vgapci1
    vgapci1: child nvidia1 requested pci_enable_busmaster
    vgapci1: child nvidia1 requested pci_enable_io
    vgapci1: child nvidia1 requested pci_enable_io
    nvidia1: [GIANT-LOCKED]
    nvidia1: [ITHREAD]

  3. Start a root Linux shell:

    # /compat/linux/bin/sh
    sh-3.00#

  4. Install the CUDA toolkit:

    sh-3.00# sh /somepath/cudatoolkit_2.3_linux_32_rhel4.7.run
    Verifying archive integrity… All good.
    Uncompressing NVIDIA CUDA………………………………………………………………………………………………………………………
    Enter install path (default /usr/local/cuda, ‘/cuda’ will be appended):
    <… lots of files installed into /usr/local/cuda >

  5. Add /usr/local/cuda to /compat/linux/etc/ld.so.conf and run the Linux ldconfig as root:

    sh-3.00# echo /usr/local/cuda/lib >> /etc/ld.so.conf
    sh-3.00# ldconfig
    ldconfig: /usr/local/cuda/lib/libcudart.so.2 is not a symbolic link

    ldconfig: /usr/local/cuda/lib/libcufft.so.2 is not a symbolic link

    ldconfig: /usr/local/cuda/lib/libcufftemu.so.2 is not a symbolic link

    ldconfig: /usr/local/cuda/lib/libcublasemu.so.2 is not a symbolic link

    ldconfig: /usr/local/cuda/lib/libcublas.so.2 is not a symbolic link

  6. Install the CUDA SDK:

    sh-3.00# sh /somepath/cudasdk_2.3_linux.run
    Verifying archive integrity… All good.
    Uncompressing NVIDIA GPU Computing SDK…………………………………………………………………………………………………………..
    Enter install path (default ~/NVIDIA_GPU_Computing_SDK):
    ….

In this case I installed the CUDA SDK to my home directory which was shared with the Linux/i386 build box that I used via NFS. I compiled the binaries on the Linux/i386 host and then ran them on the FreeBSD/amd64 machine. At this point I no longer have access to the hardware in question so I am not able to provide any output or screenshots from the CUDA SDK applications. While native support for CUDA applications with FreeBSD would be nice, the current capabilities are certainly enough for further investigation and evaluation.

3 Responses to “Using CUDA with the native FreeBSD/amd64 NVIDIA driver”

  1. [...] This post was mentioned on Twitter by Tech & Friki Stuff, dikshie. dikshie said: using cuda in FreeBSD's native nvidia 64 bit driver http://bit.ly/cBtEWV [...]

  2. Jacob Frelinger says:

    I’m using ‘cuda’ on Freebsd using a similar setup, using the linux_gentoo_state3 port and chrooting into it’s env. This has the advantage of being able to build cuda apps on the freebsd box and not needing to use a linux box to build them.

  3. Eduardo says:

    Can you make an update to it? How’s the new nvidia driver working?

    Thanks

Leave a Reply