Sagemaker Code Editor - Run Python script while computer is off

0

Hello,

I am trying to train a model using a Python script inside of the Sagemaker Code Editor. The script is started from the terminal. When I shut the computer down, the script continues to run for a couple of minutes longer, than hangs itsself. When I log back in the Code Editor, the script continues to run from the point it stopped. How can I run python scripts in the background, so that I do not have to keep the computer on and still see the output in the terminal?`

Thanks!

RaduM
demandé il y a un mois126 vues
2 réponses
1

ℹ️ You can execute a Python script in the background using the nohup command, which ensures that the process continues to run even after you exit the shell or terminal. However, it's important to note that nohup does not keep the script running if the computer on which it is executed is turned off or shut down. For more details on using the nohup command, you can refer to this guide: Nohup Command in Linux.

Example:

nohup python your_script.py > output.log &
profile picture
EXPERT
répondu il y a un mois
0

Hello,

Please note that when we shut down, the terminal will not be able to record any output information. To continue to run the script and get the complete output even after you turn off your device, you can use "nohup" command.

nohup python script.py > output.log &

Please refer to https://paulorod7.com/running-a-python-script-in-terminal-without-losing-it-by-a-connection-drop for more details.

AWS
INGÉNIEUR EN ASSISTANCE TECHNIQUE
répondu il y a un mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions