Skip to content

Get set up

Install nnsight, get an API key, and save the key. After that, remote=True works from any script or notebook on the machine.

Install

pip install --upgrade nnsight

NDIF accepts recent nnsight releases only. An older one is refused when you send a request:

RemoteError: Failed to send request: Client nnsight version X is below the minimum supported Y. Please `pip install --upgrade nnsight`.

Get a key

Create an account at login.ndif.us and copy your API key.

Save the key

From a terminal:

nnsight login
# Enter your NDIF API key:
# NDIF API key saved — logged in as you@university.edu.

Or from Python:

import nnsight

nnsight.login()             # asks for the key; nnsight.login("YOUR_KEY") skips the question

Both write the key to ~/.config/nnsight/config.yaml. nnsight reads it from there on every run.

There are three other places a key can come from:

Where How
An environment variable export NDIF_API_KEY=YOUR_KEY. It is used instead of the saved key.
Google Colab A Colab secret named NDIF_API_KEY.
One Python process from nnsight import CONFIG then CONFIG.API.APIKEY = "YOUR_KEY".

Check it

nnsight whoami
# you@university.edu

nnsight.whoami() returns the same as a dict, with the access tags on your account (Code on the server).

nnsight.status() tells you whether the service is up and which models are loaded (Models).

Settings

Settings live on nnsight.CONFIG. CONFIG.save() writes the current values to the config file.

Setting Default What it does
CONFIG.API.APIKEY none Your API key.
CONFIG.API.HOST https://api.ndif.us The server requests go to. The NDIF_HOST environment variable sets it too. See Self-hosting.
CONFIG.APP.REMOTE_LOGGING True Show the status line while a job runs.
CONFIG.APP.DEBUG False Print request and result sizes and one line per status. See Debugging.