Skip to content

Commit

Permalink
low specs systems hack
Browse files Browse the repository at this point in the history
  • Loading branch information
JegernOUTT committed Jan 19, 2024
1 parent 41b884f commit 76f6dcf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions self_hosting_machinery/finetune/scripts/aux/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from typing import Any, Dict

import psutil
import torch
from torch.utils.data import DataLoader
from transformers import AutoTokenizer
Expand Down Expand Up @@ -86,6 +87,10 @@ def create_train_dataloader(
if dataset.files_len == 0:
raise RuntimeError("No train files provided")

mem = psutil.virtual_memory()
if mem.total // 2 ** 30 <= 16: # saving up a bunch of memory for low specs machines (<= 16Gb ram)
num_workers = 1

return DataLoader(
dataset,
batch_size=batch_size * world_size,
Expand Down

0 comments on commit 76f6dcf

Please sign in to comment.