Python Workflows on HPC Systems

Dominik Strassel, Philipp Reusch, Janis Keuper

Abstract

Python has become the primary language for machine learning and data science, yet its design often conflicts with the multi-user, resource-constrained nature of High-Performance Computing (HPC) systems. This paper explores the systemic failures of standard resource controls when applied to Python workflows, specifically focusing on process management, memory limits, and threading behavior. Through empirical analysis of NumPy, TensorFlow, and PyTorch, we demonstrate how Python "escapes" allocated limits, leading to "renegade" processes and inefficient cluster utilization. We conclude that containerization offers the most robust solution for isolating and controlling Python-based workloads in shared HPC clusters.

Introduction

HPC systems rely on a "good citizenship" model where jobs adhere to allocated CPU, RAM, and GPU slices. Python, designed for flexibility rather than multi-user isolation, frequently bypasses these controls. This study addresses three critical issues: renegade processes, resource escaping, and environment management overhead.

The Problem of Renegade Processes

Python's extensive use of multiprocessing often creates complex process hierarchies. A significant issue arises when a parent process is terminated (e.g., by a batch system signal); child processes are frequently adopted by the init process (PPID=1) rather than being terminated. These "orphans" continue to consume resources, particularly GPU memory, outside the visibility of standard job schedulers.

Figure 2: Process hierarchy in Python workflows, illustrating the potential for orphaned child processes when a parent is terminated.

Resource Enforcement and the "Memory Tax"

Traditional resource limits like ulimit -m are largely ineffective in modern Linux kernels, leaving cgroups as the only reliable enforcement mechanism. Furthermore, Python's object-oriented nature imposes a significant "memory tax"—a 4-byte integer in C can require up to 32 bytes in Python. This overhead, combined with Python’s private heap management, makes accurate memory footprint prediction difficult for users.

Threading Behavior in Deep Learning Frameworks

We benchmarked the threading behavior of NumPy, TensorFlow, and PyTorch under various environment variable restrictions (e.g., OMP_NUM_THREADS). While NumPy generally respects these limits, deep learning frameworks often exhibit "thread resistance."

Figure 6: PyTorch thread count behavior, demonstrating that the framework maintains a constant thread count (9) regardless of the OMP_NUM_THREADS setting.

TensorFlow proved even more unpredictable, spawning up to 80 threads in unrestricted environments and often ignoring standard environment variables. This behavior can lead to severe CPU oversubscription on shared nodes. Empirical results showed that restricting TensorFlow to a single CPU core caused GPU utilization to drop to 63%, highlighting the CPU-based preprocessing bottleneck.

Conclusion

The friction between Python's design and HPC requirements necessitates a shift in management strategy. Relying on user "good citizenship" or outdated Linux utilities is insufficient. Containerization (e.g., Singularity) provides the required isolation and resource jailing to ensure that when a job terminates, its entire process tree and resource footprint are cleanly removed, preserving cluster stability.

Summary updated

Abstract

The recent successes and wide spread application of compute intensive machine learning and data analytics methods have been boosting the usage of the Python programming language on HPC systems. While Python provides many advantages for the users, it has not been designed with a focus on multi-user environments or parallel programming - making it quite challenging to maintain stable and secure Python workflows on a HPC system. In this paper, we analyze the key problems induced by the usage of Python on HPC clusters and sketch appropriate workarounds for efficiently maintaining multi-user Python software environments, securing and restricting resources of Python jobs and containing Python processes, while focusing on Deep Learning applications running on GPU clusters.
BibTeX
@inproceedings{strassel2020python,
  author = {Dominik Strassel and Philipp Reusch and Janis Keuper},
  title = {{Python Workflows on HPC Systems}},
  booktitle = {PyHPC@SC},
  year = {2020},
  doi = {10.1109/pyhpc51966.2020.00009},
}
Figure