Reference
This feature is not supported on the Wolfram Cloud.

CUDALink allows the Wolfram Language to use the CUDA parallel computing architecture on Graphical Processing Units (GPUs). It contains functions that use CUDA-enabled GPUs to boost performance in a number of areas, such as linear algebra, financial simulation, and image processing. CUDALink also integrates CUDA with existing Wolfram Language development tools, allowing a high degree of automation and control.

This section summarizes the functionality.

Wolfram Language Functions

This describes the Wolfram Language functions provided by CUDALink.

Query

CUDAQdetermine whether CUDALink is supported
CUDAInformationenumerate all device information
CUDADriverVersiongive video driver version
$CUDADeviceCountnumber of devices on system
$CUDALinkPathpath to the CUDALink application
$CUDADevicedevice used in CUDALink computation

Functions for querying the setup of CUDALink.

Resource Installation

CUDAResourcesInstallinstall the CUDA resources
CUDAResourcesInformationgive information on installed CUDA resources
CUDAResourcesUninstalluninstall the CUDA resources

Functions for installing and uninstalling CUDALink resources.

Image Processing

CUDAImageConvolveconvolve images with specified kernel
CUDABoxFilterapply the box filter on images

Filtering functions for image processing using CUDA.

CUDADilationapply morphological dilation on images
CUDAErosionapply morphological dilation on images
CUDAClosingapply morphological closing on images
CUDAOpeningapply morphological opening on images

Morphological functions for image processing using CUDA.

CUDAImageAddadd two images
CUDAImageSubtractsubtract two images
CUDAImageMultiplymultiply two images
CUDAImageDividedivide two images
CUDAClampclamp values of an image between a specified range
CUDAColorNegateinvert an image

Binary operations for image processing using CUDA.

Fourier Transform

CUDAFourierfind the Fourier transform
CUDAInverseFourierfind the inverse Fourier transform

Fourier transform operations using CUDA.

Linear Algebra

CUDADotgive product of vectors and matrices
CUDATransposetranpose input matrix
CUDAArgMaxListgive the index with maximum absolute element
CUDAArgMinListgive the index with minimum absolute element
CUDATotalgive the total of the absolute values of a vector

Linear algebra functions using CUDA.

CUDALink Programming

CUDAFunctionhandle to CUDA function loaded using CUDAFunctionLoad
CUDAFunctionLoadload CUDAFunction into the Wolfram Language
CUDAFunctionInformationget CUDAFunction information

Working with CUDA functions.

NVCCCompilercompile code using the NVIDIA CUDA compiler
CUDACCompilersgive list of supported C compilers installed on system

Access to the CUDA compiler.

SymbolicCUDAFunctionsymbolic representation of a CUDA function
SymbolicCUDABlockIndexsymbolic representation of a block index CUDA call
SymbolicCUDAThreadIndexsymbolic representation of a thread index CUDA call
SymbolicCUDABlockDimensionsymbolic representation of a block dimension CUDA call
SymbolicCUDACalculateKernelIndexsymbolic representation of a CUDA index calculation
SymbolicCUDADeclareIndexBlocksymbolic representation of a CUDA index declaration

Symbolic representations of CUDA programs.

Memory

CUDAMemoryhandle to CUDA memory registered using CUDAMemoryLoad or CUDAMemoryAllocate
CUDAMemoryLoadload Wolfram Language memory into CUDALink returning CUDAMemory
CUDAMemoryAllocateallocate memory for CUDALink returning CUDAMemory
CUDAMemoryGetcopy CUDAMemory to the Wolfram Language
CUDAMemoryUnloadunload and delete a CUDAMemory handle
CUDAMemoryInformationget CUDAMemory handle information
CUDAMemoryCopyToHostcopy CUDAMemory from GPU to CPU
CUDAMemoryCopyToDevicecopy CUDAMemory from CPU to GPU

Functions for working with memory in CUDA.

CUDALink Examples

CUDAFinancialDerivativefinancial option valuation
CUDAMapapply a function to each element on an input list
CUDASortsort input elements
CUDAFoldfold input elements
CUDAFoldListfold input elements into a list
CUDAVolumetricDataReadread raw volumetric data to be rendered
CUDAVolumetricRenderrender volumetric data read
CUDAFluidDynamicscompute and render a fluid dynamics simulation

