Skip to content

Commit

Permalink
Quit and clean when TVM is interrupted (apache#3640)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostplant authored and wweic committed Aug 9, 2019
1 parent edcea22 commit f4733e4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions python/tvm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"""TVM: Low level DSL/IR stack for tensor computation."""
from __future__ import absolute_import as _abs

import multiprocessing
import sys
import traceback

from . import _pyversion

from . import tensor
Expand Down Expand Up @@ -59,3 +63,13 @@

# Contrib initializers
from .contrib import rocm as _rocm, nvcc as _nvcc, sdaccel as _sdaccel

# Clean subprocesses when TVM is interrupted
def tvm_excepthook(exctype, value, trbk):
print('\n'.join(traceback.format_exception(exctype, value, trbk)))
if hasattr(multiprocessing, 'active_children'):
# pylint: disable=not-callable
for p in multiprocessing.active_children():
p.terminate()

sys.excepthook = tvm_excepthook

0 comments on commit f4733e4

Please sign in to comment.