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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南