-
-
Save martindurant/5f517ec55a5bff9c32637e8ebc57ef7c to your computer and use it in GitHub Desktop.
Strange,
I create a 4gb array copying your code and get the following:
distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
distributed.nanny - WARNING - Restarting worker
distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
distributed.nanny - WARNING - Restarting worker
distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
distributed.nanny - WARNING - Restarting worker
distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
distributed.nanny - WARNING - Restarting worker
distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
distributed.nanny - WARNING - Restarting worker
distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
distributed.nanny - WARNING - Restarting worker
distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
distributed.nanny - WARNING - Restarting worker
distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
I'm using WSL2 on Win10, could that be the issue? The Ubuntu instance tells me it's using 4gb, but task manager on windows tells me the linux instance is using 8gb (I have 16gb)
import dask.distributed
from dask.distributed import Client
import numpy
import time
x = np.random.random(size=[2_000_000, 200])
x2 = SharedWrappedArray(x)
# x3 = SharedMMapArray(x)
client = Client(processes=True, threads_per_worker=2,
n_workers=4)
models = []
for i in range(8):
models.append(client.submit(lambda x: x.sum(), x2))
client.gather(models)
How much memory should this consume? The array is around 4gb, if it wasn't duplicated my workers wouldn't crash right.
If Dask is asking the workers for the number of bytes contained in a variable, like sys.getsizeof, then the array will appear to contribute to the memory footprint of each process, even if it isn't actually duplicated. I'm not sure how psutil's memory_info, which is what the nanny watches, handles this. I'm not certain how to tell the difference. Since this would be a new way to do things, it's worth finding out. Something similar must happen when multiple dask processes use one GPU.
I see what you're saying. That could be happening. Are you able to reproduce the out of memory errors with code similar to mine?
I haven't yet tried, sorry
No, you should get a pointer to the same OS-cached block in memory.