如何在 MPI 作业中的计算节点上设置环境变量
How to set environment variables on compute nodes in an MPI job
当 运行 MPI 在调度程序下时,我不明白如何在计算节点上设置环境。
我愿意:
mpirun -np 1 --hostfile ./hostfile foo.sh
与 foo.sh
:
#!/usr/bin/env zsh
echo $LD_LIBRARY_PATH
然后我不恢复 LD_LIBRARY_PATH 我在交互式 shell... 与 MPI 连接时 executed/sourced 的初始化文件是什么?
注意:我在 zsh 下,我尝试将东西放在 .zprofile 或 .zshenv 而不是 .zshrc 中,但它似乎没有做出任何改变......我的 LD_LIBRARY_PATH 已设置在由 .zshrc 提供的 .bashrc 提供的 .profile 中。
一些 MPI 实现具有用于 mpirun 的 -x
标志,例如OpenMPI:
-x <env>
Export the specified environment variables to the remote nodes before executing the program. Only one environment variable can be specified per -x option. Existing environment variables can be specified or new variable names specified with corresponding values. For example:
% mpirun -x DISPLAY -x OFILE=/tmp/out ...
The parser for the -x option is not very sophisticated; it does not even understand quoted values. Users are advised to set variables in the environment, and then use -x to export (not define) them.
如果您的没有,则必须在作业脚本中明确设置环境变量,例如
export LD_LIBRARY_PATH=...
您也可以使用 end 和以下命令指定每个 mpi 的线程数。
env OMP_NUM_THREADS=n PARALLEL=n mpirun -np m program.exe < input.file > output.file &
其中 n 和 m 是线程数和 CPU 内核数。
示例:
env OMP_NUM_THREADS=2 PARALLEL=2 mpirun -np 12 program.exe < input.file > output.file &
当 运行 MPI 在调度程序下时,我不明白如何在计算节点上设置环境。
我愿意:
mpirun -np 1 --hostfile ./hostfile foo.sh
与 foo.sh
:
#!/usr/bin/env zsh
echo $LD_LIBRARY_PATH
然后我不恢复 LD_LIBRARY_PATH 我在交互式 shell... 与 MPI 连接时 executed/sourced 的初始化文件是什么?
注意:我在 zsh 下,我尝试将东西放在 .zprofile 或 .zshenv 而不是 .zshrc 中,但它似乎没有做出任何改变......我的 LD_LIBRARY_PATH 已设置在由 .zshrc 提供的 .bashrc 提供的 .profile 中。
一些 MPI 实现具有用于 mpirun 的 -x
标志,例如OpenMPI:
-x <env>
Export the specified environment variables to the remote nodes before executing the program. Only one environment variable can be specified per -x option. Existing environment variables can be specified or new variable names specified with corresponding values. For example:
% mpirun -x DISPLAY -x OFILE=/tmp/out ...
The parser for the -x option is not very sophisticated; it does not even understand quoted values. Users are advised to set variables in the environment, and then use -x to export (not define) them.
如果您的没有,则必须在作业脚本中明确设置环境变量,例如
export LD_LIBRARY_PATH=...
您也可以使用 end 和以下命令指定每个 mpi 的线程数。
env OMP_NUM_THREADS=n PARALLEL=n mpirun -np m program.exe < input.file > output.file &
其中 n 和 m 是线程数和 CPU 内核数。
示例:
env OMP_NUM_THREADS=2 PARALLEL=2 mpirun -np 12 program.exe < input.file > output.file &