Skip to content

Instantly share code, notes, and snippets.

@TysonRayJones
Last active July 26, 2019 14:32
Show Gist options
  • Save TysonRayJones/1633e420c8e7554059c840552b654e6b to your computer and use it in GitHub Desktop.
Save TysonRayJones/1633e420c8e7554059c840552b654e6b to your computer and use it in GitHub Desktop.
Connecting to remote Mathematica kernels on Victor and Igor

Here's how to create and connect to remote Mathematica kernels running on the Victor and Igor machines in the office.

These instructions currently do not describe how to connect through a VPN outside of Oxford.

1. Setup passphrase-free SSH

Windows

Skip this step. Windows users must instead enter the questlink@ password for Victor or Igor each time they connect to a remote kernel through Mathematica.

Linux & MacOS

  • Ensure your client machine has an RSA key

On Linux/MacOS:

ssh-keygen -t rsa

and enter n (don't overwrite) if it asks about an overwrite, otherwise enter y.

  • Add your client key to the questlink account on Victor or Igor
cat ~/.ssh/id_rsa.pub | ssh questlink@victorslab.materials.ox.ac.uk 'cat >> .ssh/authorized_keys'
cat ~/.ssh/id_rsa.pub | ssh questlink@igor-gpu.materials.ox.ac.uk 'cat >> .ssh/authorized_keys'
  • Update your authentication agent
ssh-add -K ~/.ssh/id_rsa

2. Create the remote kernel

Windows

In a Mathematica notebook, go to Evaluation > Kernel Configuration Options > Add...

  • set Kernel name to Victor or Igor

  • tick Basic options

  • set Machine Name

    For Victor:

    victorslab.materials.ox.ac.uk
    

    For Igor:

    igor-gpu.materials.ox.ac.uk
    
  • set Remote Login to questlink

  • set Kernel Program

    For Victor:

    $WOLF_KERNEL_PATH/WolframKernel
    

    For Igor:

    /Applications/Mathematica.app/Contents/MacOS/MathKernel`
    
  • press Ok

Linux & MacOS

In a Mathematica notebook, go to Evaluation > Kernel Configuration Options > Add...

  • set Kernel name to Victor or Igor

  • tick Advanced Options

  • set Arguments to MLOpen to

    -LinkMode Listen -LinkProtocol TCPIP -LinkOptions MLDontInteract
    
  • Set Launch command

    For Victor:

    ssh questlink@victorslab.materials.ox.ac.uk '$WOLF_KERNEL_PATH/WolframKernel -wstp -LinkMode Connect -LinkProtocol TCPIP -LinkName "`linkname`"'
    

    For Igor:

    ssh questlink@igor-gpu.materials.ox.ac.uk '/Applications/Mathematica.app/Contents/MacOS/MathKernel -mathlink -LinkMode Connect -LinkProtocol TCPIP -LinkName "`linkname`" -LinkHost `ipaddress`'
    
  • press Ok

    3. Connect to the remote kernel

    You can start and connect to kernels on Victor and Igor at any time by, from within a Mathematica notebook, selecting Evaluation > Notebook's Kernel. Windows users will additionally need to enter Victor/Igor's questlink@ password at the first evaluation. Any entered commands will be sent to Victor and Igor, executed there, and the otuput returned. Files will ergo be read and written on Igor and Victor. To run a command on your client kernel (and share the result with Victor and Igor), wrap it in a call to

    UsingFrontEnd[]

    Victor and Igor are set up to run QuESTlink using their Quadro P6000 GPUs. While connected to the remote kernel, run in Mathematica

    Import["https://quest.qtechtheory.org/QuEST.m"]
    env = CreateLocalQuESTEnv[];

    Note Victor is running Ubuntu and Igor is running MacOS. Therefore calling CreateDownloadedQuESTEnv[] on Victor will download an incompatible MacOS executable. If this occurs, correct the file via the (undisclosed) admin account.

    ssh ...
    sudo /home/questlink/quest_link_backup /home/questlink/quest_link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment