# Speedrunning a Mech Interp Research Setup (Remote GPU, Torch, TransformerLens, Cuda, SSH, VS Code)

I genuinely think this is the fastest way to get set up on a brand-new mech-interp project. It takes you from nothing to a fully working remote GPU dev environment (SSH, VS Code/Cursor, CUDA, PyTorch, TransformerLens, GitHub, and UV) with as little friction as possible. It’s exactly the setup I wish I’d had when starting new projects, and it’s especially handy if you’re working on projects for a Neel Nanda’s MATS stream application and just want to get to research, not infrastructure.

This guide is especially well-suited for:

*   **People starting a brand-new mechanistic interpretability project** who want to go from “nothing on a machine” to a working research environment as fast as possible.
*   **Researchers or students in (or preparing for) projects from Neel Nanda’s MATS stream**, where a clean, reproducible setup and fast iteration really matter.
*   **Anyone with basic Python and Git experience** who doesn’t want to spend half a day fighting CUDA, drivers, and environment managers.  
     

**Quick disclaimers before we start:** this setup uses a paid cloud GPU provider, and you will be billed while the machine is running. I'm not affiliated with any provider in this guide. Also, this is a practical tutorial, not a security-hardened production setup. It's intended for research and personal development use.  
 

1\. Create your GitHub repo
---------------------------

Begin by creating your [new repo](https://github.com/new), I recommend this config:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/d5ef37f9bad8597c3ab2b7f4ff5e0885de29a34083a384b5.png)

2\. Spin up your GPU
--------------------

I recommend [Nebius](https://auth.nebius.com/ui/login) as a compute provider - super cheap, easy to use and you can stop your GPUs without deleting them which saves you money!

Start by creating an account on the [Nebius](https://nebius.com/) AI Cloud and click the purple "Create virtual machine" button in the "Virtual machines" tab.

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/d5315fe9f7d3981dbf84a0f1e56ff27646f16f319994b78b.png)

I recommend all the default setup except:

*   Preemptible
*   H100 or H200 (at least 80GB GPU memory)
*   Public IP Address -> Auto assign static IP
    *   This will ensure that if you stop and start the instance, it has the same static IP and you won't need to change your .ssh config each time!
*   Access: Add an ssh key
    *   On your local machine run the following command to create your private key "nebius\_local" and your public key "nebius\_local.pub":
    *       ssh-keygen -t ed25519 -f ~/.ssh/nebius_local -C "your_email@example.com"
        
    *   You may also need to run this if on Mac:
    *       ssh-add ~/.ssh/nebius_local
        
    *   View the public key and copy it to the clipboard
    *       cat ~/.ssh/nebius_local.pub
        
    *   Which will print one line to terminal: ssh-ed25519 ABCD... identifier
    *   Copy what it printed and add it as an ssh key. You can choose your username, we'll call it $USERNAME.
    *   ![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/914397f74a75dcaeb31c5cf181929b6385835358b949b344.png)
        

Click "Create VM" and fill in any billing information it requests:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/ca85d5d83f93cd15a8102d5f43f89f19dd983193bf09b0b7.png)

3\. SSH into your GPU
---------------------

Once your GPU is "Running" you should be able to retrieve a the Public IPv4 address and copy it to clipboard. We'll call this $PUBLIC_IP

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/a83d2b9853f7ae91502b4c17e64f97a818e8b066fc7ab026.png)

 On your local machine run:

    ssh $USERNAME@$PUBLIC_IP

For me this looks like:

    ssh jrosser@59.190.71.41

If you get a fingerprint message, say "yes"! Eventually you should be in! Typing "exit" will end your session.

If anything has gone wrong at this point, ask claude code, or:

*       sudo systemctl restart ssh
    
*   And if that doesn't work, check that you copied your ssh-key in correctly! Try adding or removing a newline at the end.
*   If all else fails you may want to delete the VM and start up a new one. 

4\. Connect VSCode (or Cursor) to your GPU
------------------------------------------

Now that you ssh is working, let's connect to it from Cursor.

On your local terminal edit your ssh config and at the end add your VM as a host:

    sudo nano ~/.ssh/config

and add your VM's $PRIVATE_IP and $USERNAME in this format to the end of the file:

    Host nebius-vm
        HostName 59.190.71.41
        User jrosser

Open VSCode/Cursor and click the blue "Open a remote window" button in the bottom left:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/f6eaf334f725f38b2058c51d4e973eae94e9a75f32e7c2a9.png)

And from the list select "Connect to Host"

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/82d36edc722ce06102f1b36ff3c4a72ce209f6b767a4a087.png)

and select "nebius-vm" from the list.

It should take a minute or so to open the remote.

5\. Install your environment super quick! (cuda + torch + transformerlens and more!)
------------------------------------------------------------------------------------

### 5.1. Create a GitHub SSH key on your remote terminal and upload that to github[^ygx4ujf8m0o]

In your remote terminal in your IDE, create a new .ssh key:

*   On your remote machine run the following command to create your private key "nebius\_remote" and your public key "nebius\_remote.pub":
*       ssh-keygen -t ed25519 -f ~/.ssh/nebius_remote -C "your_email@example.com"
    
*   View the public key and copy it to the clipboard
*       cat ~/.ssh/nebius_remote.pub
    
*   Which will print one line to terminal: ssh-ed25519 ABCD... identifier. Copy what it printed.

Navigate to the SSH and GPG keys section of your GitHub profile settings. [Quick link](https://github.com/settings/ssh/new).

Add the copied nebius_remote key as an ssh key on github.

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/76e1e1b1830c0b1962cb96a627dfc0ed98d56ad90c8a8c06.png)

### 5.2 Some minimal git config setup so you can clone via ssh

Run these four commands in your remote terminal, one by one:

    git config --global user.name "Your Name"
    git config --global user.email "your.github.email@example.com"
    eval "$(ssh-agent -s)" && ssh-add ~/.ssh/nebius_remote
    ssh -T git@github.com

After this your expected output would be “Hi <username>! You’ve successfully authenticated..." showing that it's all working :)

### 5.3 Navigate to your github repo and get the ssh clone command

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/6bceb848e15fc8d05c437846b7f4a1aace4bb8107ec1067f.png)

In your remote terminal type "git clone" and then copy in the command you copied from the github repo:

    git clone git@github.com:$GITHUBUSERNAME/$GITHUBREPONAME.git

Then in VSCode/Cursor, use "Open Folder" to navigate into that folder.

### 5.4 Install your whole environment using UV

> Aside: why are we using UV? Why not conda?  
> If you have used conda before, you'll relate to it taking 20mins+ to install torch sometimes. UV seems to install everything on a Nebius H100 in under a minute! It's also just much cleaner and creates an easily reproducible environment but that's for another time!

Begin by installing "uv" by running this in your remote terminal.

    curl -LsSf https://astral.sh/uv/install.sh | sh

Then run 

    uv init --python 3.10

Then edit the file "pyproject.toml" that was created and replace the contents with [this file](http://jrosser.co.uk/assets/pyproject.toml) (or find it here: [https://jrosser.co.uk/#resources](https://jrosser.co.uk/#resources) )[ ](https://jrosser.co.uk/#resources)) which I made to contain all the dependencies one might need, it should look like this

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/0fdc3b581ff4fbb43ffedfac4f67af9b99e76a284dc7281d.png)

Then run

    uv sync

It should create a `.venv` environment that you can activate in your remote terminal via:

    source .venv/bin/activate

And you can run this to check that torch can find the GPU:

    python -c "import torch; print(torch.cuda.is_available())"

Should return "True".

And that's it! Go forth and save the world!

6\. Stopping your VM
--------------------

Once you're done for the day, don't forget to stop your VM so you won't be charged for using it overnight (unless you want something to keep running!)

You can do this on Nebius, but not on other providers!

Bonus!
------

Given you're working on a single VM, you may just want to completely refresh your GPU e.g. to resolve unexplained OOM errors. Just run this - beware it will kill all python processes currently running (which is normally fine!)

    pkill -9 python

Also, if you want to use claude code, simply run this on your remote terminal

    curl -fsSL https://claude.ai/install.sh | bash

###   
 

[^ygx4ujf8m0o]: For a more secure setup, use a deploy key which only gives access to a single repo: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys