Difference between revisions of "VS Code Remote Development"

From UFRC
Jump to navigation Jump to search
m (Israel.herrera moved page Draft:VSCode Server Setup to VSCode Server Setup without leaving a redirect)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
This guide provides information on running VSCode Server on HiPerGator, including running Jupyter notebooks. While I work with Research Computing, and this may eventually be transitioned to our official documentation, '''this is currently not officially supported by UF Research Computing.'''
+
This guide provides information on running VSCode Remote Development on HiPerGator, including running Jupyter notebooks. This has been updated in December 2022 when Microsoft [https://code.visualstudio.com/blogs/2022/12/07/remote-even-better integrated Remote Development into VSCode].
  
 
Why might you want to do this?
 
Why might you want to do this?
Line 10: Line 10:
 
** You can accidentally end up running scripts on the login servers and have your account suspended.
 
** You can accidentally end up running scripts on the login servers and have your account suspended.
 
** Running VSCode on HiPerGator through OOD is kind of slow and limiting in terms of extensions and updates.
 
** Running VSCode on HiPerGator through OOD is kind of slow and limiting in terms of extensions and updates.
* With VSCode Server (currently in [https://code.visualstudio.com/blogs/2022/07/07/vscode-server private beta], 2022-10-07), you can startup the server within an interactive job with whatever resources you have requested and connect to it in your web browser. No MFA issues, install your desired extensions, connect to GitHub Copilot, run and debug your code easily!
+
* With VSCode Remote Development, you can startup the server within an interactive job with whatever resources you have requested and connect to it in your web browser. No MFA issues, install your desired extensions, connect to GitHub Copilot, run and debug your code easily!
  
== Request access to the VSCode Server private beta ==
 
  
As of this writing, VSCode Server is still in private beta. This means that you will need to request access. See: [https://code.visualstudio.com/blogs/2022/07/07/vscode-server#_getting-started VSCode Server Getting Started] for the sign-up form.
+
== Install VSCode in your ~/bin folder ==
  
== Install VSCode Server in your ~/bin folder ==
+
This may become somewhat optional as Research Computing updates VSCode, but this does give you full control over the version to use.
  
The installation instructions for VSCode Server will not quite work as-is on HiPerGator as the script that is used relies on <code>sudo</code>, which users do not have.
+
# Download the x64 CLI for Linux package from the [https://code.visualstudio.com/#alt-downloads VSCode Downloads site ].
 +
# Transfer the download to HiPerGator.
 +
# Extract the tar.gz file and copy the binary to ~/bin:
  
The following modifications are needed.
+
tar -xvf vscode_cli_alpine_x64_cli.tar.gz
<ol>
+
cp code ~/bin/
<li>Download and keep the <code>setup.sh</code> script:
+
 
<pre style="color: red">wget https://aka.ms/install-vscode-server/setup.sh</pre>
+
 
</li>
+
== First run: Launch a development session and start VSCode tunnel==
<li>Edit the <code>setup.sh</code> script:
 
<ul><li>Change line 3 (You can replace <code>$USER</code> with your username, though it should work as-is):
 
<pre style="color: red">- INSTALL_LOCATION=/usr/local/bin/code-server</pre>
 
<pre style="color: green">+ INSTALL_LOCATION=/home/$USER/bin/code-server</pre>
 
</li>
 
<li>Delete or comment out lines 58-67 (note line numbers are included here):
 
<pre style="color: red">
 
- 58  if command_exists sudo;
 
- 59  then
 
- 60    if [ "$DOWNLOAD_WITH" = curl ]; then
 
- 61      sudo curl -sSL "$INSTALL_URL" -o "$INSTALL_LOCATION"
 
- 62    else
 
- 63      sudo wget -qO "$INSTALL_LOCATION" "$INSTALL_URL"
 
- 64    fi
 
- 65
 
- 66    sudo chown $USER $INSTALL_LOCATION
 
- 67  else
 
</pre>
 
</li>
 
<li>Change line 3 (You can replace <code>$USER</code> with your username, though it should work as-is):
 
<pre style="color: red">- 73 fi</pre>
 
</li>
 
</ul>
 
<li>Run the edited <code>setup.sh</code>, which will download and install <code>code-server</code> at <code>~/bin/code-server</code>, which is in your <code>$PATH</code>.
 
</li>
 
</li>
 
</ol>
 
  
== First run: Launch a development session and start VSCode Server ==
 
 
# See [this page for information on development sessions HiPerGator](Development_and_Testing), but something like this should work: <code>srun --mem=4gb --time=01:00:00 --pty bash -i</code>
 
# See [this page for information on development sessions HiPerGator](Development_and_Testing), but something like this should work: <code>srun --mem=4gb --time=01:00:00 --pty bash -i</code>
# Start VSCode Server: <code>code-server</code>
+
# Start VSCode Server: <code>code tunnel</code>
# Continue to follow steps 2-5 on the [https://code.visualstudio.com/blogs/2022/07/07/vscode-server#_getting-started VSCode Server page] to authenticate your GitHub account, name your server (HiPerGator might be a good name), and accept terms.
 
# You are mostly set! Though you can add additional extensions, like GitHub Copilot, if you want.
 
  
 
== For daily use ==
 
== For daily use ==
  
Now that VSCode Server is setup, it should be relatively easy to start. For the most part, the process is:
+
Now that VSCode is setup, it should be relatively easy to start. For the most part, the process is:
  
 
# Log into HiPerGator
 
# Log into HiPerGator
 
# Start a development session, [https://help.rc.ufl.edu/doc/GPU_Access#Interactive_Access requesting GPUs if needed], and other resources for the time you want to work.
 
# Start a development session, [https://help.rc.ufl.edu/doc/GPU_Access#Interactive_Access requesting GPUs if needed], and other resources for the time you want to work.
 
# For Jupyter notebooks it is important to:
 
# For Jupyter notebooks it is important to:
#* Load Jupyter and the module you need for the kernel you want to use, e.g. for Tensorflow: <code>module load jupyter tensorflow/2.7.0</code>
+
#* Load Jupyter and the module you need for the kernel you want to use, e.g. for Tensorflow: <code>module load jupyter tensorflow/2.7.0</code>
 
#* Export the <code>XDG_RUNTIME_DIR</code> to set temp directory (otherwise it tries to use <code>/run/user/</code>, which you can't be written to!): <code>export XDG_RUNTIME_DIR=${SLURM_TMPDIR}</code>
 
#* Export the <code>XDG_RUNTIME_DIR</code> to set temp directory (otherwise it tries to use <code>/run/user/</code>, which you can't be written to!): <code>export XDG_RUNTIME_DIR=${SLURM_TMPDIR}</code>
# Start VSCode server: <code>code-server</code>
+
# Start VSCode tunnel: <code>code tunnel</code>
#*This can all be done with this line: <code>module load jupyter tensorflow/2.7.0; export XDG_RUNTIME_DIR=${SLURM_TMPDIR}; code-server</code>
+
#*This can all be done with this line: <code>module load jupyter tensorflow/2.7.0; export XDG_RUNTIME_DIR=${SLURM_TMPDIR}; code tunnel</code>
 
# Connect to the URL provided in your browser.
 
# Connect to the URL provided in your browser.
 
# Code away!
 
# Code away!

Revision as of 16:44, 12 December 2022

This guide provides information on running VSCode Remote Development on HiPerGator, including running Jupyter notebooks. This has been updated in December 2022 when Microsoft integrated Remote Development into VSCode.

Why might you want to do this?

  • VSCode is a nice IDE with many great features, including GitHub Copilot (which most UF users should be able to access for free--via either student or faculty/staff GitHub Education plans).
  • HiPerGator provides a powerful compute environment with thousands of cores, petabytes of storage, and powerful GPUs.
  • But, combining the two can be problematic...
    • Remote SSH setup is complicated by MFA and the need to tunnel into a compute server with your running job. This can be worked out, but is a bit cumbersome.
    • You can accidentally end up running scripts on the login servers and have your account suspended.
    • Running VSCode on HiPerGator through OOD is kind of slow and limiting in terms of extensions and updates.
  • With VSCode Remote Development, you can startup the server within an interactive job with whatever resources you have requested and connect to it in your web browser. No MFA issues, install your desired extensions, connect to GitHub Copilot, run and debug your code easily!


Install VSCode in your ~/bin folder

This may become somewhat optional as Research Computing updates VSCode, but this does give you full control over the version to use.

  1. Download the x64 CLI for Linux package from the VSCode Downloads site .
  2. Transfer the download to HiPerGator.
  3. Extract the tar.gz file and copy the binary to ~/bin:
tar -xvf vscode_cli_alpine_x64_cli.tar.gz
cp code ~/bin/


First run: Launch a development session and start VSCode tunnel

  1. See [this page for information on development sessions HiPerGator](Development_and_Testing), but something like this should work: srun --mem=4gb --time=01:00:00 --pty bash -i
  2. Start VSCode Server: code tunnel

For daily use

Now that VSCode is setup, it should be relatively easy to start. For the most part, the process is:

  1. Log into HiPerGator
  2. Start a development session, requesting GPUs if needed, and other resources for the time you want to work.
  3. For Jupyter notebooks it is important to:
    • Load Jupyter and the module you need for the kernel you want to use, e.g. for Tensorflow: module load jupyter tensorflow/2.7.0
    • Export the XDG_RUNTIME_DIR to set temp directory (otherwise it tries to use /run/user/, which you can't be written to!): export XDG_RUNTIME_DIR=${SLURM_TMPDIR}
  4. Start VSCode tunnel: code tunnel
    • This can all be done with this line: module load jupyter tensorflow/2.7.0; export XDG_RUNTIME_DIR=${SLURM_TMPDIR}; code tunnel
  5. Connect to the URL provided in your browser.
  6. Code away!