Repository: pytorch
Issue: INTERNAL ASSERT FAILED at "../aten/src/ATen/MapAllocator.cpp":323, please report a bug to PyTorch. unable to mmap 68 bytes from file </torch_530808_7992>: Cannot allocate memory (12) ---------------------------------------------------------------------------
Labels: module: multiprocessing,module: cpu,triaged

## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->

Running into this issue when using PyTorch 1.10.0+cpu and multiprocessing. I can't share the source code, but it uses a multiprocessing pool to download ~60000 images from AWS and run some simple torch ops on them. The process reliably crashes at about 25% completion with this traceback:

```
---------------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/managers.py", line 243, in serve_client
    request = recv()
  File "/usr/lib/python3.8/multiprocessing/connection.py", line 251, in recv
    return _ForkingPickler.loads(buf.getbuffer())
  File "/home/ubuntu/venv/ml-datagen/lib/python3.8/site-packages/torch/multiprocessing/reductions.py", line 305, in rebuild_storage_filename
    storage = cls._new_shared_filename(manager, handle, size)
RuntimeError: falseINTERNAL ASSERT FAILED at "../aten/src/ATen/MapAllocator.cpp":323, please report a bug to PyTorch. unable to mmap 68 bytes from file </torch_530808_7992>: Cannot allocate memory (12)
---------------------------------------------------------------------------
``` 

In my last debug run, i used psutil to display RAM usage during the process to confirm that I wasn't just running out of memory, and indeed the crash happened at ~28% RAM utilization, up from ~23% RAM at the beginning of the process, so nothing abnormal there. I didn't log disk usage during the image download, but each image is <100kb, so the crash happens after well less than 2GB of images have been saved to disk, and there is plenty of free space remaining.

## To Reproduce

Steps to reproduce the behavior:

1. Unclear how to reproduce, given that I can't just share my code, but maybe try using a `multiprocessing.Pool` with `multiprocessing.cpu_count()` processes to  download 20000 460x460  images, run each of them through an object detection endpoint hosted on another system, multiply each resulting prediction's confidence score by the distance between the bbox center and image center, and saving the bbox with the highest resulting weighted confidence as a tuple in a `multiprocessing.Manager.list()` shared between the processes.

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

## Expected behavior
The process runs and doesn't crash.

## Environment

Running on an AWS EC2 c5.2xlarge instance.

Collecting environment information...
PyTorch version: 1.10.0+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.3 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.31

Python version: 3.8.10 (default, Sep 28 2021, 16:10:42)  [GCC 9.3.0] (64-bit runtime)
Python platform: Linux-5.11.0-1021-aws-x86_64-with-glibc2.29
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.3
[pip3] torch==1.10.0+cpu
[pip3] torchvision==0.11.1+cpu
[conda] Could not collect



cc @VitalyFedyunin