Unverified Commit b66168da authored by Min Xu's avatar Min Xu Committed by GitHub
Browse files

[minor] not creating a temp file on import (#641)



* [minor] not creating a temp file on import

* address review

* Revert "address review"

This reverts commit f65eb9bc7f7ea8829b1ac0a369ef9a3e6b56420a.
Co-authored-by: default avatarMin Xu <min.xu@acm.org>
parent fee979d9
......@@ -81,7 +81,7 @@ if torch.cuda.is_available():
available_devices.append("cuda")
_, filename_mpi = tempfile.mkstemp()
filename_mpi: Optional[str] = None
class IdentityLayer(Base):
......@@ -118,7 +118,8 @@ def torch_version() -> Tuple[int, ...]:
return tuple(int(n) for n in numbering)
_smi_ver = None
# Global variable to cache the results from the first nvidia-smi execution.
_smi_ver: Optional[str] = None
def torch_cuda_version(compiled: bool = False) -> Tuple[int, ...]:
......@@ -303,7 +304,14 @@ def torch_spawn(world_sizes: Optional[List[int]] = None) -> Callable:
error_queue = multiprocessing.get_context("spawn").SimpleQueue()
if "OMPI_COMM_WORLD_RANK" in os.environ:
# TODO (Min): this global used to be assigned every time this file is imported.
# I changed it to be assigned on first use. Should be the same, but I am not
# sure this is used or is correct since different processes would have different
# file names to init_process_group below. By initing, here, we don't leave
# a temp file behind on importing time.
global filename_mpi
if filename_mpi is None:
filename_mpi = tempfile.mkstemp()[1]
os.environ["RANK"] = os.environ["OMPI_COMM_WORLD_RANK"]
os.environ["WORLD_SIZE"] = os.environ["OMPI_COMM_WORLD_SIZE"]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment