Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spawn method for multiprocessing #64

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions python/dolma/cli/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import multiprocessing
from argparse import ArgumentParser
from pathlib import Path
from typing import List, Optional
Expand Down Expand Up @@ -27,6 +28,14 @@


def main(argv: Optional[List[str]] = None):
try:
# attempting to set start method to spawn in case it is not set
multiprocessing.set_start_method("spawn")
except RuntimeError:
# method already set, check if it is set to spawn
if multiprocessing.get_start_method() != "spawn":
raise RuntimeError("Multiprocessing start method must be set to spawn")

parser = ArgumentParser(
prog="dolma",
usage="dolma [command] [options]",
Expand Down
3 changes: 3 additions & 0 deletions scripts/make_wikipedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,7 @@ def main():


if __name__ == "__main__":
# setting multiprocessing start method to spawn
multiprocessing.set_start_method("spawn")

main()
Loading