Example applications of CUDALink.

CUDAQ and CUDAInformation

CUDAInformation gives user information on the hardware. To use, first load the CUDALink application.

In[1]:=
Click for copyable input

This gets information on the CUDA devices on the system.

In[2]:=
Click for copyable input
Out[2]=

Similar to other Wolfram Language functions, CUDAQ will not return an error on failure. Running CUDAInformation will give an error describing why CUDA failed.

If CUDALink fails, it will return one of the following errors.

insysCUDALink is not supported on the system; only "Linux", "Linux-x86-64", "Windows", "Windows-x86-64", "MacOSX-x86", and "MacOSX-x86-64" are supported
invdevnmbased on the video card name, the video card is not supported by CUDALink
invdirvan NVIDIA driver library was not found, and CUDALink was not able to determine the NVIDIA driver library path
invdrivpan NVIDIA driver was not found in the NVIDIA library path
invdrivveran NVIDIA driver was found, but the version information cannot be determined
invdrivvervan NVIDIA driver was found, but the version is unsupported
invdrivverdan NVIDIA driver was found, but the version directory cannot be determined
syslibfldloading the CUDA runtime libraries failed
initlibloading the CUDALink library failed
initCUDALink libraries were loaded, but initialization failed
nodevCUDALink was unable to find a device that is CUDA compatible

CUDALink detection failure error codes.

There are three main reasons for getting False from CUDAQ:

  • Unsupported operating system CUDA is not supported on SUN's Solaris or versions of Apple's OS X earlier than 10.6.3.
  • Unsupported hardware CUDA only works on CUDA-capable graphics cards.
  • Incompatible graphics driver a recent NVIDIA driver is needed for CUDA to operate properly.

System Requirements

CUDALink requires a compatible operating system, hardware, and driver software. This section describes what these are and how to confirm them.

Operating System

CUDALink is supported on Linux, Linux-x86-64, Windows, Windows-x86-64, Mac OS X-x86, and Mac OS X-x86-64. Mac OS X users need at least Mac OS X 10.6.3.

On Linux, CUDALink requires the system to be run in a runlevel that will load the video drivers. Usually this is default level 5, but on some servers the administrator may need to configure it manually.

GPU Hardware

CUDALink is supported on all hardware that has CUDA support. If you are not sure of the name of your graphics card, you can see the section on Graphics Card Information.

