Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix measure.py and kill-mxnet.py scripts in tools (#5257)
Browse files Browse the repository at this point in the history
  • Loading branch information
wlike authored and piiswrong committed Mar 5, 2017
1 parent 187e605 commit 8f27d7f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion tools/bandwidth/measure.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os, sys
curr_path = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(curr_path, "../../python"))
sys.path.insert(0, os.path.join(curr_path, "../../example/image-classification/symbol"))
sys.path.insert(0, os.path.join(curr_path, "../../example/image-classification/symbols"))
import mxnet as mx
import logging
import argparse
Expand Down
47 changes: 24 additions & 23 deletions tools/kill-mxnet.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
#!/usr/bin/env python

import os, sys
import subprocess

if len(sys.argv) != 2:
print "usage: %s <hostfile>" % sys.argv[0]
if len(sys.argv) != 4:
print "usage: %s <hostfile> <user> <prog>" % sys.argv[0]
sys.exit(1)

host_file = sys.argv[1]
prog_name = "train_imagenet"
user = sys.argv[2]
prog_name = sys.argv[3]

# Get host IPs
with open(host_file, "r") as f:
hosts = f.read().splitlines()
ssh_cmd = (
"ssh "
"-o StrictHostKeyChecking=no "
"-o UserKnownHostsFile=/dev/null "
"-o LogLevel=quiet "
)
kill_cmd = (
" "
"ps aux |"
"grep -v grep |"
"grep 'python train_imagenet.py' |"
"awk '{print \$2}'|"
"xargs kill"
"ps aux | "
"grep -v grep | "
"grep '" + prog_name + "' | "
"awk '{if($1==\"" + user + "\")print $2;}' | "
"xargs kill -9"
)
print kill_cmd
for host in hosts:
cmd = ssh_cmd + host +" \""+ kill_cmd+"\""
print cmd
os.system(cmd)

print "Done killing"
# Kill program on remote machines
with open(host_file, "r") as f:
for host in f:
if ':' in host:
host = host[:host.index(':')]
print host
subprocess.Popen(["ssh", "%s" % host, kill_cmd],
shell=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
print "Done killing"

# Kill program on local machine
os.system(kill_cmd)

0 comments on commit 8f27d7f

Please sign in to comment.