-
Notifications
You must be signed in to change notification settings - Fork 3
/
map_rank_to_gpu
executable file
·35 lines (34 loc) · 1.51 KB
/
map_rank_to_gpu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
#
# Copyright (C) 2002-2021 the Network-Based Computing Laboratory (NBCL), The
# Ohio State University.
#
# Contact: Dr. D. K. Panda ([email protected])
#
# For detailed copyright and licensing information, please refer to the
# copyright file COPYRIGHT in the top level directory.
#
# Name : map_rank_to_gpu
#
# Description : This script is used to set the affinity between an MPI process
# and the GPU on the system.
#
# The processes rank on a node is normally used to do this and
# different MPI launchers expose this information through
# different environment variables. For example, MVAPICH2 uses
# MV2_COMM_WORLD_LOCAL_RANK and OpenMPI uses
# OMPI_COMM_WORLD_LOCAL_RANK. For other MPI libraries, please set
# the LOCAL_RANK variable below to the appropriate one.
#
# Some python applications don't respect CUDA device mappings.
# It's much more convenient to force CUDA_VISIBLE_DEVICES here
# rather than setting it within python, because
# CUDA_VISIBLE_DEVICES must be set after MPI_Init but before the
# offending python package is imported.
#
# NOTE: Only use map_rank_to_gpu if process mapping is not
# respected. Forcing CUDA_VISIBLE_DEVICES will disable CUDA IPC,
# which may impact performance
export LOCAL_RANK=$MV2_COMM_WORLD_LOCAL_RANK
export CUDA_VISIBLE_DEVICES=$MV2_COMM_WORLD_LOCAL_RANK
exec $*