无法从 Slurm 调用 Keras
Cannot call Keras from Slurm
我想在使用 Slurm 作为作业引擎的集群上使用 Keras。
如果我打开终端并运行以下命令,一切正常:
$python
>>> import tensorflow
>>> import keras
但是,如果我将 import tensorflow
和 import keras
放在一个 Python 文件中,然后我从 slurm 调用该文件:
srun [bunch of parameters for my cluster] python mypythonfile.py
然后我得到以下错误:ImportError: No module named keras
。
在带有 Slurm 的集群中使用 Keras 时有什么具体要做的吗?
我重申我的评论只是为了表明这个问题已经得到回答:
module load xxxx
很常见,其中 xxxx
是不同于默认的 Python 安装。您通常将其粘贴在 .bash_profile
或类似文件中,以确保您拥有所需的 Python 版本,并且始终可用。
当您使用 Slurm 提交工作时,它不会调用您的 .bash_profile
。它只是执行脚本。您需要确保加载 Python 发行版是该脚本的一部分。
我也遇到了这个问题,最近解决了。正如上面的回答提到的,slurm 命令不会执行.bash_profile 并且您可以在python 中直接导入kears 的原因是.bash_profile 中的环境设置语句。结果,我将 export PATH="/n/home01/username/miniconda3/bin:$PATH" 添加到我的 sbatch 文件中,然后一切正常。
我想在使用 Slurm 作为作业引擎的集群上使用 Keras。
如果我打开终端并运行以下命令,一切正常:
$python
>>> import tensorflow
>>> import keras
但是,如果我将 import tensorflow
和 import keras
放在一个 Python 文件中,然后我从 slurm 调用该文件:
srun [bunch of parameters for my cluster] python mypythonfile.py
然后我得到以下错误:ImportError: No module named keras
。
在带有 Slurm 的集群中使用 Keras 时有什么具体要做的吗?
我重申我的评论只是为了表明这个问题已经得到回答:
module load xxxx
很常见,其中 xxxx
是不同于默认的 Python 安装。您通常将其粘贴在 .bash_profile
或类似文件中,以确保您拥有所需的 Python 版本,并且始终可用。
当您使用 Slurm 提交工作时,它不会调用您的 .bash_profile
。它只是执行脚本。您需要确保加载 Python 发行版是该脚本的一部分。
我也遇到了这个问题,最近解决了。正如上面的回答提到的,slurm 命令不会执行.bash_profile 并且您可以在python 中直接导入kears 的原因是.bash_profile 中的环境设置语句。结果,我将 export PATH="/n/home01/username/miniconda3/bin:$PATH" 添加到我的 sbatch 文件中,然后一切正常。