Configuring Kernels for Parallel Computing

You can use local and remote additional kernels for performing parallel computations. Local kernels, using additional cores on your CPU, usually do not need any configuration, but for remote kernels you need to specify where they are and how to access the remote resources.

$DefaultParallelKernelslist of kernel configurations to launch by default
KernelConfiguration["URL"]configuration for a launchable kernel
LaunchKernels[]launch configured kernels

Configuration of kernels for parallel computing.

Introduction: The Default Setting

By default, local kernels are used for parallel computation:
The number of kernels launched is equal to the machine's $ProcessorCount:

The string "localhost" or "Local" is a short form of a kernel configuration. To obtain all properties of a kernel configuration, turn it into a configuration object and query it for its properties.

Turn the short form into a kernel configuration object:
Obtain its properties:
Or obtain an association with its properties:
You can easily launch a specific number of local kernels:

Managing Configurations

When you assign a new value to $DefaultParallelKernels, any subsequent use of LaunchKernels[] in the current session will use these kernels. The value is also remember between sessions.

Modify the default list of kernels to launch 4 local kernels and 2 kernels on a remote machine:
This list of kernels is now used in LaunchKernels[]:
After quitting and restarting the notebook's kernel, $DefaultParallelKernels preserves the value assigned earlier:
The reset the value of $DefaultParallelKernels to its default, and remove the persistent setting, use Unset:

Kernel configurations can also be edited from the Kernels section of the Preferences or the Evaluation Parallel Kernel Configuration menu item.

Properties of Kernel Configurations

The detailed form of a kernel configuration supports many properties that you can modify for special situations.

You specify properties as options in KernelConfiguration:
Give the value of a property in a configuration object:
Give all property names and values:
To modify an existing configuration, specify the properties you want to change in a new object:
The "KernelCount" property can more easily be given in the short string form of a kernel configuration:
To verify the value that will be used, turn it into a configuration object and ask for the property:

The Location of the Engine Executable

For kernels on the local machine, the engine invoked is the same one as the one that invokes the kernel.

The default kernel command for local kernels:
It is in the same installation as the kernel that invokes it:
You can launch a different kernel by giving its location in a file: URL:

To access remote resources, you may need to specify the location of the engine executable on the remote machine if the "wolfram" executable is not on the shell search path.

Specify the remote executable for a macOS computer:
For an OS-dependent default, use the "OperatingSystem" option:

Types of Kernels to Configure

To use kernels on machines other than your workstation, you need to specify the method used to access the remote machine and, depending on the method, additional parameters, such as remote a user name.

Local Kernels

"Local"the default local kernel specification
"localhost"legacy localhost specification
"file://"an empty file URL to use the default kernel executable
$ProcessorCountan integer to denote the number of default kernels to launch

Equivalent forms of local kernel URLs.

Local kernels can be specified with the legacy "localhost" string, a file URL or an integer, to indicate the desired number of default kernels.

Equivalent forms for local kernel specifications:
The file: URL allows you to give a different executable:

SSH Kernels

The SSH protocol allows secure login on remote computers. It can be set up with SSH keys allowing login without a password prompt. Logging into a remote machine with the Wolfram Engine installed is an easy way to access remote resources in your lab, a local cluster or in cloud-computing services.

On a local Windows computer, it is recommended to install Microsoft's SSH package to allow the use of remote resources. Windows can also be configured as a remote resource by setting up an SSH server. This is an advanced topic not covered here.

Other operating systems come with SSH preinstalled.

"Username"noneremote user name
"OperatingSystem""Unix"the remote operating system
"KernelCommand"os-dependentthe remote engine executable

Common properties for SSH kernels.

Launch a default kernel on a remote Linux computer:
Launch 2 default kernels on a remote Macintosh:
Launch a specific kernel version:

WSTPServer Kernels

Install WSTPServer on a computer to easily provide kernels on this computer. WSTPServer can provide individual kernels for use in RemoteEvaluate, and parallel kernels.

Request a number of kernels in the default pool for parallel kernels:
Use a single kernel for an evaluation:

A WSTPServer instance may provide several pools of kernels.

Specify the pool to use as a URL path component:

LightweightGrid Kernels

The Wolfram Lightweight Grid Manager is part of gridMathematica. It serves parallel kernels similarly to the way the more modern WSTPServer does. Detailed information on how to work with Lightweight Grid Manager is given in the tutorial Configuring LightweightGrid Kernels for Parallel Computation.

Lightweight Grid kernels are configured in much the same way as WSTPServer kernels, using the scheme lwg: in place of wstp:.

Request a number of kernels in a default installation of Lightweight Grid Manager on a given host:
Alternatively, specify a full Lightweight Grid Manager URL: