server icon indicating copy to clipboard operation
server copied to clipboard

Python backend doesn't load model.py in the model directory properly when trailing slashes(/) present in --backend-directory option

Open twjang opened this issue 1 year ago • 1 comments

Description The Python backend does not properly load the model.py file in the model directory when trailing slashes (/) are present in the --backend-directory option.

Triton Information What version of Triton are you using? r23.12

Are you using the Triton container or did you build it yourself? container

To Reproduce Follow the instructions in https://github.com/triton-inference-server/python_backend?tab=readme-ov-file#quick-start

  1. Launch the Triton Docker image:
docker run --shm-size=1g --ulimit memlock=-1 -p 8000:8000 -p 8001:8001 -p 8002:8002 --ulimit stack=67108864 -ti nvcr.io/nvidia/tritonserver:23.12-py3

  1. Inside the docker container, clone python_backend repository and prepare the model repository directory:
git clone https://github.com/triton-inference-server/python_backend -b r23.12
cd python_backend
mkdir -p models/add_sub/1/
cp examples/add_sub/model.py models/add_sub/1/model.py
cp examples/add_sub/config.pbtxt models/add_sub/config.pbtxt
  1. Start Triton server with the following command:
tritonserver --model-repository `pwd`/models --backend-directory /opt/tritonserver/backends/ --log-verbose 1

According to the log, triton_python_backend_stub is launched with following arguments:

I1222 03:27:07.578630 363 stub_launcher.cc:253] Starting Python backend stub:  exec /opt/tritonserver/backends/python/triton_python_backend_stub /opt/tritonserver/python_backend/models/add_sub/1/model.py triton_python_backend_shm_region_1 1048576 1048576 363 /opt/tritonserver/backends/python 336 add_sub /opt/tritonserver/backends/python     

However, the last argument should be DEFAULT.

  1. Successfully run Triton server with the following command: Please be aware that the trailing / has been removed from the --backend-directory option.
tritonserver --model-repository `pwd`/models --backend-directory /opt/tritonserver/backends --log-verbose 1

Now, everything works fine.

I1222 03:29:44.179683 387 stub_launcher.cc:253] Starting Python backend stub:  exec /opt/tritonserver/backends/python/triton_python_backend_stub /opt/tritonserver/python_backend/models/add_sub/1/model.py triton_python_backend_shm_region_2 1048576 1048576 387 /opt/tritonserver/backends/python 336 add_sub_0_0 DEFAULT  

Expected behavior The presence of a trailing / in the --backend-directory option should not affect its behavior.

twjang avatar Dec 22 '23 03:12 twjang

Thanks for reporting this issue. I have filed a bug for this issue.

Tabrizian avatar Jan 10 '24 16:01 Tabrizian