Giter Site home page Giter Site logo

Comments (3)

BernhardLenz avatar BernhardLenz commented on June 18, 2024 10

AWS support recommended below solution:

This seems to be a known issue when executing the code locally, as mentioned in the following Github issue [3]. A work-around to fix the issue is also defined in that issue [3] and can be referred to using the following link: aws/sagemaker-python-sdk#300 (comment)

The steps in the work-around given in the above link are:

1. Login to the AWS console -> IAM -> Roles -> Create Role

2. Create an IAM role and select the "SageMaker" service

3. Give the role "AmazonSageMakerFullAccess" permission

4. Review and create the role

5. Next, also attach the "AWSRoboMakerFullAccess" permission policy to the above created role (as required in the Github notebook [1]).

6. The original code would then need to be modified to fetch the IAM role directly when the code is executed on a local machine. The code snippet to be used is given below:

    try:
        sagemaker_role = sagemaker.get_execution_role()
    except ValueError:
        iam = boto3.client('iam')
        sagemaker_role = iam.get_role(RoleName='<sagemaker-IAM-role-name>')['Role']['Arn']

In the above snippet, replace the "" text with the IAM role name created in Step 4.

References:

[1] https://github.com/aws-samples/aws-deepracer-workshops/blob/master/log-analysis/DeepRacer%20Log%20Analysis.ipynb
[2] https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-ex-role.html
[3] aws/sagemaker-python-sdk#300

from guidance-for-training-an-aws-deepracer-model-using-amazon-sagemaker.

 avatar commented on June 18, 2024

from guidance-for-training-an-aws-deepracer-model-using-amazon-sagemaker.

BernhardLenz avatar BernhardLenz commented on June 18, 2024

@AachenAU Good point. I tried but getting a different error which is

----> 4     sagemaker_role = sagemaker.get_execution_role('sagemaker')
/opt/conda/lib/python3.7/site-packages/sagemaker/session.py in get_execution_role(sagemaker_session)
   3314     if not sagemaker_session:
   3315         sagemaker_session = Session()
-> 3316     arn = sagemaker_session.get_caller_identity_arn()
AttributeError: 'str' object has no attribute 'get_caller_identity_arn'

The full error is below:

Couldn't call 'get_role' to get Role ARN from role name arn:aws:iam::26********:root to get Role path.
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-9bb111bb0794> in <module>
      1 try:
----> 2     sagemaker_role = sagemaker.get_execution_role()
      3 except:

/opt/conda/lib/python3.7/site-packages/sagemaker/session.py in get_execution_role(sagemaker_session)
   3323     )
-> 3324     raise ValueError(message.format(arn))
   3325 

ValueError: The current AWS identity is not a role: arn:aws:iam::26********:root, therefore it cannot be used as a SageMaker execution role

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-6-9bb111bb0794> in <module>
      2     sagemaker_role = sagemaker.get_execution_role()
      3 except:
----> 4     sagemaker_role = sagemaker.get_execution_role('sagemaker')
      5 
      6 print("Using Sagemaker IAM role arn: \n{}".format(sagemaker_role))

/opt/conda/lib/python3.7/site-packages/sagemaker/session.py in get_execution_role(sagemaker_session)
   3314     if not sagemaker_session:
   3315         sagemaker_session = Session()
-> 3316     arn = sagemaker_session.get_caller_identity_arn()
   3317 
   3318     if ":role/" in arn:

AttributeError: 'str' object has no attribute 'get_caller_identity_arn'

from guidance-for-training-an-aws-deepracer-model-using-amazon-sagemaker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.