VS Code in Studio Lab

Setup VS Code in 5 mins in your environment

Sofian Hamiti
CodeX
3 min readMar 30, 2022

--

Amazon SageMaker Studio Lab gives you free access to AWS compute resources to quickly start learning and experimenting with ML. It is simple to setup and allows you to run notebooks on CPU or GPU instances.

Studio Lab is based on JupyterLab but you can also run VS Code in it.

Photo by Yancy Min on Unsplash

In this post, I will show how you can set up VS Code in Studio Lab and access it in your web browser in less than 5 mins.

Prerequisites

To go through this example, make sure you have the following:

  1. A Studio Lab account. You can request one here.
  2. Familiarity with Studio Lab. You can visit Amazon SageMaker Studio Lab for Beginners if it sounds new to you.

Setting up VS Code in your Studio Lab (5 mins)

Code-server allows us to access VS Code from a browser, while having the compute in the cloud. We will install it in our Studio Lab in 3 steps:

Step 1 - Launch your Studio Lab environment

Image by author: You can pick the CPU of GPU compute

Step 2 - Launch a terminal from the launcher

Image by author: Click on the Terminal icon in your Studio Lab launcher

Step 3 - Install and run code-server

Your Amazon SageMaker Studio Lab environment comes out of the box with conda and pip to install and manage packages. So we can install code-server using anaconda.

Below is a script you can use to install and run code-server. You can run the commands in your terminal or execute the shell script in your Studio Lab:

The script runs code-server with --auth none for illustrative purposes. You may use password or other mean to secure the access in your environment. See the code-server documentation for more details.

Image by author: You should see the following after running the code-server command.

Accessing VS Code on your browser

Studio Lab has a Jupyter proxy and you can access VS Code through it.

All you need is to copy the URL of your Studio Lab, change it a bit, and past it into a new tab:

Images by author: On the left is the original URL of my Studio Lab. I replaced /lab with /proxy/8080 and pasted it in a new browser tab.

The tab should now open VS Code. You can install the Python extension for VS Code and get to work in your ML project!

Image by author

Conclusion

Amazon SageMaker Studio Lab is an easy way to access free compute on AWS and get working on your experimental projects.

In this post, I showed how you can install VS Code in 5 mins on it, giving you the flexibility to work with notebooks or IDE.

You can also read MLOps with MLFlow and Amazon SageMaker Pipelines, and learn other cool things you can do with SageMaker.

--

--

CodeX
CodeX

Published in CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Responses (3)