Introduction
Tired of being tied to your local machine for development? Wish you could access your perfectly customized VS Code environment from anywhere? Coder, an open-source project, allows you to run VS Code in the cloud, unlocking a world of possibilities. This post will guide you through setting up your own instance of Code Server on Google Cloud Platform (GCP) and supercharging it with Tensor Processing Units (TPUs) for machine learning tasks.
What is Coder and Why Use It?
Coder, created by a startup of the same name, makes VS Code accessible in the browser. This means you can access your IDE and its settings from any device, including your phone or tablet. Benefits include:
- Accessibility: Develop from anywhere with an internet connection.
- Collaboration: Multiple developers can collaborate on the same project in real-time.
- Scalability: Attach virtually unlimited computing resources to the backend.
Setting Up Code Server on Google Cloud Platform
Here's how to get your own Code Server instance running on GCP:
- Create a Virtual Machine: In the GCP console, navigate to Compute Engine and create a new VM instance. Choose an appropriate configuration (e.g., standard instance with 2 CPU cores and 7.5 GB of memory). Select Ubuntu 16.04 as the operating system and allow HTTP/HTTPS traffic. Remember to shut down the VM when not in use to avoid incurring costs.
- Install Code Server: Once the VM is running, use the SSH button to access its command line. The easiest option is to use Cloud Shell. Download the latest Linux release of Code Server using
wget
: - Unzip and Run Code Server: Unzip the downloaded file using the
tar
command: - Configure Firewall (if needed): For front-end development, you might need to open specific ports in the firewall. Go to the network details of your VM and either modify the default firewall rule or create a new one to allow traffic on the desired port (e.g., 4200 for Angular). Don't forget to tag the VM with the firewall rule's tag.
wget [download URL from GitHub]
tar -xvzf [downloaded_file].tar.gz
Then, navigate to the unzipped directory and run Code Server:
sudo ./code-server --port 80
Note the password provided in the terminal output. Access your VS Code instance by navigating to your VM's external IP address with port 80 (e.g., http://[external_ip]:80
) in your browser and entering the password.
Supercharging with Tensor Processing Units (TPUs)
For machine learning tasks, TPUs offer significantly better performance than CPUs or even GPUs. Here's how to integrate them with your Code Server instance:
- Create a TPU: In the GCP console, navigate to the TPUs tab (under Compute Engine). Be aware of the costs involved (hundreds of dollars per hour) and ensure you delete the TPU when you're finished. You can also create the TPU from the command line using
ctpu up
. This creates a TPU node and a corresponding VM with TensorFlow pre-installed. - Install Code Server on the TPU VM: You'll need to install Code Server on the new VM created alongside the TPU using the same steps as described in the previous section.
- Modify Your TensorFlow Code: Adapt your TensorFlow code to utilize the TPU. This typically involves using a distribution strategy. The example in the transcript uses the
TPU distribution strategy
.
The video demonstrates a performance comparison by training a neural network on a synthetic dataset. Training that took approximately 90 minutes on a CPU was reduced to just 2.5 minutes on a TPU.
Conclusion
Running VS Code in the cloud with Coder unlocks flexibility, collaboration, and scalability for your development workflow. By leveraging the power of Google Cloud Platform and TPUs, you can significantly accelerate computationally intensive tasks like machine learning model training. Coder represents a powerful trend towards browser-based development environments, making software development more accessible and efficient.
0 Comments