This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Solve 2 different problems simultaneously by run 2 different scripts or 2 processes?

+1 vote

Dear all,

I have 2 totally different Python scripts to solve 2 different problems. I like to run both simultaneously on the same computer over night so when I come back I will have both solutions available. Can I do that?

I could imagine two approaches:
1. Run 2 scripts in 2 different terminals
2a. Assign one specific MPI to each script
2b. Assign one specific MPI to each problem in one combined script

The issue with the 1st approach I guess is that instant-cache is shared globally. But I am not sure.
I do not know how to implement 2nd approach.

Thanks.

asked May 28, 2016 by lxd FEniCS Novice (290 points)
edited May 28, 2016 by lxd

1 Answer

+1 vote
 
Best answer

You can use Approach 1 without worrying about instant-cache.
Each weak form is compiled in a different folder using a unique folder and filename.

Just type:

nohup python script1.py >& script1.out &
nohup python script2.py >& script2.out &

nohup will keep your process running in the background even if you close the terminal.
>& will redirect both standard output and standard error to the file script.out.
*&
at the end will allow you to continue using the same terminal window while the process is running.

To check the progress of your script you can use

tail -f script1.out
answered May 30, 2016 by umberto FEniCS User (6,440 points)
selected May 30, 2016 by lxd

I tried running two different scripts with the same weak form (but different BCs and parameters) and got this error in 1 of 2 processes:
"In instant.build_module: Path '/home/npm/.instant/cache/dolfin_compile_code_32220f6fe933aebc34804feb5f7e2f10b2be842b' already exists, but module wasn't found in cache previously. Not overwriting, assuming this module is valid."
Is there a way to specifically assign storage folder or files for the weak form in each script? I think we can go around this overwriting issue by this way. Can we do that?

You can set INSTANT_CACHE_DIR and INSTANT_ERROR_DIR separately for each script, and you might also want to do the same with TMP.

Can you give an example on how the code would look like? I can set INSTANT_CACHE_DIR and INSTANT_ERROR_DIR but got "nohup: ignoring input" on one of two processes. Thank you.

Example:

export INSTANT_CACHE_DIR=$PWD/instant/script1/cache
export INSTANT_ERROR_DIR=$PWD/instant/script1/error
nohup python demo_poisson.py >& script1.out &
export INSTANT_CACHE_DIR=$PWD/instant/script2/cache
export INSTANT_ERROR_DIR=$PWD/instant/script2/error
nohup python demo_poisson.py >& script2.out &

In each script, I add these two lines:

INSTANT_CACHE_DIR= '~/.instant/script1/cache/'
INSTANT_ERROR_DIR= '~/.instant/script1/error/'

then run nohup as above and it worked.

Thank you so much!

...