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

[Windows] Support CPU shared memory (Client/Frontend) #7048

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

fpetrini15
Copy link
Contributor

@fpetrini15 fpetrini15 commented Mar 27, 2024

Goal: Support CPU shared memory between the server and client for Windows

Sub-goals: Modify L0_shared_memory to run on bare-metal Windows using only Python.

Client changes: triton-inference-server/client#551

Some things to note:

  • When I can verify that the Linux tests pass using only the Python script, I will remove test.sh
  • L0_shared_memory uses a graphdef model by default. I swapped it with Python so that it would be supported on both Windows and Linux. I still need to go back and investigate how the model ends up in L0_shared_memory (not generated by script) and remove it.
  • Some of the default paths need to be modified to reflect the testing environment and will be modified pre-merge.

qa/L0_shared_memory/shared_memory_test.py Fixed Show fixed Hide fixed
qa/L0_shared_memory/shared_memory_test.py Fixed Show fixed Hide fixed
qa/L0_shared_memory/shared_memory_test.py Fixed Show fixed Hide fixed
qa/L0_shared_memory/shared_memory_test.py Fixed Show fixed Hide fixed
qa/L0_shared_memory/shared_memory_test.py Fixed Show fixed Hide fixed
qa/L0_shared_memory/shared_memory_test.py Fixed Show fixed Hide fixed
qa/L0_shared_memory/shared_memory_test.py Fixed Show fixed Hide fixed
qa/L0_shared_memory/shared_memory_test.py Fixed Show fixed Hide fixed
qa/L0_shared_memory/shared_memory_test.py Show resolved Hide resolved
qa/L0_shared_memory/shared_memory_test.py Show resolved Hide resolved
src/shared_memory_manager.cc Outdated Show resolved Hide resolved
src/shared_memory_manager.cc Outdated Show resolved Hide resolved
src/shared_memory_manager.cc Outdated Show resolved Hide resolved
src/shared_memory_manager.cc Outdated Show resolved Hide resolved
src/shared_memory_manager.h Outdated Show resolved Hide resolved
Copy link
Contributor

@nv-kmcgill53 nv-kmcgill53 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review is a bit ramble-y but it's very tricky as well. You've done a great job so far, I'm teasing out the nuances so you can provide a good template of how to program for multiple OSes in a sustainable way.

docs/protocol/extension_shared_memory.md Outdated Show resolved Hide resolved
qa/common/util.py Show resolved Hide resolved
src/shared_memory_manager.cc Show resolved Hide resolved
src/shared_memory_manager.h Outdated Show resolved Hide resolved
src/shared_memory_manager.cc Outdated Show resolved Hide resolved
src/shared_memory_manager.cc Outdated Show resolved Hide resolved
src/shared_memory_manager.h Outdated Show resolved Hide resolved
@fpetrini15 fpetrini15 requested a review from GuanLuo April 9, 2024 18:26
triton_client = httpclient.InferenceServerClient(_url, verbose=True)
# Custom setup method to allow passing of parameters
def _setUp(self, protocol, log_file_path):
self._tritonserver_ipaddr = os.environ.get("TRITONSERVER_IPADDR", "localhost")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be configurable in practice? Do we expect to use shared memory for anything other than a co-located server on localhost?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBD: Currently on the Windows testing side of things, it's passed in as a variable and is different from "localhost". Still trying to get a CI pipeline up to see the new behavior for this test in particular. Will remove if no issue.

self._build_model_repo()
self._build_server_args()
self._shared_memory_test_server_log = open(log_file_path, "w")
self._server_process = util.run_server(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does util.run_server interact with test.sh also starting server? Is there conflict or issue there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe they should overlap. For this test my ultimate goal is to remove test.sh entirely.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this also getting run in the linux case that runs test.sh? or is there changes on the gitlab-side to not run test.sh at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see your point. There are changes on the gitlab side such that test.sh will not run at all for Windows. I will attempt to change the Linux test case so that it also will not run test.sh

Comment on lines 95 to 97
backend_dir = "C:\\opt\\tritonserver\\backends"
model_dir = "C:\\opt\\tritonserver\\qa\\L0_shared_memory\\models"
self._server_executable = "C:\\opt\\tritonserver\\bin\\tritonserver.exe"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably more of a random note or follow-up, but I was under the impression something like Pathlib.Path("/opt/tritonserver/backends") would translate to "C:\\opt\\tritonserver\\backends" for free when run on Windows. If so you could probably condense the cases to work for both.

Did you see otherwise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I believe you are right. ATM they are set to my local path and were hardcoded for convenience. They need to be modified and will once I determine the CI environment.

# Constant members
shared_memory_test_client_log = Path(os.getcwd()) / "client.log"
model_dir_path = Path(os.getcwd()) / "models"
model_source_path = Path(os.getcwd()).parents[0] / "python_models/add_sub/model.py"
Copy link
Collaborator

@rmccorm4 rmccorm4 Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future follow-up as we expand python utilities for CI testing, but might be nice to have some kind of utils.relative_path([path, to, thing]).

ex maybe something like this:

model_dir_path = utils.relative_path("models")
model_source_path = utils.relative_path("..", "python_models", "add_sub", "model.py")

nv-kmcgill53
nv-kmcgill53 previously approved these changes Apr 11, 2024
Copy link
Contributor

@nv-kmcgill53 nv-kmcgill53 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Great work on this!

src/shared_memory_manager.h Show resolved Hide resolved
src/shared_memory_manager.cc Outdated Show resolved Hide resolved
Copy link
Contributor

@GuanLuo GuanLuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, can be addressed in the future PR that adds clean up logic

src/shared_memory_manager.cc Outdated Show resolved Hide resolved
src/shared_memory_manager.cc Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants