pm2 활용, VM환경에서 tensorflow 학습 자동화하기

송지혁
2 min readAug 25, 2019

--

VM을 돌리다보면 16시간에서는 길때는 70시간까지 돌려야하는 상황이 온다. 이럴 때 인터넷이 끊기거나 컴퓨터가 한번이라도 에러를 일으키면 train이 멈추어버리고 만다.

해결책을 강구하던중 nodejs에서는 pm2를 이용해서 서버를 켜놓았는데 이를 VM에서도 활용하면 어떨까 해서 적용해보았다.

  1. VM 에 node js 설치하기

(1)일단 nvm을 설치한다.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.3/install.sh | bash

(2)설치 재인식 진행

source ~/.bashrc

or

ssh 재접속

(3)node 설치

nvm install node

node -v, npm -v 으로 버전 확인 및 설치 확인

2. VM에 pm2 설치

(1) npm install pm2 -g

(2) pm2 -v 으로 버전 확인 및 설치 확인

(3) pm2 start (실행할 파일) — interpreter=python3

ex) pm2 start train.py — interpreter=python3

여기에서 interpreter 는 구동하는 환경에 따라 설정한다.

log를 확인하고 싶다면 pm2 log train 를 활용하면 된다.

작동을 멈추고 싶다면 pm2 stop train 를 활용하면 된다.

(참고 : ssh 를 껐다가 다시 키는 경우 pm2를 다시 설치해야하는 경우가 있다. 하지만 pm2 는 돌아가고 있음. 원인 불명…)

reference :

nodejs : https://junistory.blogspot.com/2017/08/nodejs.html

pm2 : https://stackoverflow.com/questions/32127834/how-to-run-a-python-script-like-pm2-for-nodejs

--

--

No responses yet