Predictive Hacks

How to Connect Amazon SageMaker Studio Lab with S3

AWS’s response to the Google Colab is the AWS SageMaker Studio Lab. In this tutorial, we will show you how to connect AWS SageMaker Studio Lab with S3.

Install the awscli Library

We can work with the Jupyter notebooks directly. First, we will install the awscli library.

%pip install awscli

Create a Directory to Store the Credentials and the Config files

The next step is to make a directory called .aws where we will store the credentials and the config files.

We make the .aws directory:

!mkdir ~/.aws

Then we create the credentials file storing the access and secret keys:

%%writefile ~/.aws/credentials

aws_access_key_id =  < paste your access key here, run this cell, then delete the cell >
aws_secret_access_key = < paste your secret key here, run this cell, then delete the cell > 

Finally, we create the config file.

%%writefile ~/.aws/config


Note that the locations of the credentials and the config files are:

  • /home/studio-lab-user/.aws/credentials
  • /home/studio-lab-user/.aws/config

Let’s do an ls -lta to see the files and the directories under the parent directory.

!ls -lta

As we can see the .aws file is there! Let’s get the content of the config file.

!cat .aws/config

Copy from S3 to Amazon SageMaker Studio Lab

Now we are set. Let’s see how we can copy a bucket from S3 to Studio Lab. Note that the working directory is the /home/studio-lab-user. Let’s copy the S3 bucket called gpipisbucket under the /home/studio-lab-user/MyS3Buckets/gpipisbucket path.

!aws s3 cp s3://gpipisbucket /home/studio-lab-user/MyS3Buckets/gpipisbucket --recursive

And voilà! We copy the S3 bucket to Studio Lab

Related Articles

You may find useful the following articles:

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore


Image Captioning with HuggingFace

Image captioning with AI is a fascinating application of artificial intelligence (AI) that involves generating textual descriptions for images automatically.


Intro to Chatbots with HuggingFace

In this tutorial, we will show you how to use the Transformers library from HuggingFace to build chatbot pipelines. Let’s