[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [HTCondor-users] Parallel Matlab in HTCondor



I have a bit different problem. I have file program.condor containing:

Executable = run_matlab.sh
Universe = vanilla
Getenv = true
Log = mat.log
Output = mat.out
Error = mat.err
# main matlab file to execute
Input = script_test.m
# Number of CPUs request
# Request_cpus = 2
Queue

When Request_cpus is not used, the matlab calculations are performed. When Request_cpus is used, the calculations never start.

run_matlab.sh contains:
#!/bin/bash
matlab -nosplash -nodisplay -nodesktop -nojvm -r "script_test,exit"


script_test.m contains:
function test_script
c = 0;
tic
for a = 1:100000
    for b = 1:100000
        if a == b
            c = c + 1;
        end
    end
end
t = toc;
disp(c)
disp(t)
save('vysledek.mat','c','t')

I understand that I have to add in run_matlab.sh file the parameter maxNumCompThreads, but I think there is some different problem now. And please forget, that for-for cycle can use just only one thread. It is just only testing script.

Kind regards,
Rene

Dne 12.12.2014 v 22:28 Louis Marascio napsal(a):
On Fri, Dec 12, 2014 at 5:52 AM, Werner Hack <werner.hack@xxxxxxxxxx> wrote:

But what can I do, if I want to use more cores/threads (request_cpus >1) in matlab?
Can HTCondor provide any info to the matlab job (environment variable? )
about the assigned request_cpus?
If I check all environment variables in a job I can not see such info.
Werner,

The job should have a RequestCpus classad that you can query to set
the appropriate matlab variable. The _CONDOR_JOB_AD environment
variable can be used as an easy way to get to the job ad file at the
start of the job. From that file you can get the RequestCpus value. If
you know the cluster you can also query it with condor_q, of course.

For example, if I submit the following:

     cmd = test.sh
     output = out.txt
     request_cpus = 2
     queue

and my executable file test.sh is:

     #!/usr/bin/env bash

     echo $_CONDOR_JOB_AD
     cpus=$(grep ^RequestCpus $_CONDOR_JOB_AD | tr -d ' ' | cut -d= -f2)
     echo "I have $cpus CPUs"
     sleep 1d

I get the number of cpus printed to my output file.

So, instead of sleeping you can invoke matlab and tell it the cpu
count that you requested with request_cpus in your submit file.

Hope that helps,

Louis

---
Louis R. Marascio
512-964-4569
_______________________________________________
HTCondor-users mailing list
To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users

The archives can be found at:
https://lists.cs.wisc.edu/archive/htcondor-users/