CUDALink Setup

This section explains how CUDALink is set up and configured for your machine. It also discusses common setup problems and how to troubleshoot them.

Prerequisites

You should confirm that you have GPU hardware supported by CUDA. If you are not certain, you can see the list of hardware supported in the "GPU Hardware" section. In addition, you should check that your operating system is supported. If you do not have supported hardware, you will not be able to fully use CUDALink.

NVIDIA CUDA Toolkit and compatible CUDA driver is required for CUDALink to work. For convenience, NVIDIA includes a compatible CUDA driver with the toolkit.

The CUDA installation packages can be found on the CUDA Downloads Page.

Installation guides for Windows and Linux can be found here:

Installation Guide Windows

Installation Guide Linux

Note that macOS is not supported by NVIDIA.

This loads the CUDALink application:

This checks if CUDALink is supported. If it returns a Success object, as shown below, then CUDALink will work.

CUDALink Compatibility With NVIDIA CUDA Toolkit

The function CUDAToolkitCompatibilityInformation checks if CUDALink is compatible with the user installed NVIDIA CUDA Toolkit:

Core Setup and Testing

The function CUDAQ checks if CUDALink is supported. If it returns True, as shown below, then CUDALink will work.

If CUDAQ does not return True, CUDALink will not work. However, you might be able to configure your machine to fix this. The rest of this section describes steps you can carry out to try and enable CUDALink.

CUDA Driver

For CUDALink to work, you need to have an up-to-date driver. You can check this for your system by running CUDADriverVersion.

In addition, you can check the driver information directly from your computer, as described in "Checking the NVIDIA Driver".

Further Setup and Configuration

You can confirm that CUDALink is working by executing CUDAQ and seeing that this returns True. However, some further configuration and testing may be useful, in particular if you want to use CUDAFunctionLoad.

More detailed information on your hardware is available from the Links section of SystemInformation. A sample is shown below.

This gives detailed information about your hardware. For example, you can tell how many cores are available and if double-precision computations are supported. You can also see how many CUDA devices you have installed on your machine and which is the fastest.

C Compiler

If you want to run your own CUDA kernels with CUDAFunctionLoad, you will also need a C compiler. You can confirm that a suitable C compiler is available with CUDACCompilers.

Nondefault Installation

CUDALink performs many system checks, testing to see if it is supported. The NVIDIA CUDA Toolkit root directory, NVIDIA driver library, NVIDIA driver version, CUDA library path, CUDA library version, and the ability to load the CUDALink runtime libraries are checked before a function such as CUDAQ is called. If any fail, either because the file does not exist in the expected location or because the file is not of a supported version, then an error message is returned, and CUDAQ fails.

By default, CUDALink searches the standard installation location. However, you can set system environment variables to choose different locations. More often than not, if the system has a CUDA-capable card and the proper software is installed, then you may have installed the driver, or the NVIDIA CUDA Toolkit in a nonstandard location. The following section details the environment variables checked.

CUDA_PATH

This is the path to the NVIDIA CUDA Toolkit root directory.

"Windows-x86-64""C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.2"
"Linux-x86-64""/usr/local/cuda-11.2"

Default path to the NVIDA CUDA Toolkit root directory, in case is not defined.

NVIDIA_DRIVER_LIBRARY_PATH

This is the absolute path to the NVIDIA driver library. The library is installed by the NVIDIA driver package downloaded from the NVIDIA driver download website.

"Windows""C:\\Windows\\System32\\nvapi.dll"
"Windows-x86-64""C:\\Windows\\System32\\nvapi64.dll"
"Linux""/usr/lib/libnvidia-tls.so.*"
"Linux-x86-64""/usr/lib64/libnvidia-tls.so.*"
"MacOSX-x86""/Library/Frameworks/CUDA.framework/Versions/Current/CUDA"
"MacOSX-x86-64""/Library/Frameworks/CUDA.framework/Versions/Current/CUDA"

Default path to the NVIDIA driver library in case is not defined.

After detection, the result is stored in .

CUDA_LIBRARY_PATH

This is the absolute path to the CUDA library. The library is installed by the NVIDIA driver package downloaded from the NVIDIA driver download website.

"Windows""C:\\Windows\\System32\\nvcuda.dll"
"Windows-x86-64""C:\\Windows\\System32\\nvcuda.dll"
"Linux""/usr/lib/libcuda.so"
"Linux-x86-64""/usr/lib64/libcuda.so"
"MacOSX-x86""/usr/local/cuda/lib/libcuda.dylib"
"MacOSX-x86-64""/usr/local/cuda/lib/libcuda.dylib"

Default path to the CUDA Library in case is not defined.

After detection, the result is stored in .

Common Errors

No NVCC Compiler

Functions that compile CUDA code accept the "CompilerInstallation". This option can be set to a location of an existing NVCC compiler. Here, you compile using the NVCC compiler located in C:\CUDA.

No C Compiler

NVCC compiler requires a C compiler, the NVCC compiler will not be detected without a valid C compiler.

Supported C compilers are Microsoft Visual Studio on Windows and GCC on Linux.

CUDALink requires a supported C compiler to be installed on the system:

Windows

Linux

If the compiler is not in a standard installation, then the "CompilerIntallation" option can be given to use the nondefault installation, as described in "Setting a Different Compiler" .

Systems with Different GPU Manufacturers

On systems with multiple GPU devices, the NVIDIA driver must be installed last. This will allow the operating system to run the CUDA card using the proper driver.

Laptops that perform automatic video card switching (between an Intel and an NVIDIA card, for example) may interfere with CUDALink's initialization of the CUDA device. On such systems, users can either disable the video card switching behavior, or use tools that allow the user to switch from the menu bar (search the web for "dual-GPU switch" followed by the operating system).

Using CUDALink over Remote Desktop

CUDALink will not work over the Windows Remote Desktop (RDP). Users can use other protocols like VNC to perform remote computation. Unix users can use either SSH or X tunneling.

A recommended alternative to VNC is to set up remote kernels. This allows you to get the interactivity of the front end while running the kernel on a remote CUDA machine. Information on how to set up remote kernels is found in the

documentation page.

Using CUDALink inside a Virtual Machine

Most virtual machines emulate the video card, so you cannot access the GPU for CUDA computation. Unless your virtual machine software supports GPU computation, and the machine is configured to allow the virtual machine to use the GPU, CUDALink is not supported in a virtual machine.

Multiple CUDA Devices

CUDALink is supported on multiple devices using the Wolfram Language's parallel tools. Worker kernels can be launched for each GPU. The maximum number of GPUs supported is limited only by the number of kernels a user can launch.

For information on using multiple devices, refer to

.

Headless Terminals

CUDALink is supported on headless terminals, although sometimes on Linux, due to system configuration, the NVIDIA devices do not get the proper permission. For more information on configuring CUDALink for use on headless terminals, refer to

.