Skip to content

Commit ce41ec8

Browse files
committed
Check for Python intitialization before GIL status
1 parent b56d2da commit ce41ec8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torch_xla/csrc/xla_graph_executor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ std::vector<at::Tensor> XLAGraphExecutor::GetTensorsFused(
642642
// completes. Release the GIL so other threads can proceed and unblock any
643643
// collective computations.
644644
PyThreadState* save = nullptr;
645-
if (PyGILState_Check()) {
645+
if (Py_IsInitialized() && PyGILState_Check()) {
646646
save = PyEval_SaveThread();
647647
}
648648
std::vector<xla::Literal> literals =

0 commit comments

Comments
 (0)