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

Add debug mode support for python backend #324

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions src/pb_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,21 @@ Stub::StubSetup()
deserialize_bytes_ = python_backend_utils.attr("deserialize_bytes_tensor");
serialize_bytes_ = python_backend_utils.attr("serialize_byte_tensor");

// add a debug mode for triton python backend
py::module os = py::module_::import("os");
py::object env = os.attr("environ");
std::string triton_debug = py::str(env.attr("get")("TRITON_DEBUG", "0"));
if (triton_debug == "1") {
py::module debugpy = py::module_::import("debugpy");
std::string debug_port = py::str(env.attr("get")("TRITON_DEBUG_PORT", "8003"));
int triton_debug_port = std::stoi(debug_port);
LOG_INFO << "Running with debugpy mode on 0.0.0.0:" << triton_debug_port;
py::tuple listen_args(2);
listen_args[0] = "0.0.0.0";
listen_args[1] = triton_debug_port;
debugpy.attr("listen")(listen_args);
}

return sys;
}

Expand Down