Certainly! Connecting to a remote workstation through an SSH double tunnel in VS Code to use a Jupyter notebook with GPU access involves several steps. Below is a detailed guide to help you through the process.
Step 1: Install Required Software
Ensure you have the following software installed on both your local and remote machines:
-
SSH Server:
-
VS Code:
- Download and install VS Code from here.
-
Remote - SSH Extension for VS Code:
- Open VS Code.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing
Ctrl+Shift+X.
- Search for "Remote - SSH" and install the extension by Microsoft.
-
Python and Jupyter:
-
CUDA and GPU Drivers (if not already installed):
- Ensure the remote machine has the necessary GPU drivers and CUDA installed.
Step 2: Configure SSH Keys
To simplify the connection process, it's recommended to use SSH keys.
-
Generate SSH Keys (if you don't already have them):
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Follow the prompts to save the keys to the default location.
-
Copy the Public Key to the Remote Machine:
ssh-copy-id user@remote_machine_ip
Replace user with your username on the remote machine and remote_machine_ip with the IP address of the remote machine.
Step 3: Set Up the Double SSH Tunnel
A double SSH tunnel involves connecting through an intermediate machine. Assume you have an intermediate machine (jump host) that you can first connect to, and from there, connect to the final remote workstation.
- Create an SSH Config File:
Step 4: Connect to the Remote Workstation using VS Code
-
Open VS Code.
-
Open the Command Palette:
- Press
Ctrl+Shift+P to open the Command Palette.
-
Remote-SSH: Connect to Host:
- In the Command Palette, type
Remote-SSH: Connect to Host and select it.
- Choose
remote_workstation from the list. This will use the ProxyJump to connect through the jump host.
-
Open a New Terminal:
- Once connected, open a new terminal in VS Code by selecting
Terminal from the top menu and then New Terminal.
- This terminal will be running on the remote workstation.
Step 5: Set Up and Run Jupyter Notebook
-
Start the Jupyter Notebook:
-
Forward the Jupyter Notebook Port:
-
Access the Jupyter Notebook in a Browser:
- Open a web browser and navigate to
http://localhost:8888.
- You should see the Jupyter notebook interface. Enter the token provided in the remote terminal to access the notebook.
Step 6: Configure VS Code to Use the Remote Jupyter Server
-
Install the Python Extension:
- If you haven't already, install the Python extension for VS Code from the Extensions view.
-
Select the Jupyter Server:
- Open the Command Palette (
Ctrl+Shift+P).
- Type
Python: Select Jupyter Server and select it.
- Choose
Existing: http://localhost:8888 to connect to the remote Jupyter server.
-
Create or Open a Jupyter Notebook:
- You can now create a new Jupyter notebook or open an existing one. The notebook will run on the remote workstation, utilizing the GPU.
Step 7: Verify GPU Access
- Check GPU Availability:
By following these steps, you should be able to connect to a remote workstation through an SSH double tunnel in VS Code and use a Jupyter notebook with GPU access.