I have been trying to test a streamlit app on Sagemaker Studio.
If I run the streamlit hello
command on the system terminal, the command executes properly and I'm able to access the app at
https://x-xxxxxxxxxxxx.studio.us-west-2.sagemaker.aws/jupyter/default/proxy/8501/
When I run the same command through an image terminal, I get the 500 : Internal Server Error
at the same link. Is there any way to use streamlit with an image terminal?
Unfortunately, SageMaker Studio architecture at this moment doesn't allow you to run apps through Jupyter Proxy on a kernel gateway. Therefore, running Streamlit in an image terminal is a little bit tricky.
One of the options is to use SageMaker SSH Helper library. After reading and completing the "Getting Started" section, you will need to jump to the "Local IDE integration with SageMaker Studio over SSH". Inside the script sm-local-ssh-ide
there are lines with the port forwarding instructions for the SSH client.
You will need to add one more:
-L localhost:8501:localhost:8501 \
After you complete all steps and run this script, your Streamlit app that you've started inside the SageMaker Studio image terminal will be available on your local machine at http://localhost:8501/.
If you want to learn more how SageMaker Studio works, I recommend this nice blog post by Giuseppe Angelo Porcelli and Vikesh Pandey: Dive deep into Amazon SageMaker Studio Notebooks architecture.