File size: 361 Bytes
af6e330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import torch

def cleanup_shared_memory():
    import os
    import glob

    shm_files = glob.glob('/dev/shm/torch_*')
    for shm_file in shm_files:
        try:
            os.remove(shm_file)
        except OSError as e:
            print(f"Error removing shared memory file {shm_file}: {e}")

# 在主程序开始或结束时调用
cleanup_shared_memory()