Import and export models in the AWS DeepRacer console - AWS DeepRacer

Import and export models in the AWS DeepRacer console

There are scenarios in which you might need to import or export an AWS DeepRacer model. Racers who participated in an employer-sponsored event can export their models to avoid losing access to them, race administrators can provide pre-trained models for attendees to import and use during the event. Use the Your models page to import and export AWS DeepRacer models in the console.

Copy your AWS DeepRacer model to Amazon S3

To copy an AWS DeepRacer model to Amazon S3
  1. Log in to the AWS DeepRacer console.

  2. In Reinforcement learning on the navigation pane, choose Your models.

  3. Select the model you want to import by selecting the check box next to the model’s name. You can only copy one model to Amazon S3 from the console at a time.

  4. Choose the Actions button dropdown, then choose Copy to S3.

    A new Copy to Amazon S3 page opens.

  5. On the Copy to Amazon S3 page, use the Amazon S3 bucket dropdown selector to select an Amazon S3 bucket to export the model to. AWS DeepRacer S3 buckets must include deepacer in the name.

    1. If you don’t have a valid Amazon S3 bucket, create one by choosing Create a new bucket. The dropdown selector will populate a bucket name with the following format aws-deepracer-assets-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.

  6. Add an optional folder prefix to the Amazon S3 object in the S3 object prefix field.

  7. After you have set up the S3 bucket, select which assets you want to include. You must select at least one asset type to proceed.

    • Model: The model folder contains all required files for a model import.

    • Logs: Copies the training and evaluation logs for the model. This option includes the logs/, metrics/, and sim-trace/ folders.

    • Video: This option copies the videos folder to your Amazon S3 bucket. The videos folder contains the evaluation/ and training/ folders. These folders include videos from the top view, a 45 degree angle view, and a 45 degree angle view with the console overlay showing the location of the car on the track.

  8. After you press Copy, a pop-up informing you that you are responsible for the Amazon S3 data storage costs appears. If you agree with the terms, press the Copy button on the pop-up.

  9. Once the copy process starts, you will be taken back to the Your models page in the console. A banner on the top of the page will show the current status. When the export process is done the banner will confirm the successful export.

Required files for model import

To upload a model folder for a model trained outside the console, follow the steps on the Uploading objects page of the Amazon S3 documentation. The following table contains a list of the files required for the model import. If any of the required files are missing, the model import will fail.

Models trained in the AWS DeepRacer console have the folder name format DAY/MONTH/YEAR/TIME GMT. Our example model was exported on November 30, 2023 and the folder name is Thu, 30 Nov 2023 19:01:24 GMT. In this example, we refer to this folder as root.

Required files for model imports
File name Folder path Description
.coach_checkpoint root/model/ The coach checkpoint file contains the key for the model checkpoint used in the import.
ckpt files root/model/ Checkpoint files are snapshots of the model weights taken at different stages during training. They include the ckpt.index, ckpt.data, and ckpt.meta files.
model_metadata.json root/ The model metadata file contains settings that include action space definitions, sensor configuration, and the training algorithm selection.
reward_function.py root/ A python file that contains the reward function used to train the model.

Metrics files are not necessary for importing your model. If these files are not included, the training metrics and reward graph for the model will not be available on the console.

Optional files for model imports
File name Folder path Description
training_params.yaml root/ The training_params file contains training job data that includes track and vehicle information, racer and model names, and folder paths for training artifacts.
hyperparameters.json root/ip/ Contains the model's hyperparameter information such as batch size, loss type, learning rate, and number of epochs.
training-*.json root/metrics/training/ Used to visualize the model's training metrics in the AWS DeepRacer console.

Import your AWS DeepRacer model to the console

This section walks you through the process of importing an AWS DeepRacer model to the console. Before you can import a model, you need to copy the Amazon S3 URL for the model folder.

Copy the AWS DeepRacer Amazon S3 bucket URL
  1. Log in to the Amazon S3 console and go to the Buckets page.

  2. Select the Amazon S3 bucket you created for your AWS DeepRacer model by pressing the link on the name of the bucket. The format of S3 buckets created in the AWS DeepRacer console is aws-deepracer-assets-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.

  3. From the Objects tab of the AWS DeepRacer bucket:

    1. Select the model you want to import by pressing the model object’s name link in the Name field.

      A list of subfolders appears.

    2. Select the root of the model folder by choosing the checkbox next to the folder name. Models trained in the AWS DeepRacer console have the folder name format DAY/MONTH/YEAR/TIME GMT.

  4. Once you navigate to the root of the model folder, select the Copy S3 URL button. The Copy s3 URL, Copy URL, Open, and Delete buttons will be grayed out until you select the checkbox next to the model name.

    Note

    If you added a prefix during the Copy to S3 process, such as my_model/version_2, the path of your model folder is deep_racer_bucket/model_name/my_model/version_2/root/.

Import your model to the AWS DeepRacer console
  1. On the AWS DeepRacer console, go to the Your models page.

  2. Select the Import Model button on the models container.

    The import model page will appear.

  3. On the Import section:

    1. Enter the Amazon S3 URL for the model folder you want to import. The Amazon S3 URL has the format s3://deep_racer_bucket/model_name/prefix/root.

  4. On the Details section:

    1. Enter the model name.

    2. Add an optional description for the model.

    3. If you’re using an administrator account using multi-user mode, choose the user you’re importing the model for from the dropdown selector.

  5. Select the Import button on the bottom of the screen.

  6. Once the import process starts, you will be taken back to the Your models page in the console. A banner on the top of the page will show the current status, and the model will appear in your models list with Importing.. as its status. When the import process is done, the banner will confirm the successful import and the status of your model will change from Importing.. to Ready.

Troubleshooting

We couldn't copy your model despite making several attempts. If the model is still in your S3 bucket, retry the model import by selecting the model from the Model errors table, and choosing Update, then choosing Import. Or, If you have a local copy of the model, you can manually import it by following the steps on the Uploading objects page of the Amazon S3 documentation.

We couldn't copy the model because the S3 bucket where this model was stored has been deleted. If you have a copy of the model, place it in an S3 bucket with deepracer in its name, and try to import again following the steps in the Import your AWS DeepRacer model to the console section.

The permissions for the Amazon S3 bucket where this model is stored have changed, so we couldn't copy the model. This can happen for two reasons, you directly edited the permissions on the AWS DeepRacer S3 or the AWS DeepRacer service role policy. If you directly edited the permissions on your AWS DeepRacer S3 bucket, restore the bucket permissions by following the steps in the Adding a bucket policy by using the Amazon S3 console page using the following policy:

{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1586917903457", "Effect": "Allow", "Principal": { "Service": "deepracer.amazonaws.com" }, "Action": [ "s3:GetObjectAcl", "s3:GetObject", "s3:PutObject", "s3:PutObjectAcl" ], "Resource": [ "arn:aws:s3:::your-bucket-name", "arn:aws:s3:::your-bucket-name/*" ] } ] }

To import the model after restoring the bucket permissions, select the model from the Model errors table and choose Update. When the Model import page appears, choose Import.

We can't copy the model because it's been deleted from the Amazon S3 bucket. If you still have the file, try to restore it to your AWS DeepRacer bucket, then select the model from the Model errors table and choose Update. When the Model import page appears, choose Import. If you have a local copy of the model, you can manually import the files by following the steps on the Uploading objects page of the Amazon S3 documentation.

We can't copy the model because the coach checkpoint metadata has been deleted from the Amazon S3 bucket. If you still have the file, try to restore it to your AWS DeepRacer bucket, then select the model from the Model errors table and choose Update. When the Model import page appears, choose Import. If you have a local copy of the model, you can manually import the files by following the steps on the Uploading objects page of the Amazon S3 documentation.

We can't copy the model because the checkpoint files have been deleted from the Amazon S3 bucket. If you still have the files, try to restore them to your AWS DeepRacer bucket, then select the model from the Model errors table and choose Update. When the Model import page appears, choose Import. If you have a local copy of the files, you can manually import them by following the steps on the Uploading objects page of the Amazon S3 documentation.

Your model file exceeds the 1 GB file size limit that the service can create, so your file was edited. This model will not be imported. To remove this message, select the model from the Model errors table, and choose Delete.

Your checkpoint file exceeds the 1 GB file size limit that the service can create, so your file was edited. This model will not be imported. To remove this message, select the model from the Model errors table, and choose Delete.

Your YAML file exceeds the 10 MB file size limit that the service can create, so your file was edited. This model will not be imported. To remove this message, select the model from the Model errors table, and choose Delete.

We can't validate your model because it's been edited. If you have a copy of the model, try to replace it in your AWS DeepRacer S3 bucket, then select the model from the Model errors table and choose Update. When the Model import page appears, choose Import.

We couldn’t copy the model because the permissions that were available with AWS DeepRacer when you trained it have been removed. To authorize AWS DeepRacer to recreate the required permissions, choose the model from the Model errors table and then choose Update. When the Model import page appears, choose Import. AWS DeepRacer will recreate the permissions, then copy the model.