Skip to content

Warning

This is as a Lab Notebook which describes how to solve a specific problem at a specific time. Please keep this in mind as you read and use the content. Please pay close attention to the date, version information and other details.

Ollama under Scratch with SSH Tunnel (2026-10-28)

Author: Dev Jyoti Ghosh Arnab

This notebook installs Ollama in user space under $SCRATCH, serves a model on a GPU node, and opens an SSH tunnel so a laptop client can reach that model. An optional section shows how to chat from Cursor with the Continue extension.

Related docs:

Note

Replace NETID with your NetID and NODE with the hostname SLURM prints for your job (for example nvl-000). Keep Ollama bound to 127.0.0.1. Do not publish a compute-node port to the public internet without iCER approval.

Choose a model size

The install and tunnel steps are the same. Only the GPU request, model tag, and (optional) Continue model name change.

Size Model tag Suggested salloc Notes
8B (rehearsal) llama3.1:8b --gpus=v100:1 --cpus-per-task=4 --mem=16G --time=04:00:00 About 5 GB on disk; fits a V100 32GB
70B llama3.3:70b --gpus=h200:1 --cpus-per-task=8 --mem=64G --time=04:00:00 About 40 GB on disk; needs roughly 80+ GB GPU memory

If the H200 queue is long, an 80 GB A100 is the other fit for 70B. Plain --gpus=a100:1 can land on a 40 GB card. See job constraints and confirm with nvidia-smi before pulling.

Windows used in this guide

Window Role
HPCC terminal 1 GPU job; runs ollama serve
HPCC terminal 2 Same node; ollama pull and test curl
Laptop CMD 1 SSH tunnel (-L 11434)
Laptop CMD 2 Local curl check
Cursor (optional) Continue chat against the tunnel

1. One-time install under $SCRATCH

Do this inside an interactive GPU job, not on a login or overloaded development node.

  1. Log in and open a development node, then request a GPU (use the 8B line first if you are learning the path):

    ssh NETID@hpcc.msu.edu
    ssh dev-intel18
    salloc --gpus=v100:1 --cpus-per-task=4 --mem=16G --time=02:00:00
    
  2. Confirm the node and space:

    hostname
    nvidia-smi
    echo "$SCRATCH"
    df -h "$SCRATCH"
    
  3. Download and extract Ollama (use one line for curl):

    mkdir -p "$SCRATCH/ollama-stack" "$SCRATCH/src"
    cd "$SCRATCH/src"
    curl -fL -o ollama-linux-amd64.tar.zst https://ollama.com/download/ollama-linux-amd64.tar.zst
    ls -lh ollama-linux-amd64.tar.zst
    tar --zstd -xf ollama-linux-amd64.tar.zst -C "$SCRATCH/ollama-stack"
    

    If tar --zstd fails:

    module load zstd
    unzstd -c ollama-linux-amd64.tar.zst | tar -xf - -C "$SCRATCH/ollama-stack"
    
  4. Create and source an environment file:

cat > "$SCRATCH/ollama-env.sh" <<'EOF'
export PATH="$SCRATCH/ollama-stack/bin:$PATH"
export LD_LIBRARY_PATH="$SCRATCH/ollama-stack/lib/ollama:${LD_LIBRARY_PATH:-}"
export OLLAMA_MODELS="$SCRATCH/ollama_models"
export OLLAMA_HOST="127.0.0.1:11434"
mkdir -p "$OLLAMA_MODELS"
EOF

source "$SCRATCH/ollama-env.sh"
ollama -v
which ollama

Checkpoint: which ollama points under $SCRATCH/ollama-stack/bin. A “could not connect” warning is normal until ollama serve is running. This path does not use ollama_link_models or the shared LLM library.

2. Serve and pull a model

On HPCC terminal 1 (on the GPU node):

source "$SCRATCH/ollama-env.sh"
ollama serve

Leave that process in the foreground. In HPCC terminal 2, SSH to the same node, then:

source "$SCRATCH/ollama-env.sh"
ollama pull llama3.1:8b          # or: ollama pull llama3.3:70b
ollama list
curl http://127.0.0.1:11434/api/generate -d '{
  "model": "llama3.1:8b",
  "prompt": "Say hello in one sentence.",
  "stream": false
}'

Use the same model tag in pull, list, and curl as in the table above. Start ollama serve before pull.

3. SSH tunnel from the laptop

Run this on the laptop, not on the cluster. Keep ollama serve running.

ssh -J NETID@hpcc.msu.edu,NETID@dev-intel18 -L 11434:127.0.0.1:11434 NETID@NODE

Use hpcc.msu.edu as the gateway (not gateway.hpcc.msu.edu). Jump through a development node, then to the compute node. Leave this window open.

In a second laptop terminal:

curl http://127.0.0.1:11434/api/tags

Checkpoint: the JSON lists your model tag.

4. Optional: chat from Cursor with Continue

Cursor’s built-in Agent / Tab still use Cursor’s own models and do not call a private localhost tunnel. For chat against the HPCC Ollama server, use an editor-side client such as Continue.

  1. In Cursor, open Extensions (Ctrl+Shift+X), install Continue.
  2. On Windows CMD (not PowerShell), create the config:

    mkdir "%USERPROFILE%\.continue"
    notepad "%USERPROFILE%\.continue\config.yaml"
    
  3. Save a model block that matches what you pulled:

    name: HPCC
    version: 1.0.0
    schema: v1
    models:
      - name: Llama on HPCC
        provider: ollama
        model: llama3.1:8b
        apiBase: http://127.0.0.1:11434
    

    For 70B, set model: llama3.3:70b (and rename the display name if you like).

  4. In Continue, select that model and send a short message. Keep the tunnel and ollama serve open while you chat.

5. Shut down

  1. Stop using Continue (if open).
  2. Close the laptop tunnel window.
  3. On HPCC terminal 1, stop the server with Ctrl+C, then exit the allocation, or scancel JOBID from another session.

Do not leave an idle large-GPU job running.

Troubleshooting

Symptom Fix
nvdia-smi: command not found Use nvidia-smi
curl: (2) no URL specified! Put the download curl on one line
could not connect during pull Start ollama serve first
model ... not found Finish ollama pull, then ollama list
Tunnel typed on the cluster Run the -L command on the laptop
Continue cannot reach Ollama Job ended, serve stopped, or tunnel closed; redo sections 2–3
PowerShell $env:USERPROFILE fails in CMD Use %USERPROFILE%

Notes

  • Scratch is purged for files unused for an extended period and is not backed up. For longer retention, ask your lab about research storage and point OLLAMA_MODELS there.
  • Tested on HPCC with a V100 (nvl-000), Ollama 0.40.12 under $SCRATCH, model llama3.1:8b, Windows CMD tunnel via hpcc.msu.edu → dev-intel18 → compute node, and Continue in Cursor.