shy-refrigerator-15055
03/09/2023, 2:30 PM@batch(memory=40000) , the step runs fine. With @batch(memory=10000, max_swap=40000, swappiness=50) , we get an out of memory error. Is there anything else that needs to be set up for Batch actually allocating swap or is there a cap on the amount of swap that can be used regardless of the MF decorator?fresh-laptop-72652
03/09/2023, 11:19 PMUser Data to run on startup, which is a single line to make a 5GB swapfile
#!/bin/bash
fallocate -l 5G /swapfile && chmod 0600 /swapfile && mkswap /swapfile && swapon /swapfile
Once you've updated the compute environment to use that revision of the launch template, you can confirm it's accessible from a example flow:
from metaflow import FlowSpec, batch, step
class SwapTest(FlowSpec):
@batch(cpu=2, memory=15000, max_swap=25000, swappiness=0)
@step
def start(self):
import psutil
print(psutil.swap_memory())
self.next(self.end)
@step
def end(self):
pass
if __name__ == "__main__":
SwapTest()
which shows the available swap memory in bytes
sswap(total=5368705024, used=1048576, free=5367656448, percent=0.0, sin=0, sout=90112)
all that said, I'd really caution against trying to lean on swap memory unless it's absolutely necessary and you're also using that launch template to attach a sufficiently configured EBS volume with high throughput / high IOPS provisioned! Using swap memory is not something to take lightly, and it's kinda silly to consider when talking about quite small datasets in the 10s of GBs versus just provisioning more memory.
hope that helps! 🙂shy-refrigerator-15055
03/10/2023, 12:37 PM