forked from matterport/Mask_RCNN
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
79 lines (64 loc) · 3.01 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Settings
PATH_SSH_KEY=~/.ssh/id_rsa
REMOTE_DIR=~/work
LOCAL_DIR=.
PATH_VM_ID=./terraform/.vm-id
PATH_VM_IP=./terraform/.vm-ip
PATH_VM_ID_GPU=./terraform/.vm-id-gpu
PATH_VM_IP_GPU=./terraform/.vm-ip-gpu
PATH_VM_ID_MGPU=./terraform/.vm-id-mgpu
PATH_VM_IP_MGPU=./terraform/.vm-ip-mgpu
##### You should not have to touch stuff below this line
VM_ID=$(shell cat ${PATH_VM_ID}) # Azure resource ID
VM_CONN=$(shell cat ${PATH_VM_IP}) # user@IP
mkfile_path=$(abspath $(lastword $(MAKEFILE_LIST)))
CURRENT_DIR=$(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
# sync code disabled strict key checking for syncup for terraform build
syncup:
rsync -e "ssh -i ${PATH_SSH_KEY} -o StrictHostKeyChecking=no" -avz --exclude=".git/" --exclude-from=.gitignore ${LOCAL_DIR} $(shell echo ${VM_CONN}:${REMOTE_DIR}/${CURRENT_DIR} | tr -d '[:space:]')
syncdown:
rsync -e "ssh -i ${PATH_SSH_KEY}" -avz --exclude=".git/" --exclude-from=.gitignore $(shell echo ${VM_CONN}:${REMOTE_DIR}/${CURRENT_DIR}/ | tr -d '[:space:]') ${LOCAL_DIR}
# start/stop instance
stop:
az vm deallocate --ids ${VM_ID}
start:
az vm start --ids ${VM_ID}
status:
az vm show -d --ids ${VM_ID} | grep "powerState" | cut -d\" -f4
# ssh into machine and forward jupyter port
ssh:
ssh -i ${PATH_SSH_KEY} -L 8888:localhost:8888 ${VM_CONN}
VM_ID_GPU=$(shell cat ${PATH_VM_ID_GPU}) # Azure resource ID
VM_CONN_GPU=$(shell cat ${PATH_VM_IP_GPU}) # user@IP
# gpu commands
syncup-gpu:
rsync -e "ssh -i ${PATH_SSH_KEY} -o StrictHostKeyChecking=no" -avz --exclude=".git/" --exclude-from=.gitignore ${LOCAL_DIR} $(shell echo ${VM_CONN_GPU}:${REMOTE_DIR}/${CURRENT_DIR} | tr -d '[:space:]')
syncdown-gpu:
rsync -e "ssh -i ${PATH_SSH_KEY}" -avz --exclude=".git/" --exclude-from=.gitignore $(shell echo ${VM_CONN_GPU}:${REMOTE_DIR}/${CURRENT_DIR}/ | tr -d '[:space:]') ${LOCAL_DIR}
# start/stop instance
stop-gpu:
az vm deallocate --ids ${VM_ID_GPU}
start-gpu:
az vm start --ids ${VM_ID_GPU}
status-gpu:
az vm show -d --ids ${VM_ID_GPU} | grep "powerState" | cut -d\" -f4
# ssh into machine and forward jupyter port
ssh-gpu:
ssh -i ${PATH_SSH_KEY} -L 8888:localhost:8888 -L 6006:localhost:6006 -L 8787:localhost:8787 ${VM_CONN_GPU}
VM_ID_MGPU=$(shell cat ${PATH_VM_ID_MGPU}) # Azure resource ID
VM_CONN_MGPU=$(shell cat ${PATH_VM_IP_MGPU}) # user@IP
# gpu commands
syncup-mgpu:
rsync -e "ssh -i ${PATH_SSH_KEY} -o StrictHostKeyChecking=no" -avz --exclude=".git/" --exclude-from=.gitignore ${LOCAL_DIR} $(shell echo ${VM_CONN_MGPU}:${REMOTE_DIR}/${CURRENT_DIR} | tr -d '[:space:]')
syncdown-mgpu:
rsync -e "ssh -i ${PATH_SSH_KEY}" -avz --exclude=".git/" --exclude-from=.gitignore $(shell echo ${VM_CONN_MGPU}:${REMOTE_DIR}/${CURRENT_DIR}/ | tr -d '[:space:]') ${LOCAL_DIR}
# start/stop instance
stop-mgpu:
az vm deallocate --ids ${VM_ID_MGPU}
start-mgpu:
az vm start --ids ${VM_ID_MGPU}
status-mgpu:
az vm show -d --ids ${VM_ID_MGPU} | grep "powerState" | cut -d\" -f4
# ssh into machine and forward jupyter port
ssh-mgpu:
ssh -i ${PATH_SSH_KEY} -L 8888:localhost:8888 -L 8881:localhost:8881 ${VM_CONN_MGPU}