KernelConfiguration

KernelConfiguration[spec]

specifies a kernel that can be used for RemoteEvaluate or LaunchKernels.

Details

  • KernelConfiguration["spec",options ] can be used to override default settings for a kernel specification.
  • The following kernel specifications are recognized:
  • "ssh://user@hostname:port/path"a kernel on the given machine, accessed using SSH
    "ssh://hostname"use the default path, user and port on the given machine
    "hostname"equivalent to "ssh://hostname"
    "wstp://server:port/pool"a kernel on a WSTPServer
    "wstp://server"use the default port and kernel pool
    "Local"the default local kernel
    "localhost"a kernel on the same machine
    nn local parallel kernels
    "file:///path/to/wolfram"the given kernel on the same machine
    "file://"the default kernel on the same machine
    "https://www.wolframcloud.com/"a kernel in the Wolfram Cloud
    "lwg://host.example.com:port/path"a kernel on a LightweightGrid server
    "lwg://host.example.com:port"use the default path to the LightweightGrid manager
    "lwg://host.example.com"use the default port (3737) of the LightweightGrid server
    LinkObject[]a WSTP link to a running kernel
  • Settings for SSH kernels include:
  • "EvaluationKernelArguments"{"-noinit"}additional arguments for evaluation kernels
    "ForwardPort"Randomremote port to use for connection forwarding
    "KernelArguments"(OS-dependent)arguments to pass all kernel programs
    "KernelCommand"(OS-dependent)the kernel program to run
    "KernelCount"1number of parallel kernels to launch
    "MachineName"Nonethe name of the machine to connect to
    "Method"(OS-dependent)how to connect to the kernel on the remote machine
    "Name"Automatica unique name for this kernel
    "OperatingSystem""Unix"the remote operating system
    "Port"Nonethe port of the SSH server
    "SshArguments"(see below)arguments to pass to the SSH command
    "SshCommand""ssh"the name of the SSH command
    "SshIdentity"Nonethe private SSH key to use
    "SubKernelArguments"{"-noinit","-subkernel"}additional arguments for parallel subkernels
    "TimeConstraint"10number of seconds to wait for a connection
    "Username"Nonethe login name that SSH should use
  • The connection method "Launch" is the default on macOS and Linux. It uses LinkLaunch to invoke SSH and uses stdin/stdout for the WSTP connection to the remote kernel.
  • The connection method "Forward" is the default on Windows. It creates a listening WSTP socket on the local machine and forwards the kernel connection inside an SSH tunnel from the remote kernel to the listening socket.
  • The default remote "KernelCommand" is chosen based on the declared "OperatingSystem":
  • "Unix""wolfram"
    "MacOSX""/Applications/Mathematica.app/Contents/MacOS/wolfram"
    "Windows""wolfram.exe"
  • If the given command is not on the search path on the remote machine, the absolute path to the remote kernel command should be given as value of "KernelCommand".
  • If "Username" is not set or is None, no username part is given on the SSH command line. "Username"$Username sets the remote username to be the same as the local one.
  • "Username" and "KernelCommand" can also be given as part of the specification as "ssh://user@hostname:port/path".
  • The default value for "SshArguments" is {"-4", "-x", "-o", "StrictHostKeyChecking=no", "-o", "BatchMode=yes"}.
  • SSH cannot ask for passwords interactively. Keys can be specified, or an SSH password agent can be used.
  • Settings for WSTPServer kernels include:
  • "KernelCount"1number of parallel kernels to launch
    "MachineName"Nonethe name of the server to connect to
    "Name"Automatica unique name for this kernel
    "Pool"Automaticthe kernel pool to request
    "Port"31415the port to connect to
    "TimeConstraint"10number of seconds to wait for a connection
  • If the kernel pool is not specified, the WSTPServer chooses a kernel from the default pool.
  • Settings for LWG kernels include:
  • "Agent"Automaticthe LWG agent URL to use
    "KernelCount"1number of parallel kernels to launch
    "Name"Automatica unique name for this kernel
    "Service"Automaticthe kernel service to request
    "TimeConstraint"30number of seconds to wait for a connection
  • If the kernel service is not specified, the LightweightGrid server chooses a kernel from the default service.
  • Settings for cloud kernels include:
  • "CloudBase"Nonethe cloud base
    "Name"Automatica unique name for this kernel
    "TimeConstraint"number of seconds to wait for a connection
  • The cloud base is given in the form of an HTTPS URL.
  • Settings for local kernels include:
  • "EvaluationKernelArguments"{"-noinit"}additional arguments for evaluation kernels
    "KernelArguments"(OS-dependent)arguments to pass to the kernel program
    "KernelCommand"(OS-dependent)the kernel program to launch
    "KernelCount"$ProcessorCountnumber of parallel kernels to launch
    "LimitByLicense"Truelimit number of parallel kernels by license availability
    "LinkProtocol"Automaticthe link protocol to use
    "LowerPriority"Truewhether to run parallel subkernels at a lower priority
    "SubKernelArguments"{"-noinit","-subkernel"}additional arguments for parallel subkernels
    "TimeConstraint"number of seconds to wait for a connection
  • The LinkProtocol option is passed on to LinkLaunch.
  • Settings for link kernels include:
  • "LinkObject"Nonethe LinkObject to use
    "Name"Automatica unique name for this kernel
  • The link object must be an open WSTP link to a running kernel.

