Using custom Python versions with SageMaker
Currently (as of March 2020), SageMaker supports Python 3.6 kernels only, which means you can’t run any 3.7 or 3.8 code out of the box. Fortunately, there’s an easy (though not well documented) fix:
name="my-env" version="3.7" # Create a new conda environment for the given Python version conda create -y -n "$name" python="$version" # Activate the environment source /home/ec2-user/anaconda3/bin/activate "$name" # Create a Jupyter kernel for your new environment pip install ipykernel python -m ipykernel install --name "$name" --display-name "$name" --user # Deactivate the environment source /home/ec2-user/anaconda3/bin/deactivate
For maximum laziness, bundle this script into your
on-setup.sh lifecycle configuration script.