Skip to content

Commit 59dd41b

Browse files
committed
missing images added
1 parent c194801 commit 59dd41b

12 files changed

Lines changed: 133 additions & 0 deletions
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Connect to RHOAI Workbench Kernel from local Visual Studio Code (VS Code)
2+
3+
Some users prefer to work directly in their local IDE and run Jupyter notebooks
4+
using a kernel on a remote workbench hosted on NERC's RHOAI. While most IDEs
5+
support connecting to a remote kernel as a standard feature, this does not work
6+
with RHOAI due to its authentication setup.
7+
8+
Typically, IDEs use token-based authentication to connect to remote kernels. However
9+
workbench pods in RHOAI include an authentication layer in front of the workbench
10+
container that manages user access. This layer relies on OpenShift's authentication
11+
mechanism, which is not compatible with the standard remote kernel connection
12+
features provided by most IDEs.
13+
14+
## Workaround: Connect to the remote kernel using Openshift port-forwarding
15+
16+
Use the following steps to connect your local VS Code to RHOAI Workbench kernel:
17+
18+
- In your RHOAI data science project, create a workbench that you intend to use
19+
as your remote kernel. If you require a GPU accelerator, choose a compatible
20+
workbench image (i.e. PyTorch, TensorFlow based Workbench image).
21+
22+
![Create workbench](images/open-object-detection-jupyter-lab.png)
23+
24+
- Open the workbench and copy the context path from the browser. You will need
25+
this (i.e. `notebook/<your-project-namespace>/object-detection/lab`) later
26+
when connecting from VS Code locally.
27+
28+
![Workbench context path](images/workbench-context-path.png)
29+
30+
- Make sure you have the `oc` CLI tool installed and configured on your local
31+
machine following [these steps](../../openshift/logging-in/setup-the-openshift-cli.md#first-time-usage).
32+
33+
- From terminal on your laptop/desktop login to the NERC OpenShift cluster and
34+
switch to your project namespace:
35+
36+
```sh
37+
oc login --token=<your_token> --server=https://api.shift.nerc.mghpcc.org:6443
38+
```
39+
40+
For example:
41+
42+
```sh
43+
oc login --token=<your_token> --server=https://api.shift.nerc.mghpcc.org:6443
44+
Logged into "https://api.shift.nerc.mghpcc.org:6443" as "<your_account>" using the token provided.
45+
```
46+
47+
!!! info "Information"
48+
49+
Some users may have access to multiple projects. Run the following command
50+
to switch to a specific project space: `oc project <your-project-namespace>`.
51+
52+
- Switch to your data science project:
53+
54+
Please confirm the correct project is being selected by running `oc project`,
55+
as shown below:
56+
57+
oc project
58+
Using project "<your-project-namespace>" on server "https://api.shift.nerc.mghpcc.org:6443".
59+
60+
- Start port-forwarding to your workbench pod
61+
62+
* List all the pods in your project. The pod running your workbench is named
63+
based on your workbench name in RHOAI. For example, `object-detection-0`
64+
corresponds to a workbench named `Object Detection`.
65+
66+
> **Note:** Capital letters are converted to lowercase, and spaces are
67+
replaced with hyphens (`-`).
68+
69+
* Enable port-forwarding to your workbench pod. You need to forward to the
70+
port the pod is listening on. It is usually `8888` for RHOAI workbench.
71+
You can find this port from the service in your project with name same
72+
as your workbench.
73+
74+
![Port-forward to wb pod](images/port-forwarding.png)
75+
76+
- Open the Jupyter notebook in your local VS Code
77+
78+
![Jupyter Notebook](images/jupyter-nb.png)
79+
80+
- From the top right corner of the notebook, click on `Select Kernel`.
81+
82+
![Select Kernel](images/select-kernel.png)
83+
84+
- From the options, select `Existing Jupyter Server` and then enter the url as
85+
follows:
86+
87+
![Existing Jupyter Server](images/existing-jupyter-server.png)
88+
89+
`localhost` `[:port]` `/context-path` copied earlier that has the pattern
90+
`/notebook/ds-project-name/workbench-name/lab`. e.g. `http://localhost:8888/notebook/<your-project-namespace>/object-detection/lab`
91+
and then press `Enter` to confirm.
92+
93+
![Existing Jupyter Server URL](images/jupyter-server-url.png)
94+
95+
- A prompt saying
96+
97+
`Connecting over HTTP without a token may be an insecure connection. Do you
98+
want to connect to a possibly insecure server?` is displayed. select `Yes`
99+
100+
![Insecure connection prompt](images/connect-over-http.png)
101+
102+
- Select the prompted `Server display name` or enter a new one and then press
103+
`Enter` to confirm.
104+
105+
![Server display name](images/name-connection.png)
106+
107+
- A list of available kernels is displayed. Choose `Python 3.9`.
108+
109+
![Select Kernel](images/select-remote-kernel.png)
110+
111+
- You should see the selected Kernel in the top right corner.
112+
113+
![Remote kernel selected](images/remote-kernel-selected.png)
114+
115+
- The code inside of your notebook will now execute using the remote kernel on
116+
the RHOAI workbench pod.
117+
118+
- If your workbench uses a NVIDIA GPU, you can verify that it is being used in
119+
the execution of your notebook by adding a command `!nvidia-smi`. You should
120+
see output similar to the image below.
121+
122+
![Nvidia GPU used ](images/nvidia-gpu-used.png)
123+
124+
## Caveats
125+
126+
- Jupyter notebooks in your local VS Code environment will not be saved to the
127+
workbench.
128+
129+
- If your notebook uses any files (models, inputdata etc.), they should be
130+
present on the workbench and their path should match the path specified in
131+
your notebook.
132+
133+
---
64 KB
Loading
51.4 KB
Loading
92.7 KB
Loading
103 KB
Loading
68.8 KB
Loading
171 KB
Loading
37.5 KB
Loading
82.8 KB
Loading
130 KB
Loading

0 commit comments

Comments
 (0)