Examples

open allclose all

Basic Examples  (2)

Connect to a machine with SSH, launch a default kernel and evaluate some of its properties:

Optionally, wrap the kernel specification in KernelConfiguration:

Specify an absolute path to the remote kernel command:

Alternatively, give the path as an option of KernelConfiguration:

Scope  (25)

SSH Kernels  (6)

Give the path to the remote kernel as an option of KernelConfiguration:

Alternatively, specify the path as part of the SSH URL:

Specify an absolute path to the default kernel command on macOS:

Specify the remote operating system to choose a suitable kernel command:

If no options are needed, KernelConfiguration can be omitted:

The number of parallel kernels to launch can be given with "KernelCount":

When using a URL short form, the number of parallel kernels can be specified with "?n":

WSTPServer Kernels  (4)

Connect to a WSTPServer listening on the given port:

Alternatively, specify the port as an option of KernelConfiguration:

Connect to a WSTPServer and request a kernel in the given pool:

Alternatively, specify the kernel pool as an option of KernelConfiguration:

When using a URL short form, the number of parallel kernels can be specified with "?n":

The number of parallel kernels to launch can be given with "KernelCount":

Cloud Kernels  (2)

Use a kernel in the default cloud:

Specify a URL for a (private) cloud to use:

Local Kernels  (7)

Use a specific local kernel, given by its absolute path as a file URL:

Alternatively, specify the path as a property of KernelConfiguration:

Use a specific local kernel, given by its relative path:

The number of parallel kernels to launch can be given with "KernelCount":

When using a URL short form, the number of parallel kernels can be specified with "?n":

A single integer n is short for n local kernels:

For local kernels, the default number of parallel kernels is equal to $ProcessorCount, license permitting:

Use a specific link protocol:

LWG Kernels  (4)

Launch two parallel kernels from a LightweightGrid server with default port and manager URL:

Derive the kernel configuration from a LightweightGrid server URL:

Get all documented properties of LWG kernels:

Launch a parallel kernel from this configuration:

When using a URL short form, the number of parallel kernels can be specified with "?n":

The number of parallel kernels to launch can be given with "KernelCount":

Link Kernels  (2)

Launch a kernel and obtain the WSTP link to it:

Use it in a kernel configuration:

Perform an evaluation on this kernel:

Link kernels can be used only once:

Launch two kernels that can be used as parallel subkernels:

Use them in a kernel configuration:

Use the configurations for parallel computing:

Properties & Relations  (2)

A kernel object describes a method for launching a kernel; it does not represent a persistent connection:

Each evaluation launches a new kernel, which is discarded after use:

$DefaultParallelKernels is the list of kernels to use by default for parallel computation:

Neat Examples  (1)

Specify a remote machine:

Query it for its number of processors:

Update the description with the discovered kernel count:

Launch all of those parallel subkernels:

Wolfram Research (2022), KernelConfiguration, Wolfram Language function, https://reference.wolfram.com/language/ref/KernelConfiguration.html (updated 2023).

Text

Wolfram Research (2022), KernelConfiguration, Wolfram Language function, https://reference.wolfram.com/language/ref/KernelConfiguration.html (updated 2023).

CMS

Wolfram Language. 2022. "KernelConfiguration." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2023. https://reference.wolfram.com/language/ref/KernelConfiguration.html.

APA

Wolfram Language. (2022). KernelConfiguration. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/KernelConfiguration.html

BibTeX

@misc{reference.wolfram_2024_kernelconfiguration, author="Wolfram Research", title="{KernelConfiguration}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/KernelConfiguration.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_kernelconfiguration, organization={Wolfram Research}, title={KernelConfiguration}, year={2023}, url={https://reference.wolfram.com/language/ref/KernelConfiguration.html}, note=[Accessed: 22-November-2024 ]}