我想在sagemaker中运行一个简单的模型。
当尝试运行以下代码时,我一直得到这个错误。
这是一个非常简单的代码,我看到在一些教程和sagemaker的例子,包括在木星的笔记本。
有谁知道我应该怎么做才能让它工作吗?
输入:
import sagemaker
sess = sagemaker.Session()
输出:
---------------------------------------------------------------------------
UnknownServiceError Traceback (most recent call last)
/tmp/ipykernel_11350/4126940475.py in <cell line: 3>()
1 import sagemaker
2
----> 3 sess = sagemaker.Session()
~/anaconda3/envs/python3/lib/python3.8/site-packages/sagemaker/session.py in __init__(self, boto_session, sagemaker_client, sagemaker_runtime_client, sagemaker_featurestore_runtime_client, default_bucket, settings, sagemaker_metrics_client)
131 self.settings = settings
132
--> 133 self._initialize(
134 boto_session=boto_session,
135 sagemaker_client=sagemaker_client,
~/anaconda3/envs/python3/lib/python3.8/site-packages/sagemaker/session.py in _initialize(self, boto_session, sagemaker_client, sagemaker_runtime_client, sagemaker_featurestore_runtime_client, sagemaker_metrics_client)
183 self.sagemaker_metrics_client = sagemaker_metrics_client
184 else:
--> 185 self.sagemaker_metrics_client = self.boto_session.client("sagemaker-metrics")
186 prepend_user_agent(self.sagemaker_metrics_client)
187
~/anaconda3/envs/python3/lib/python3.8/site-packages/boto3/session.py in client(self, service_name, region_name, api_version, use_ssl, verify, endpoint_url, aws_access_key_id, aws_secret_access_key, aws_session_token, config)
297
298 """
--> 299 return self._session.create_client(
300 service_name,
301 region_name=region_name,
~/anaconda3/envs/python3/lib/python3.8/site-packages/botocore/session.py in create_client(self, service_name, region_name, api_version, use_ssl, verify, endpoint_url, aws_access_key_id, aws_secret_access_key, aws_session_token, config)
868 retryhandler, translate, response_parser_factory,
869 exceptions_factory, config_store)
--> 870 client = client_creator.create_client(
871 service_name=service_name, region_name=region_name,
872 is_secure=use_ssl, endpoint_url=endpoint_url, verify=verify,
~/anaconda3/envs/python3/lib/python3.8/site-packages/botocore/client.py in create_client(self, service_name, region_name, is_secure, endpoint_url, verify, credentials, scoped_config, api_version, client_config)
85 'choose-service-name', service_name=service_name)
86 service_name = first_non_none_response(responses, default=service_name)
---> 87 service_model = self._load_service_model(service_name, api_version)
88 cls = self._create_client_class(service_name, service_model)
89 region_name, client_config = self._normalize_fips_region(
~/anaconda3/envs/python3/lib/python3.8/site-packages/botocore/client.py in _load_service_model(self, service_name, api_version)
152
153 def _load_service_model(self, service_name, api_version=None):
--> 154 json_model = self._loader.load_service_model(service_name, 'service-2',
155 api_version=api_version)
156 service_model = ServiceModel(json_model, service_name=service_name)
~/anaconda3/envs/python3/lib/python3.8/site-packages/botocore/loaders.py in _wrapper(self, *args, **kwargs)
130 if key in self._cache:
131 return self._cache[key]
--> 132 data = func(self, *args, **kwargs)
133 self._cache[key] = data
134 return data
~/anaconda3/envs/python3/lib/python3.8/site-packages/botocore/loaders.py in load_service_model(self, service_name, type_name, api_version)
375 known_services = self.list_available_services(type_name)
376 if service_name not in known_services:
--> 377 raise UnknownServiceError(
378 service_name=service_name,
379 known_service_names=', '.join(sorted(known_services)))
UnknownServiceError: Unknown service: 'sagemaker-metrics'. Valid service names are: accessanalyzer, account, acm, acm-pca, alexaforbusiness, amp, amplify, amplifybackend, amplifyuibuilder, apigateway, apigatewaymanagementapi, apigatewayv2, appconfig, appconfigdata, appflow, appintegrations, application-autoscaling, application-insights, applicationcostprofiler, appmesh, apprunner, appstream, appsync, athena, auditmanager, autoscaling, autoscaling-plans, backup, backup-gateway, batch, braket, budgets, ce, chime, chime-sdk-identity, chime-sdk-meetings, chime-sdk-messaging, cloud9, cloudcontrol, clouddirectory, cloudformation, cloudfront, cloudhsm, cloudhsmv2, cloudsearch, cloudsearchdomain, cloudtrail, cloudwatch, codeartifact, codebuild, codecommit, codedeploy, codeguru-reviewer, codeguruprofiler, codepipeline, codestar, codestar-connections, codestar-notifications, cognito-identity, cognito-idp, cognito-sync, comprehend, comprehendmedical, compute-optimizer, config, connect, connect-contact-lens, connectparticipant, cur, customer-profiles, databrew, dataexchange, datapipeline, datasync, dax, detective, devicefarm, devops-guru, directconnect, discovery, dlm, dms, docdb, drs, ds, dynamodb, dynamodbstreams, ebs, ec2, ec2-instance-connect, ecr, ecr-public, ecs, efs, eks, elastic-inference, elasticache, elasticbeanstalk, elastictranscoder, elb, elbv2, emr, emr-containers, es, events, evidently, finspace, finspace-data, firehose, fis, fms, forecast, forecastquery, frauddetector, fsx, gamelift, glacier, globalaccelerator, glue, grafana, greengrass, greengrassv2, groundstation, guardduty, health, healthlake, honeycode, iam, identitystore, imagebuilder, importexport, inspector, inspector2, iot, iot-data, iot-jobs-data, iot1click-devices, iot1click-projects, iotanalytics, iotdeviceadvisor, iotevents, iotevents-data, iotfleethub, iotsecuretunneling, iotsitewise, iotthingsgraph, iottwinmaker, iotwireless, ivs, kafka, kafkaconnect, kendra, keyspaces, kinesis, kinesis-video-archived-media, kinesis-video-media, kinesis-video-signaling, kinesisanalytics, kinesisanalyticsv2, kinesisvideo, kms, lakeformation, lambda, lex-models, lex-runtime, lexv2-models, lexv2-runtime, license-manager, lightsail, location, logs, lookoutequipment, lookoutmetrics, lookoutvision, machinelearning, macie, macie2, managedblockchain, marketplace-catalog, marketplace-entitlement, marketplacecommerceanalytics, mediaconnect, mediaconvert, medialive, mediapackage, mediapackage-vod, mediastore, mediastore-data, mediatailor, memorydb, meteringmarketplace, mgh, mgn, migration-hub-refactor-spaces, migrationhub-config, migrationhubstrategy, mobile, mq, mturk, mwaa, neptune, network-firewall, networkmanager, nimble, opensearch, opsworks, opsworkscm, organizations, outposts, panorama, personalize, personalize-events, personalize-runtime, pi, pinpoint, pinpoint-email, pinpoint-sms-voice, polly, pricing, proton, qldb, qldb-session, quicksight, ram, rbin, rds, rds-data, redshift, redshift-data, rekognition, resiliencehub, resource-groups, resourcegroupstaggingapi, robomaker, route53, route53-recovery-cluster, route53-recovery-control-config, route53-recovery-readiness, route53domains, route53resolver, rum, s3, s3control, s3outposts, sagemaker, sagemaker-a2i-runtime, sagemaker-edge, sagemaker-featurestore-runtime, sagemaker-runtime, savingsplans, schemas, sdb, secretsmanager, securityhub, serverlessrepo, service-quotas, servicecatalog, servicecatalog-appregistry, servicediscovery, ses, sesv2, shield, signer, sms, sms-voice, snow-device-management, snowball, sns, sqs, ssm, ssm-contacts, ssm-incidents, sso, sso-admin, sso-oidc, stepfunctions, storagegateway, sts, support, swf, synthetics, textract, timestream-query, timestream-write, transcribe, transfer, translate, voice-id, waf, waf-regional, wafv2, wellarchitected, wisdom, workdocs, worklink, workmail, workmailmessageflow, workspaces, workspaces-web, xray
我试图更新一些库,如sagemaker, boto, boto3,但似乎没有帮助。
我在尝试在笔记本实例中运行AWS的机器学习教程时遇到了同样的问题。我要做的是在笔记本实例中更新sagemaker,如下所示:
import sys
!{sys.executable} -m pip install sagemaker -U
希望这能解决你的问题:)
我也有同样的问题,运行
pip install sagemaker -U
帮我解决了。类似于以下问题:Sagemaker Studio UnkownServiceError for Session