Skip to content

Commit

Permalink
enable qsub use
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Simianer committed Jan 24, 2013
1 parent 8b399cb commit 0c02f35
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
7 changes: 7 additions & 0 deletions environment/LocalConfig.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ my $host = domainname;

# keys are: HOST_REGEXP, MERTMem, QSubQueue, QSubMemFlag, QSubExtraFlags
my $CCONFIG = {

'StarCluster' => {
'HOST_REGEXP' => qr/compute-\d+\.internal$/,
'JobControl' => 'qsub',
Expand Down Expand Up @@ -67,6 +68,12 @@ my $CCONFIG = {
'JobControl' => 'fork',
'DefaultJobs' => 12,
},
'cluster.cl.uni-heidelberg.de' => {
'HOST_REGEXP' => qr/node25/,
'JobControl' => 'qsub',
'QSubMemFlag' => '-l h_vmem=',
'DefaultJobs' => 13,
},
'LOCAL' => { # LOCAL must be last in the list!!!
'HOST_REGEXP' => qr//,
'QSubMemFlag' => ' ',
Expand Down
25 changes: 15 additions & 10 deletions training/dtrain/parallelize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

if ARGV.size != 7
STDERR.write "Usage: "
STDERR.write "ruby parallelize.rb <dtrain.ini> <epochs> <rand=true|false> <#shards|predef> <at once> <input> <refs>\n"
STDERR.write "ruby parallelize.rb <dtrain.ini> <epochs> <rand=true|false> <#shards|predef> <at once> <input> <refs> <qsub>\n"
exit
end

cdec_dir = '~/mt/cdec-dtrain/'
dtrain_bin = "~/bin/dtrain_local"
cdec_dir = '~/MAREC/cdec-dtrain/'
dtrain_bin = "~/MAREC/cdec-dtrain/training/dtrain/dtrain"
ruby = '/usr/bin/ruby'
lplp_rb = "#{cdec_dir}/training/dtrain/hstreaming/lplp.rb"
lplp_args = 'l2 select_k 100000'
cat = '/bin/cat'

ini = ARGV[0]
epochs = ARGV[1].to_i
Expand All @@ -27,6 +28,8 @@
shards_at_once = ARGV[4].to_i
input = ARGV[5]
refs = ARGV[6]
use_qsub = false
use_qsub = true if ARGV[7]

`mkdir work`

Expand Down Expand Up @@ -92,12 +95,16 @@ def make_shards(input, refs, num_shards, epoch, rand)
remaining_shards = num_shards
while remaining_shards > 0
shards_at_once.times {
qsub_str_start = qsub_str_end = ''
if use_qsub
qsub_str_start = "qsub -cwd -sync y -b y -j y -o work/out.#{shard}.#{epoch} -N dtrain.#{shard}.#{epoch} \""
qsub_str_end = "\""
end
pids << Kernel.fork {
`#{dtrain_bin} -c #{ini}\
`#{qsub_str_start}#{dtrain_bin} -c #{ini}\
--input #{input_files[shard]}\
--refs #{refs_files[shard]} #{input_weights}\
--output work/weights.#{shard}.#{epoch}\
&> work/out.#{shard}.#{epoch}`
--output work/weights.#{shard}.#{epoch}#{qsub_str_end}`
}
weights_files << "work/weights.#{shard}.#{epoch}"
shard += 1
Expand All @@ -106,10 +113,8 @@ def make_shards(input, refs, num_shards, epoch, rand)
pids.each { |pid| Process.wait(pid) }
pids.clear
end
cat = File.new('work/weights_cat', 'w+')
weights_files.each { |f| cat.write File.new(f, 'r').read }
cat.close
`#{ruby} #{lplp_rb} #{lplp_args} #{num_shards} < work/weights_cat &> work/weights.#{epoch}`
`#{cat} work/weights.*.#{epoch} > work/weights_cat`
`#{ruby} #{lplp_rb} #{lplp_args} #{num_shards} < work/weights_cat > work/weights.#{epoch}`
if rand and epoch+1!=epochs
input_files, refs_files = make_shards input, refs, num_shards, epoch+1, rand
end
Expand Down

0 comments on commit 0c02f35

Please sign in to comment.