I am trying to train a huggingface model on jupyternotebook on my local machine.
can i get some advice on: how do i pass my IAM role access key ?
i have installed sagemaker on my jupyternotebook, however, how do i connect to my AWS account? i found a line of code:
Blockquote
gets role for executing training job
iam_client = boto3.client(‘iam’)
role = iam_client.get_role(RoleName=‘{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}’)[‘Role’][‘Arn’]
hyperparameters = {
‘model_name_or_path’:‘finiteautomata/beto-sentiment-analysis’,
‘output_dir’:‘/opt/ml/model’
# add your remaining hyperparameters
# more info here https://github.com/huggingface/transformers/tree/v4.6.1/examples/pytorch/text-classification
}
Blockquote
i have set up a new user in my AWS account and have my access keys. just don’t understand how do it pass it on to my local machine?
everytime i only get errors like:
Blockquote
ValueError: Must setup local AWS configuration with a region supported by SageMaker.
You need to create an IAM Role for sagemaker with permission to access all required resources. You can find instructions on how to do this here: SageMaker Roles - Amazon SageMaker
The IAM managed policy, AmazonSageMakerFullAccess is automatically attached to this role. To see the permissions included in this policy, select the sideways arrow next to the policy name. Select Next: Tags .
(Optional) Add tags and select Next: Review .
Give the role a name in the text field under Role name and select Create role .
On the Roles section of the IAM console, select the role you just created. If needed, use the text box to search for the role using the role name you entered in step 7.
I have had an AWS IAM role and have my unique ARN. My following problem is in my jupyternotebook, no matter how i apply my ARN to “{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}” into the below code.
iam_client = boto3.client(‘iam’)
role = iam_client.get_role(RoleName=’{IAM_ROLE_WITH_SAGEMAKER_PERMISSIONS}’)[‘Role’][‘Arn’]
i always get an error :
Blockquote
NoCredentialsError: Unable to locate credentials
could you please kindly advise what might i be missing here?
Yes let me explain this, it is a bit complicated to get started. So the IAM ROLE, which you have created will be used inside the SageMaker Training Job/Inference. Meaning this ROLE is used to, e.g. download your data from s3 or is needed to start the underlying machine.
The error NoCredentialsError: Unable to locate credentials is shown when you don’t have credentials configured on your machine. You need to run aws configure so set up IAM Credentials (User) on your machine. You need these credentials to start your training job.
So I had the same problem, but I didn’t want to use the secret access key to connect to AWS account, I was using SSO login. My goal was to deploy huggingface model from my local machine using HuggingFaceModel interface. The solution: