AWS DeepRacer: Failed to create model

If you are reading this post, most likely you are getting Failed to create model. Unable to create your model error when tried to create a model on DeepRacer console. I also had this issue and was able to figure out why DeepRacer was keep failing to create a model for me. Hopefully, by the end of reading this post, you would be able to find out why a model was not created at your end.

First, CloudWatch is your best friend, always reach out to it when help is needed!
There are 3 Log Groups in CloudWatch that you might be interested in, here are the steps to get there:

  1. After login to AWS Console, find CloudWatch from Services and land there by clicking CloudWatch
  2. Click Logs from the left
  3. You should have the following Log Groups in the list (in addition to other, based on what services you are using)
    • /aws/lambda/AWS-DeepRacer-Test-Reward-Function
    • /aws/sagemaker/TrainingJobs
    • /aws/robomaker/SimulationJobs

Before proceed further let me share my sample reward_function that was failing to create a model:

import sys


# Constants - Don't change them
MAX_REWARD = 1e+5 # 10000.0
NO_REWARD = 1e-5 # 0.00001

def log(message):
print(f'>>>> {message}')

def reward_function(params):

# Read input parameters
track_width = params['track_width']
distance_from_center = params['distance_from_center']

# Calculate 3 markers that are at varying distances away from the center line
marker_1 = 0.1 * track_width
marker_2 = 0.25 * track_width
marker_3 = 0.5 * track_width

# Give higher reward if the car is closer to center line and vice versa
if distance_from_center <= marker_1:
reward = 1.0
elif distance_from_center <= marker_2:
reward = 0.5
elif distance_from_center <= marker_3:
reward = 0.1
reward = NO_REWARD # likely crashed/ close to off track

return float(reward)

Now back to debugging. First Log Group I’m interested in is /aws/lambda/AWS-DeepRacer-Test-Reward-Function, and didn’t see any usual. Then I looked into /aws/sagemaker/TrainingJobs, nothing unsual there as well. Finally, I moved to /aws/robomaker/SimulationJobs, and found the following:

I was puzzled that -FunctionAWS-DeepRacer-Test-Reward didn’t complain about print(f'>>>> {message}), I was suspicious that python on robomaker/SimulationJobs dont’ have the same version as on AWS-DeepRacer-Test-Reward. I went ahead and removed f-string from my reward function. And what I saw in the log, confimed my suspicion. Take a look at the version out from sys.version_info dumped into the log of SimulationJobs

So, DeepRacer was not able to create a model for me as I was using f-string which was introcuded in python 3.6, whereas hosts on Robomaker that run SimulationJobs had python older than 3.6