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

Switch threading model to fork on macOS #8347

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 16 additions & 0 deletions python/tvm/driver/tvmc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

from tvm.driver.tvmc.common import TVMCException

import multiprocessing as mp
from sys import platform
import os

REGISTERED_PARSER = []

Expand Down Expand Up @@ -91,6 +94,19 @@ def _main(argv):


def main():
if platform == "darwin":
# This fixes a crash on macOS. Note, that for tvmc to run
# safely on macOS the user needs to set the environment variable
# OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES _before_ the process
# is run. See this analysis for more information:
# https://wefearchange.org/2018/11/forkmacos.rst.html
mp.set_start_method("fork", force=True)
if os.environ.get("OBJC_DISABLE_INITIALIZE_FORK_SAFETY") != "YES":
sys.stderr.write("We suggest you set the environment variable\n"
"OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES\n"
"when running tvmc on macOS. More details here: "
"https://wefearchange.org/2018/11/forkmacos.rst.html")

sys.exit(_main(sys.argv[1:]))


Expand Down