The following hardware is currently supported:

  • NVIDIA Tesla: Tesla K40, Tesla K20X, Tesla K20, Tesla K10, Tesla C2050/2070, Tesla M2050/M2070, Tesla S2050, Tesla S1070, Tesla M1060, Tesla C1060, Tesla C870, Tesla D870, and Tesla S870.
  • NVIDIA Quadro: Quadro K6000, Quadro K5000, Quadro K4000, Quadro K2000D, Quadro K2000, Quadro K600, Quadro 6000, Quadro 5000, Quadro 4000, Quadro 2000, Quadro 600, Quadro FX 5800, Quadro FX 5600, Quadro FX 4800, Quadro FX 4700 X2, Quadro FX 4600, Quadro FX 3800, Quadro FX 3700, Quadro FX 1800, Quadro FX 1700, Quadro FX 580, Quadro FX 570, Quadro FX 380, Quadro FX 370, Quadro NVS 510, Quadro NVS 450, Quadro NVS 420, Quadro NVS 295, Quadro Plex 1000 Model IV, and Quadro Plex 1000 Model S4.
  • NVIDIA Quadro Mobile: Quadro K5100M, Quadro K5000M, Quadro K4100M, Quadro K4000M, Quadro K3100M, Quadro K3000M, Quadro K2100M, Quadro K2000M, Quadro K1100M, Quadro K1000M, Quadro K610M, Quadro K510M, Quadro K500M, Quadro 5010M, Quadro 5000M, Quadro 4000M, Quadro 3000M, Quadro 2000M, Quadro 1000M, Quadro FX 3800M, Quadro FX 3700M, Quadro FX 3600M, Quadro FX 2800M, Quadro FX 2700M, Quadro FX 1800M, Quadro FX 1700M, Quadro FX 1600M, Quadro FX 880M, Quadro FX 770M, Quadro FX 570M, Quadro FX 380M, Quadro FX 370M, Quadro FX 360M, Quadro NVS 320M, Quadro NVS 160M, Quadro NVS 150M, Quadro NVS 140M, Quadro NVS 135M, and Quadro NVS 130M.
  • GeForce: GeForce GTX Titan Z, GeForce GTX TITAN Black, GeForce GTX TITAN, GeForce GTX 780 Ti, GeForce GTX 780, GeForce GTX 770, GeForce GTX 760, GeForce GTX 750 Ti, GeForce GTX 750, GeForce GT 740, GeForce GTX 690, GeForce GTX 680, GeForce GTX 670, GeForce GTX 660 Ti, GeForce GTX 660, GeForce GTX 650 Ti BOOST, GeForce GTX 650 Ti, GeForce GTX 650, GeForce GT 640, GeForce GT 630, GeForce GT 620, GeForce GT 610, GeForce GTX 590, GeForce GTX 580, GeForce GTX 570, GeForce GTX 560 Ti, GeForce GTX 560, GeForce GTX 550 Ti, GeForce GT 520, GeForce GTX 480, GeForce GTX 470, GeForce GTX 465, GeForce GTX 460, GeForce GTX 460 SE, GeForce GTS 450, GeForce GT 440, GeForce GT 430, GeForce GT 420, GeForce GTX 295, GeForce GTX 285, GeForce GTX 280, GeForce GTX 275, GeForce GTX 260, GeForce GTS 250, GeForce GTS 240, GeForce GT 240, GeForce GT 220, GeForce 210/G210, GeForce GT 140, GeForce 9800 GX2, GeForce 9800 GTX+, GeForce 9800 GTX, GeForce 9800 GT, GeForce 9600 GSO, GeForce 9600 GT, GeForce 9500 GT, GeForce 9400 GT, GeForce 9400 mGPU, GeForce 9300 mGPU, GeForce 9100 mGPU, GeForce 8800 Ultra, GeForce 8800 GTX, GeForce 8800 GTS, GeForce 8800 GT, GeForce 8800 GS, GeForce 8600 GTS, GeForce 8600 GT, GeForce 8600 mGT, GeForce 8500 GT, GeForce 8400 GS, GeForce 8300 mGPU, GeForce 8200 mGPU, and GeForce 8100 mGPU.
  • GeForce Mobile: GeForce GTX 880M, GeForce GTX 870M, GeForce GTX 860M, GeForce GTX 850M, GeForce 845M, GeForce 840M, GeForce 830M, GeForce GTX 780M, GeForce GTX 770M, GeForce GTX 765M, GeForce GTX 760M, GeForce GT 750M, GeForce GT 745M, GeForce GT 740M, GeForce GT 735M, GeForce GT 730M, GeForce GTX 680MX, GeForce GTX 680M, GeForce GTX 675MX, GeForce GTX 675M, GeForce GTX 670MX, GeForce GTX 670M, GeForce GTX 660M, GeForce GT 650M, GeForce GT 645M, GeForce GT 640M, GeForce GTX 580M, GeForce GTX 570M, GeForce GTX 560M, GeForce GT 555M, GeForce GT 550M, GeForce GT 540M, GeForce GT 525M, GeForce GT 520M, GeForce GTX 480M, GeForce GTX 470M, GeForce GTX 460M, GeForce GT 445M, GeForce GT 435M, GeForce GT 425M, GeForce GT 420M, GeForce GT 415M, GeForce GTX 285M, GeForce GTX 280M, GeForce GTX 260M, GeForce GTS 360M, GeForce GTS 350M, GeForce GTS 260M, GeForce GTS 250M, GeForce GT 335M, GeForce GT 330M, GeForce GT 325M, GeForce GT 320M, GeForce 310M, GeForce GT 240M, GeForce GT 230M, GeForce GT 220M, GeForce G210M, GeForce GTS 160M, GeForce GTS 150M, GeForce GT 130M, GeForce GT 120M, GeForce G110M, GeForce G105M, GeForce G103M, GeForce G102M, GeForce G100, GeForce 9800M GTX, GeForce 9800M GTS, GeForce 9800M GT, GeForce 9800M GS, GeForce 9700M GTS, GeForce 9700M GT, GeForce 9650M GT, GeForce 9650M GS, GeForce 9600M GT, GeForce 9600M GS, GeForce 9500M GS, GeForce 9500M G, GeForce 9400M G, GeForce 9300M GS, GeForce 9300M G, GeForce 9200M GS, GeForce 9100M G, GeForce 8800M GTX, GeForce 8800M GTS, GeForce 8700M GT, GeForce 8600M GT, GeForce 8600M GS, GeForce 8400M GT, GeForce 8400M GS, GeForce 8400M G, and GeForce 8200M G.
    • ION: ION.

    An updated list of device support can be found on the NVIDIA CUDA-Enabled Products page.

    Users with ATI or Intel graphics processors will not be able to use CUDA, but might be able to use OpenCL using OpenCLLink.

