I want to use Keras on a cluster using Slurm as the job engine.
If I open a terminal and run the following commands, everything works fine:
$python
>>> import tensorflow
>>> import keras
However, if I place import tensorflow
and import keras
in a Python file that I then call from slurm :
srun [bunch of parameters for my cluster] python mypythonfile.py
Then I get the following error: ImportError: No module named keras
.
Is there something specific to do when using Keras in a cluster with Slurm?
I'm reiterating my comment just to show that this question has been answered:
It's common to
module load xxxx
wherexxxx
is a different Python installation than the default. You usually stick this in your.bash_profile
or a similar file to make sure that you have the Python version you want, always available.When you submit a job with Slurm, it doesn't call your
.bash_profile
. It just executes the script. You need to make sure that loading your Python distribution is part of that script.