I'm running into a problem when I try to setup a virtual environment on Ubuntu, using "virtualenv --system-site-packages myenv", and trying to run my python script with slurm (srun/sbatch)
Although I have run my code without problem in the past, at this point i'm getting an "ModuleNotFoundError" when trying to run with my environment activated (source ./myenv/bin/activate)
I noticed that although I can run "python foo.py" normally with my current environment activated, "srun python foo.py" fails. In fact, by printint sys.version, I can see that the python version running with srun is different from the python command withour srun, which tells me that the environment is changed (and thus cannot find my packages). "srun python --version" also confirms this.
Has anyone had a similar problem?
Thanks
The python environment is set via environment variables and Slurm does not always carry your current environment into your job. You can specify it with the
--export
option, e.g. with--export=ALL
. This should be the default if nothing is specified, but your admins might have changed it via specific Slurm environment variables.Another way around this would be to load the virtual environment in your jobscripts, if you use sbatch.