CUDA 2.3

Installing nVidia CUDA 2.1 on gentoo GNU/Linux

Brief notes on installation using gentoo's ebuild portage system

  1. nVidia support CUDA on a number of Linux platforms. However this does not include gentoo.

  2. The three components of CUDA (nVidia device drivers, CUDA and CUDA SDK 2.1) can be installed in that order.

    Installing CUDA SDK 2.1 does not automatically install the other two components. Instead the installation of CUDA SDK 2.1 can fail because CUDA SDK requires components in CUDA.

    Possibly "emerge nvidia-cuda-sdk" could be used to ensure all the missing components required by CUDA SDK are down loaded and installed. However this is not necessary if the three components are installed in order.

  3. These notes suggest using gentoo's ebuild package to down load the required nVidia files (rather than doing it yourself).

  4. login as root.
    Eg via sudo su -

    Some of these steps have to be done as root. Eg adding drivers to the Linux kernel and changing user account privileges. Other parts might be done as a normal user but this has not be investigated.

  5. The packages and their versions support by portage are stored in /usr/portage/
    (The unix find -iname '*nvidia*.ebuild' may be helpful.)

    The ebuild option merge will both fetch the required installation kit and install it. However I preferred to separate the down load and installation phases by using ebuild fetch and later ebuild merge.

  6. Install nVidia device drivers.
    For my device (T10P) version 180.27 was recommended.
    ebuild /usr/portage/x11-drivers/nvidia-drivers/nvidia-drivers-180.27.ebuild fetch
    ebuild /usr/portage/x11-drivers/nvidia-drivers/nvidia-drivers-180.27.ebuild merge
    
    There are various compilation warnings and "QA Notice" but the build seems to go through ok.

    (Still as root) the nVidia drivers installation said it needed the following commands:

    modprobe -r nvidia 
    eselect opengl set nvidia
    

  7. Install nVidia CUDA
    Again for my device CUDA 2.1 was recommended
    ebuild /usr/portage/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-2.1.ebuild fetch
    ebuild /usr/portage/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-2.1.ebuild merge
    
    There is a "QA Notice" but the build seems to go through ok.

  8. Install nVidia CUDA SDK
    The most recent ebuild for CUDA SDK 2.1 in portage was 1215.2015, so this was used. (If your gentoo build is more than a few months old, you might want to ensure its portage files are up to date.)
    ebuild /usr/portage/dev-util/nvidia-cuda-sdk/nvidia-cuda-sdk-2.10.1215.2015.ebuild fetch
    ebuild /usr/portage/dev-util/nvidia-cuda-sdk/nvidia-cuda-sdk-2.10.1215.2015.ebuild merge
    
    There are various compilation warnings (eg for smokeParticles) and the "QA Notice" but the build seems to go through ok.

  9. Added relevant uses to video group by editing /etc/group

  10. create Linux devices for the new hardware

    There are command scripts (eg REHL.bat) to do this but since I have only one device it seemed easier to create my own. (This needs to be run after each reboot.) The first mknod creates a Linux device for the hardware called "nvidia0". If you have more nVidia cards, the next one should be nvidia1, and so on. The last mknod creates a (pseudo) Linux device "nvidiactl" shared by all your nVidia hardware.

    #!/bin/bash
    #
    #REHL.bat
    # much simplified by WBL 19 March 2009
    #
    # Startup script for nVidia CUDA
    #
    # chkconfig: 345 80 20
    # description: Startup/shutdown script for nVidia CUDA
    
    mknod  -m 666 /dev/nvidia0   c 195   0
    #mknod -m 666 /dev/nvidia1   c 195   1 #second card
    #mknod -m 666 /dev/nvidia2   c 195   2 #third card
    mknod  -m 666 /dev/nvidiactl c 195 255
    
    Thats it. All should be well now.

  11. Comfort checks. These should be done by the user (rather than root)
    The Linux command /usr/sbin/lspci, lists whats connected to the PC's PCI bus. Amongst these you should see your nVidia card.

    The nVidia supplied SDK tool deviceQuery show now run and show details of your device:

    /opt/cuda/sdk/bin/linux/release/deviceQuery
    

  12. Edit /etc/conf.d/local.start (as root)
    To automate creating the devices etc at start up edit /etc/conf.d/local.start and append
    echo "Local: /root/boot_nvidia.bat"
    /root/boot_nvidia.bat
    
    #
    
    Where /root/boot_nvidia.bat is as above, except optionally add running deviceQuery. So it now looks something like:
    #!/bin/bash
    #
    #REHL.bat
    # much simplified by WBL 19 March 2009
    #
    # Startup script for nVidia CUDA
    #
    # chkconfig: 345 80 20
    # description: Startup/shutdown script for nVidia CUDA
    
    mknod  -m 666 /dev/nvidia0   c 195   0
    #mknod -m 666 /dev/nvidia1   c 195   1 #second card
    #mknod -m 666 /dev/nvidia2   c 195   2 #third card
    mknod  -m 666 /dev/nvidiactl c 195 255
    
    #prove T10P is working and turn off its fan
    /opt/cuda/sdk/bin/linux/release/deviceQuery
    
    #
    

  13. Starting to code
    /opt/cuda/sdk/projects/ contains many examples and includes their C++ source code. /opt/cuda/sdk/projects/simpleTemplates and /opt/cuda/sdk/projects/template seem like good places to start.

W. B. Langdon 26 March 2009. Last update 28 Nov 2009