0

Google has answers for SageMaker Studio, but I am at a loss for an answer on SageMaker Studio LAB...

I am reading the following on XGBoost - Am I in the right place for SM Studio LAB?

https://docs.aws.amazon.com/sagemaker/latest/dg/xgboost.html

Is there a better way for me to use XGBoost in LAB, vs what I am doing below by reading the doc above?

In SageMaker Studio I would do the following to get the ECR container for the XGBoost algorithm:

from sagemaker import image_uris
container = image_uris.retrieve('xgboost', boto3.Session().region_name, '1')

I made it a bit farther using the github example:

https://github.com/aws/studio-lab-examples/blob/main/connect-to-aws/Access_AWS_from_Studio_Lab.ipynb

This works:

from sagemaker import image_uris
from sagemaker.xgboost import XGBoost

# Create a training job name
job_name = 'ufo-xgboost-job-{}'.format(datetime.now().strftime("%Y%m%d%H%M%S"))
print('Here is the job name {}'.format(job_name))

import sagemaker
import boto3
from sagemaker import image_uris
from sagemaker.session import Session
from sagemaker.inputs import TrainingInput

But this is giving me trouble:

sess = sagemaker.Session()

xgb = sagemaker.estimator.Estimator(container,
                                    role, 
                                    instance_count=1, 
                                    instance_type='ml.m4.xlarge',
                                    output_path='model.tar.gz',
                                    sagemaker_session=sess)

xgb.set_hyperparameters(objective='multi:softmax',
                        num_class=3,
                        num_round=100)

data_channels = {
    'train': s3_input_train,
    'validation': s3_input_validation
}
xgb.fit(data_channels, job_name=job_name) 

With the following errors:

ParsingError                              Traceback (most recent call last)
~/.conda/envs/default/lib/python3.9/site-packages/botocore/configloader.py in raw_config_parse(config_filename, parse_subsections)
    148         try:
--> 149             cp.read([path])
    150         except (six.moves.configparser.Error, UnicodeDecodeError):

~/.conda/envs/default/lib/python3.9/configparser.py in read(self, filenames, encoding)
    696                 with open(filename, encoding=encoding) as fp:
--> 697                     self._read(fp, filename)
    698             except OSError:

~/.conda/envs/default/lib/python3.9/configparser.py in _read(self, fp, fpname)
   1115         if e:
-> 1116             raise e
   1117 

ParsingError: Source contains parsing errors: '/home/studio-lab-user/.aws/config'
    [line  5]: 'from sagemaker import image_uris\n'
    [line  6]: 'import boto3\n'

During handling of the above exception, another exception occurred:

truncated error at bottom:

ConfigParseError: Unable to parse config file: /home/studio-lab-user/.aws/config

1 Answers1

0

You're trying to run an external training job that would run outside of your Studio Lab Environment, on an ephemeral EC2 instance as part of a SageMaker training job.
With the error being: ConfigParseError: Unable to parse config file: /home/studio-lab-user/.aws/config it sounds like you didn't configure your AWS credentials correctly.
Did you complete successfully step 0 and step 1, in this guide for connecting Studio Lab with your AWS account?

Alternatively: Run XGBoost locally in your Studio Lab - OR - as you already have an AWS account use SageMaker Studio (isn't free), which will already be configured with a certain IAM role your admin will configure when creating the Studio domain.

Gili Nachum
  • 5,288
  • 4
  • 31
  • 33
  • 1
    Thanks Gili, Your response makes sense, appreciate it, as I did try thi9s for the first time using steps 0 and 1 in the link you mention. I've been playing around with the credentials and paths while learning the differences or nuances required in SMS LAB version. I'm going to play around with it some more and see if I get it working and post the answer here. – MatthewEvolving Jan 25 '22 at 01:01