benchmark
13714d3c - Replace hard-coded /tmp paths with tempfile.gettempdir() (#171446)

Commit
52 days ago
Replace hard-coded /tmp paths with tempfile.gettempdir() (#171446) Summary: Fixes #171385 Summary Replaced hardcoded `/tmp` paths with `tempfile.gettempdir()` in production code and key test files to allow users to configure temp directory location via environment variables (e.g., `TMPDIR`). Motivation Users need to specify custom temp directory locations when: - `/tmp` has limited storage or quota restrictions - Running on Windows (where `/tmp` doesn't exist) - Using containerized environments with custom temp directories Changes Modified 7 files to use `tempfile.gettempdir()`: - `torch/_inductor/debug.py` - Inductor saved args - `torch/_dynamo/convert_frame.py` - cProfile outputs - `torch/_inductor/compile_fx_ext.py` - Debug serialization files - `torch/distributed/elastic/agent/server/local_elastic_agent.py` - Watchdog timers - `torch/distributed/_symmetric_memory/_nvshmem_triton.py` - NVSHMEM PTX files - `benchmarks/dynamo/torchbench.py` - KALDI_ROOT env var - `test/test_cuda.py` - GDS filesystem tests Scope Note: This PR focuses on production code and critical test files (~7 files). The codebase has ~96 `/tmp` references across 53 files, but many are in: - Comments/docstrings (documentation examples) - Example scripts (functorch examples) - Less critical test files These were intentionally excluded to keep the PR focused and minimize risk of breaking existing workflows. Follow-up PRs can address remaining instances if needed. Backward Compatibility Fully backward compatible - when `TMPDIR` is not set, `tempfile.gettempdir()` defaults to `/tmp` on Unix/Linux systems, maintaining existing behavior. Testing - Verified with `git diff` that only intended changes were made - All modified paths now respect system temp directory configuration - Users can test with: `export TMPDIR=/custom/path` X-link: https://github.com/pytorch/pytorch/pull/171446 Approved by: https://github.com/malfet Reviewed By: atalman, clee2000 Differential Revision: D89903660 fbshipit-source-id: 4182cb5deffc81cadb8a13d2667bed3b2ecc83e0 Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>
Author
generatedunixname499836121
Committer
Parents
Loading