aws / sagemaker-training-toolkit

Train machine learning models within a 🐳 Docker container using 🧠 Amazon SageMaker.
Apache License 2.0
491 stars 117 forks source link

Python 3.6 unsupported [bug/question] #161

Open adamwrobel-ext-gd opened 1 year ago

adamwrobel-ext-gd commented 1 year ago

There are a few usages of capture_output in subprocess in this repo, they are not runnable in Python 3.6. Is this Python version supported?

https://github.com/aws/sagemaker-training-toolkit/blob/3405eec750a8512fd65ac438a1e9783c129ffb84/src/sagemaker_training/environment.py#L371

My usage:

estimator = Estimator(image_uri=f"{account}.dkr.ecr.{region}.amazonaws.com/{repo}:{latest_image}",
                      role=role,
                      instance_count=1,
                      instance_type=instance_type,
                      output_path=output_path)

Image I built myself and put into ECR:

FROM amd64/python:3.6

RUN pip3 glove-python

COPY train.py /opt/ml/code/train.py

ENV SAGEMAKER_PROGRAM train.py

Error:

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|   timestamp   |                                                                                                                                                                                                                                                                                              message                                                                                                                                                                                                                                                                                              |
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1668507472157 | /usr/local/lib/python3.6/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.   from cryptography.hazmat.backends import default_backend                                                                                                                                                                                                                                                                           
| 1668507472157 | Reporting training FAILURE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
| 1668507472157 | Framework Error:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| 1668507472157 | Traceback (most recent call last):   
File "/usr/local/lib/python3.6/site-packages/sagemaker_training/trainer.py", line 69, in train     env = environment.Environment()   File "/usr/local/lib/python3.6/site-packages/sagemaker_training/environment.py", line 672, in __init__     self._is_smddpmprun_installed = validate_smddpmprun()   
File "/usr/local/lib/python3.6/site-packages/sagemaker_training/environment.py", line 373, in validate_smddpmprun     check=True,   
File "/usr/local/lib/python3.6/subprocess.py", line 423, in run     with Popen(*popenargs, **kwargs) as process: |
| 1668507472157 | TypeError: __init__() got an unexpected keyword argument 'capture_output'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| 1668507472157 | __init__() got an unexpected keyword argument 'capture_output'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| 1668507472158 | Encountered exit_code 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
adamwrobel-ext-gd commented 1 year ago

This can be worked around by using older version sagemaker-training==4.3.0

This means the Python 3.6 backwards incompatibility was introduced quite recently