Skip to content

Commit d85c112

Browse files
payotogithub-actions[bot]rahult-graphcore
authored
Copy instructions for VS code in Paperspace (#44)
* Copy instructions for VS code in Paperspace * [GH-Actions] Add new files from specs (#45) .github/deployment-configs/deploy-useful-tips.yaml Co-authored-by: Rahul <[email protected]> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Rahul <[email protected]>
1 parent 50ba6ae commit d85c112

10 files changed

+252
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) 2022 Graphcore Ltd. All rights reserved.
2+
3+
_examples_internal_repository: &_examples_internal_repository
4+
origin: examples-internal/
5+
ref: null
6+
7+
_common_target_repository: &_common_target_repository
8+
origin: notebooks/
9+
ref: null
10+
11+
12+
useful-tips:
13+
source:
14+
paths:
15+
- path: useful-tips/
16+
recursive: true
17+
excludes:
18+
- path: useful-tips/managing_ipu_resources.ipynb
19+
recursive: false
20+
repository:
21+
origin: https://github.com/graphcore/Gradient-HuggingFace
22+
ref: main
23+
prefix: useful-tips
24+
target:
25+
repository:
26+
<<: *_common_target_repository
27+
prefix: useful-tips
21.6 KB
Loading
52.4 KB
Loading
97.2 KB
Loading
98.1 KB
Loading

useful-tips/images/login-code.png

77.1 KB
Loading

useful-tips/images/login-success.png

63.2 KB
Loading

useful-tips/images/restart_kernel.png

47.2 KB
Loading
62.5 KB
Loading
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Using VS Code in Paperspace Notebooks\n",
8+
"\n",
9+
"VS Code is a versatile code editor which can be used from your desktop or browser and can connect to remote machines to give you convenient access to remote compute resources.\n",
10+
"\n",
11+
"To connect to IPU machines in Gradient notebooks in Paperspace you can use the [Remote - Tunnels](https://marketplace.visualstudio.com/items?itemName=ms-vscode.remote-server) extension.\n",
12+
"\n",
13+
"This notebook will get you set up with a VS Code server that can be used to develop and run commands on the IPU machines in Paperspace from VS Code web editors or desktop applications.\n",
14+
"\n",
15+
"We've also included some troubleshooting steps for common issues."
16+
]
17+
},
18+
{
19+
"cell_type": "code",
20+
"execution_count": null,
21+
"metadata": {
22+
"execution": {
23+
"iopub.execute_input": "2023-08-09T10:30:04.537632Z",
24+
"iopub.status.busy": "2023-08-09T10:30:04.536837Z",
25+
"iopub.status.idle": "2023-08-09T10:30:04.545588Z",
26+
"shell.execute_reply": "2023-08-09T10:30:04.545027Z",
27+
"shell.execute_reply.started": "2023-08-09T10:30:04.537611Z"
28+
}
29+
},
30+
"outputs": [],
31+
"source": [
32+
"%cd /notebooks"
33+
]
34+
},
35+
{
36+
"cell_type": "code",
37+
"execution_count": null,
38+
"metadata": {
39+
"execution": {
40+
"iopub.execute_input": "2023-08-09T10:50:47.010715Z",
41+
"iopub.status.busy": "2023-08-09T10:50:47.009950Z",
42+
"iopub.status.idle": "2023-08-09T10:50:48.656974Z",
43+
"shell.execute_reply": "2023-08-09T10:50:48.656221Z",
44+
"shell.execute_reply.started": "2023-08-09T10:50:47.010692Z"
45+
}
46+
},
47+
"outputs": [],
48+
"source": [
49+
"!curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' --output vscode_cli.tar.gz\n",
50+
"!tar -xf vscode_cli.tar.gz"
51+
]
52+
},
53+
{
54+
"cell_type": "markdown",
55+
"metadata": {},
56+
"source": [
57+
"The next cell will configure folders to make your VS Code installation persist across machines -- you won't have to reinstall extensions every time you restart your Gradient Notebook instance."
58+
]
59+
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": null,
63+
"metadata": {},
64+
"outputs": [],
65+
"source": [
66+
"!mkdir -p /storage/.vscode/server\n",
67+
"!ln -s /storage/.vscode/server $HOME/.vscode-server\n",
68+
"!cp code /storage/.vscode/code\n",
69+
"!ls /storage/.vscode"
70+
]
71+
},
72+
{
73+
"cell_type": "markdown",
74+
"metadata": {},
75+
"source": [
76+
"You can now start the tunnel with the following command. Let's name the tunnel `ipu-paperspace`:"
77+
]
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": null,
82+
"metadata": {
83+
"execution": {
84+
"iopub.execute_input": "2023-08-09T10:53:07.032274Z",
85+
"iopub.status.busy": "2023-08-09T10:53:07.031643Z",
86+
"iopub.status.idle": "2023-08-09T11:02:45.570502Z",
87+
"shell.execute_reply": "2023-08-09T11:02:45.569394Z",
88+
"shell.execute_reply.started": "2023-08-09T10:53:07.032246Z"
89+
}
90+
},
91+
"outputs": [],
92+
"source": [
93+
"!/storage/.vscode/code tunnel --accept-server-license-terms --name=ipu-paperspace"
94+
]
95+
},
96+
{
97+
"cell_type": "markdown",
98+
"metadata": {},
99+
"source": [
100+
"You should see something similar to the following in the console:\n",
101+
"\n",
102+
"```console\n",
103+
"*\n",
104+
"* Visual Studio Code Server\n",
105+
"*\n",
106+
"* By using the software, you agree to\n",
107+
"* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and\n",
108+
"* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).\n",
109+
"*\n",
110+
"To grant access to the server, please log into https://github.com/login/device and use code FA2A-360B\n",
111+
"```"
112+
]
113+
},
114+
{
115+
"cell_type": "markdown",
116+
"metadata": {
117+
"execution": {
118+
"iopub.execute_input": "2023-08-09T10:25:51.970178Z",
119+
"iopub.status.busy": "2023-08-09T10:25:51.969591Z",
120+
"iopub.status.idle": "2023-08-09T10:25:52.157585Z",
121+
"shell.execute_reply": "2023-08-09T10:25:52.157047Z",
122+
"shell.execute_reply.started": "2023-08-09T10:25:51.970138Z"
123+
}
124+
},
125+
"source": [
126+
"You need to now log into GitHub to authorise the tunnel. Open https://github.com/login/device and enter the one-time code into the following screen:\n",
127+
"\n",
128+
"![code screen](https://raw.githubusercontent.com/graphcore/Gradient-HuggingFace/main/useful-tips/images/login-code.png)\n",
129+
"\n",
130+
"Once you have completed the login workflow on GitHub and see this screen you are good to go!\n",
131+
"\n",
132+
"![success screen](https://raw.githubusercontent.com/graphcore/Gradient-HuggingFace/main/useful-tips/images/login-success.png)"
133+
]
134+
},
135+
{
136+
"cell_type": "markdown",
137+
"metadata": {},
138+
"source": [
139+
"On your console, you should now see:\n",
140+
"\n",
141+
"```console\n",
142+
"[2023-08-09 11:37:06] info Creating tunnel with the name: ipu-paperspace\n",
143+
"\n",
144+
"Open this link in your browser https://vscode.dev/tunnel/ipu-paperspace/notebooks\n",
145+
"```"
146+
]
147+
},
148+
{
149+
"cell_type": "markdown",
150+
"metadata": {},
151+
"source": [
152+
"\n",
153+
"Now, open https://vscode.dev/tunnel/ipu-paperspace/notebooks to access the machine from a browser.\n"
154+
]
155+
},
156+
{
157+
"cell_type": "markdown",
158+
"metadata": {},
159+
"source": [
160+
"## Use the VS Code desktop app\n",
161+
"\n",
162+
"You can also connect from the VS Code desktop app:\n",
163+
"\n",
164+
"- either by clicking in the bottom left corner of the VS Code Web editor and selecting `Continue Working in VS Code Desktop`:\n",
165+
"\n",
166+
"![Click in the bottom right corner](https://raw.githubusercontent.com/graphcore/Gradient-HuggingFace/main/useful-tips/images/connect-tunnel-from-web-1.png)\n",
167+
"\n",
168+
"![Select \"Continue working in VS Code desktop\"](https://raw.githubusercontent.com/graphcore/Gradient-HuggingFace/main/useful-tips/images/connect-tunnel-from-web-2.png)\n",
169+
"\n",
170+
"- or by connecting directly from your desktop app. Install the [Remote - Tunnels](https://marketplace.visualstudio.com/items?itemName=ms-vscode.remote-server) extension and then add a new remote tunnel and when it's been created, connect to it:\n",
171+
"\n",
172+
"![Add the new remote tunnel](https://raw.githubusercontent.com/graphcore/Gradient-HuggingFace/main/useful-tips/images/connect-tunnel-to-app-1.png)\n",
173+
"\n",
174+
"![Connect to the remote tunnel](https://raw.githubusercontent.com/graphcore/Gradient-HuggingFace/main/useful-tips/images/connect-tunnel-to-app-2.png)"
175+
]
176+
},
177+
{
178+
"cell_type": "markdown",
179+
"metadata": {},
180+
"source": [
181+
"## Common issues\n",
182+
"\n",
183+
"After you have completed the GitHub authorisation workflow, you can get the following error:\n",
184+
"\n",
185+
"```console\n",
186+
"[2023-08-09 11:37:09] error Could not create tunnel with name: ipu-paperspace\n",
187+
"Reason: tunnel name already in use\n",
188+
"```\n",
189+
"\n",
190+
"In this case you can change the name of the tunnel. Alternatively, if the tunnel is no longer in use you can\n",
191+
"[clear the stale tunnel](https://github.com/microsoft/vscode-remote-release/issues/7469#issuecomment-1303968245) from the VS Code application on your machine as follows:\n",
192+
"\n",
193+
"1. Make sure that the [Remote - Tunnels](https://marketplace.visualstudio.com/items?itemName=ms-vscode.remote-server) extension is installed on your machine.\n",
194+
"2. Click on the Remote extensions pane (on the left of your UI).\n",
195+
"3. Right click on the tunnel you want to clear.\n",
196+
"4. Unregister the tunnel .\n",
197+
"\n",
198+
"![unregister a VS Code tunnel](https://raw.githubusercontent.com/graphcore/Gradient-HuggingFace/main/useful-tips/images/tunnel-unregister.png)\n",
199+
"\n",
200+
"You can now re-run the command to create a tunnel."
201+
]
202+
}
203+
],
204+
"metadata": {
205+
"kernelspec": {
206+
"display_name": "Python 3 (ipykernel)",
207+
"language": "python",
208+
"name": "python3"
209+
},
210+
"language_info": {
211+
"codemirror_mode": {
212+
"name": "ipython",
213+
"version": 3
214+
},
215+
"file_extension": ".py",
216+
"mimetype": "text/x-python",
217+
"name": "python",
218+
"nbconvert_exporter": "python",
219+
"pygments_lexer": "ipython3",
220+
"version": "3.8.10"
221+
}
222+
},
223+
"nbformat": 4,
224+
"nbformat_minor": 4
225+
}

0 commit comments

Comments
 (0)