Double-Precision Support

CUDALink will use double precision if it is available on the hardware detected. The following hardware has double-precision support:

  • NVIDIA Tesla Workstation: Tesla C2050/C2070 and Tesla C1060.
  • NVIDIA Tesla Data Center: Tesla M2050/M2070, Tesla S2050, Tesla S1070, and Tesla M1060.
  • NVIDIA Quadro: Quadro 6000, Quadro 5000, Quadro 4000, Quadro FX 5800, Quadro FX 4800, and Quadro FX 3800.
  • NVIDIA Quadro Mobile: Quadro 5000M.
    • GeForce: GeForce GTS 480, GeForce GTS 470, GeForce GTS 465, GeForce GTS 460, GeForce GTS 450, GeForce GTX 295, and GeForce GTX 285.

    If double-precision support is not detected, then CUDALink will represent floating-point numbers in single precision.

    An updated list of computer capability can be found on the NVIDIA CUDA-Enabled Products page.

    Programmatically, you can detect whether the cards on the system support double precision using CUDAInformation and checking if the is greater than or equal to 1.3.

    Detect which cards on the system support double precision using CUDAInformation.
    In[1]:=
    Click for copyable input
    Out[1]=

Graphics Card Information

Detailed information on your graphics can be found in the section of SystemInformation, as shown below.

In[1]:=
Click for copyable input
Out[1]=

This gives information on the graphics card installed on the system.

If you have trouble finding this, then checking the graphics card is done by either checking the system documentation or going to one of the following:

  • Device Manager on Windows
  • System Information on Mac OS X
  • Invoking lspci on Linux

Checking the NVIDIA Driver

CUDALink has a driver version detection mechanism that is accessible using CUDADriverVersion.

In[1]:=
Click for copyable input
Out[1]=

An alternative to this driver detection method is operating-system specific. The following details how to get the driver version on Windows, Linux, and Mac OS X.

Windows

If the NVIDIA driver is installed, then the NVIDIA control panel should be in the system's control panel and will give you information. The NVIDIA control panel can be accessed by clicking Start Control Panel.

Inside the control panel you will see the NVIDIA control panel.

Clicking on that will open windows that allow you to edit the hardware setup.

Clicking System Information in the bottom-left corner will give you the following window.

This tells you the driver version, which is 257.21 on this machine.

Linux

If the NVIDIA driver is installed, then running from the command line will give version information. The following screen capture shows the system running the 256.53 version of the NVIDIA driver, which can be seen in the "NVIDIA Driver Version" system information.

If X is not available, then the following command will tell you the driver version installed.

[abduld@abduldlx ~]$ ls /usr/lib/libnvidia-tls.so.*
/usr/lib/libnvidia-tls.so.2 /usr/lib/libnvidia-tls.so.256.53.15

The above tells you a non-supported NVIDIA driver 256.53.15 is installed on . Note that on some versions of Linux the drivers are installed in or in another nondefault location.

Mac OS X

To find the version information on OS X, open the Finder window and go into Applications.

Opening System Preferences will show a CUDA button if the CUDA driver is installed.

Clicking on the CUDA button will show both the CUDA driver and GPU driver versions.

CUDA driver version 6.0.0 or above is required by CUDALink.