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
已提问 1 个月前125 查看次数
2 回答
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
专家
已回答 1 个月前
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
支持工程师
已回答 1 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则