I am experimenting with different containers for training and inference based on tutorial on aws sagemaker documentation. I'm using deep learning containers provided by aws here https://github.com/aws/deep-learning-containers/blob/master/available_images.md
, such as this 763104351884.dkr.ecr.us-east-1.amazonaws.com/huggingface-pytorch-training:1.10.2-transformers4.17.0-gpu-py38-cu113-ubuntu20.04 to create models.
Model:
Type: "AWS::SageMaker::Model"
Properties:
PrimaryContainer:
Image: '763104351884.dkr.ecr.us-east-1.amazonaws.com/huggingface-pytorch-training:1.10.2-transformers4.17.0-gpu-py38-cu113-ubuntu20.04'
ExecutionRoleArn: !GetAtt ExecutionRole.Arn
I am trying to see , if i can download this image locally via docker pull, but what account do i need to download this ?
i have an aws account, would i be able to download from 763104351884.dkr.ecr.us-east-1.amazonaws.com this url via my free account?
Related
Hi I was wondering if it would be possible to select a docker imagem from my private respository in ECR using cloud formation yml for later use when configuring my task definition on an ECS service, something like this:
ContainerImage:
Description: "Container image"
Type: AWS::ECR::PrivateRepository
The only way to do it is by development of a custom resource. The resource would be a lambda function which would use AWS SDK, such as boto3, to query your ECR, and return a list of available images to your stack for further use.
am trying to create S3 bucket using serverless framework. but when I deploy, it's creating two buckets one with the name I have mentioned in the severless.yml file and another bucket.
serverless.yml
service: aws-file-upload-tos3
provider:
name: aws
runtime: nodejs12.x
stage: dev
region: us-east-2
lambdaHashingVersion: 20201221
custom:
fileUploadBucketName: ${self:service}-${self:provider.stage}-bucket
resources:
Resources:
FileBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.fileUploadBucketName}
AccessControl: PublicRead
Buckets created are
why its creating two buckets like this
By default, serverless framework creates a bucket with a generated name like <service name>-serverlessdeploymentbuck-1x6jug5lzfnl7 to store your service's stack state.
Each successive version of your serverless app is bundled and uploaded by sls to the deployment bucket, and deployed from there.
I think you have some control over how sls does this if you use the serverless-deployment-bucket plugin.
By default, the Serverless Framework creates a number of things on your machine in order to deploy what you have configured in your serverles.yml. It then needs to make use of a service inside AWS called CloudFormation to actually create the resources you configured, like your S3 bucket. The best way to do this is to take the things it created on your machine and upload them to AWS to ensure that the deployment continues without interruption or issue and the best place to do that is S3.
So the Serverless Framework will always (by default) create its own S3 bucket entirely unrelated to what you configured as a location to store the files it generated on your AWS account, then point CloudFormation at it to build the things you configured to get built.
While you have some control over this deployment bucket there always needs to be one. And it is completely unrelated to the bucket you configured.
I am working on creating an AWS cloud formation stack wherein we create resources through a template. yaml and also create the folder for that resource in the project file to indicate what all files will go in that resource once it is created.
For example, I create a lambda function in the template. yaml with the name - "count_calories" and create a folder in the project file saying- "count_calories" and put a py file with lambda handler in it and requirement. txt file in it.
In a similar way, now I have to create a sagemaker notebook instance through the template.yaml and then upload jupyter notebooks in that notebook instance, each time the stack is created with that cloud formation template.
I have created the sagemaker notebook instance with the following template code :
NotebookInstance: #Sagemaker notebook instance
Type: AWS::SageMaker::NotebookInstance
Properties:
InstanceType: ml.t3.medium
NotebookInstanceName: !Sub Calorie-NotebookInstance-${EnvVar}
RoleArn: <RoleARN>
RootAccess: Enabled
VolumeSizeInGB: 200
I have 4 Jupyter notebooks and a data file that should go into this notebook instance once it is created. I want to do the upload through the code, not from the AWS console. Please suggest to me the right way to do it or point me to any example I can follow.
Many Thanks
You're on the right path by using template Type: AWS::SageMaker::NotebookInstance
Follow along the example here to create a SageMaker notebook using CFT
Consider using AWS::SageMaker::NotebookInstanceLifecycleConfig: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sagemaker-notebookinstancelifecycleconfig.html
First, you need to refer the LifecycleConfigName in AWS::SageMaker::NotebookInstance resource, by name. That's why I'm using !GetAtt function and not !Ref.
Then, you need to create a resource AWS::SageMaker::NotebookInstanceLifecycleConfig that you referred in previous step.
Finally, in the line Fn::Base64: you insert the commands for code/file download. I'm using wget in this example, but you can probably use another bash commands, or even download a more complex script and run it. Consider the script should run in no more than 5 minutes: https://docs.aws.amazon.com/sagemaker/latest/dg/notebook-lifecycle-config.html
Please see next code example:
JupyterNotebookInstance:
Type: AWS::SageMaker::NotebookInstance
Properties:
InstanceType: ml.t3.medium
RoleArn: !GetAtt JupyterNotebookIAMRole.Arn
NotebookInstanceName: !Ref NotebookInstanceName
LifecycleConfigName: !GetAtt JupyterNotebookInstanceLifecycleConfig.NotebookInstanceLifecycleConfigName
JupyterNotebookInstanceLifecycleConfig:
Type: "AWS::SageMaker::NotebookInstanceLifecycleConfig"
Properties:
OnStart:
- Content:
Fn::Base64: "cd /home/ec2-user/SageMaker/ && wget <your_files_url_here>"
I have a lambda which was created and deployed with CloudFormation. The lambda, as of now, uses the supported .NET Core 3.1 runtime but I want to use the "unsupported" .Net Core 5 so I have created a Docker image which the lambda can run.
The problem I have is that CloudFormation can't seem to change the lambda from running a supported runtime to running a Docker image. I get Please don't provide ImageUri when updating a function with packageType Zip. when updating the CloudFormation stack with the updated template.
This is how my CloudFormation template looks like:
MyFunction:
Type: "AWS::Serverless::Function"
Properties:
PackageType: Image
ImageUri: <uri-to-ecr-docker-image>
...
Metadata:
Dockerfile: Dockerfile
DockerContext: .
DockerTag: v1
Any ideas on how to solve this?
Configuring functions defined as container images
You cannot convert an existing .zip file archive function to use a container image. You must create a new function.
simple way
Deploy a fresh environment with a docker runtime from the start.
My code:-
resources:
name: snapshot-4
type: compute.v1.disk
properties:
zone: asia-south1-a
Kind: compute#snapshot
sourceDisk: https://www.googleapis.com/compute/v1/projects/project-id/zones/asia-south1-a/disks/disk1
But it is creating Disk.. i want the snapshot of the disk1..
The only two supported ways to create Persistent Disk snapshots are via the API and via REST or client libraries. At this time there is no possibility to create a PD snapshot using the YAML. However I can recommend you to create a feature request in the Google Cloud Platform issue tracker to review your request.