Skip to main content
girl in a tunnel with logos for zrok, pinggy, kaggle and sagemaker around her

In the dynamic realm of tech development, Amazon Sagemaker Studio Lab stands out as a powerful platform for running and developing various AI demos using web user interfaces (UIs). However, the challenge lies in accessing these apps from the outside world.

Introduction: Unleashing the Power of Sagemaker Studio Lab

Amazon Sagemaker Studio Lab offers developers a versatile environment to build and deploy machine learning models, applications, and more. But what about web UIs? That's where things get interesting.

Setting the Stage: The Challenge of Accessing Web Apps

Picture this: you've developed a stellar web demo for your AI project on Sagemaker Studio Lab, but accessing it through a browser leads to a frustrating 404 error. That's where our journey begins – tackling the hurdles and finding efficient solutions to access and interact with web apps seamlessly.

Solution 1: Pinggy - Simplicity at Its Finest

Enter Pinggy, our first contender in the quest for easy web app access. Utilizing SSH, Pinggy offers a straightforward solution that requires minimal setup. With just a few commands, you can generate a temporary link to access your web app in all its glory. Quick, simple, and effective – Pinggy gets the job done with ease.

To start your app with Pinggy, you'll need to

  • Install OpenSSH if it's not already installed in your environment.
    • conda config --add channels conda-forge
       conda config --set channel_priority strict
       conda install -y openssh
  • Start your app and create a link with Pinggy
    • python launch.py & ssh -o StrictHostKeyChecking=no -p 80 -R0:localhost:7860 a.pinggy.io

Solution 2: Zrok - A Deeper Dive

For those seeking a more robust solution, Zrok steps up to the plate. While the setup may be slightly more involved, the benefits are undeniable. By creating an account and generating a token, Zrok provides a secure tunnel to your web app, ensuring smooth accessibility without compromising on security. Once set up, accessing your web app is just a click away.

To start your app with Zrok,

  • Install Zrok on your instance. 
    • wget https://github.com/openziti/zrok/releases/download/v0.4.23/zrok_0.4.23_linux_amd64.tar.gz
       tar -xvf ./zrok*.gz 
       chmod a+x zrok 
  • Optionally, add Zrok to your path variable
    • Replace PATH/TO/ZROK/FOLDER below with the full path to the folder where you extracted Zrok.
    • In a Jupyter notebook, run
      • import os
         os.environ['PATH'] += ":/home/studio-lab-user/zrok"
    • Or run the following in a Terminal
      • export PATH=$PATH:/PATH/TO/ZROK/FOLDER
  • Create an account
    • zrok invite
  • Follow the link in your email and copy your token
  • Enable your environment
    • zrok enable YOUR_TOKEN_HERE
  • Start your app and tunnel through Zrok
    • python launch.py & zrok share public http://localhost:7860 --headless

If you need to replace your Zrok token, disable the old token by running 

zrok disable

 

Get a Quickstart with Complete Notebooks

If you prefer an already finished solution, we have two Jupyter notebooks, that include all the necessary steps to run the Stable Diffusion WebUI. You can make changes to the installation block, as well as the start-up commands to use the same tunneling solutions on different app.

Integration and Innovation: Future Updates

But our journey doesn't end here. We're constantly pushing the boundaries and exploring new avenues to enhance the AI enthusiast's experience. That's why we're excited to announce our efforts to integrate Pinggy and Zrok into our Fooocus and InvokeAI installers for SageMaker. We have already integrated both into our ComfyUI notebook for Kaggle. Stay tuned for updates as we strive to make accessing web UIs in cloud envrionments even more efficient.

Conclusion: Empower Your Sagemaker Experience

Both Zrok and Pinggy got the job done quickly and efficiently. Here's what we've learned using the two:

PinggyZrok
Link lasts 1 hour on the free tierLink did not expire
No registration requiredRequires registration via email
No token requiredGet a free token on your account page
Uses SSHUses the zrok app

In conclusion, accessing web apps on Sagemaker Studio Lab doesn't have to be a daunting task. With tools like Pinggy and Zrok at your disposal, you can streamline the process and unlock the full potential of your web development projects.