ddps-lab / tfserving-inference

0 stars 2 forks source link

tf serving 코드 분석하기 #47

Open kh3654po opened 1 year ago

kh3654po commented 1 year ago

tf model server가 요청을 어떻게 처리하는지 파악하기위해 코드를 분석할 필요가 있다. 서버코드는 https://github.com/tensorflow/serving/tree/master/tensorflow_serving/model_servers 여기에 있고 관련된 추가 코드는 https://github.com/tensorflow/tensorflow 여기에 있다.

kh3654po commented 1 year ago
kh3654po commented 1 year ago
kmu-leeky commented 1 year ago

요즘 소프트웨어들은 코드 구성 자체도 그렇게 간단하지가 않구나. 코드를 분석할때는 같이 실행을 해보면서 보면 코드의 실행 시퀀스를 따라가기가 쉬운 경우가 많아.

image

예를 들어 석현이가 전에 캡쳐한 이미지를 보면 model_servers/http_server.cc 라는 코드에서 요청을 받는듯 한데. 해당 코드 부터 따라가보면서 만약에 필요하다면 디버그 메시지를 추가하고 새롭게 빌드해서 실행해보는 방법도 있을것 같아. 시간이 걸리는 작업이지만 하나씩 해보자.

kh3654po commented 1 year ago

교수님 말씀처럼 http_server.cc로 부터 시작하여 파악을 해나가니 좀더 쉬운거 같습니다. 정리중에 있는데 어느정도 정리되면 공유드리겠습니다.

kh3654po commented 1 year ago
kmu-leeky commented 1 year ago

석현아. 잘 하고 있다. 해당 코드를 석현이가 새롭게 빌드 할 수 있다면 디버그 메시지를 추가해서 실행해보면 디버깅이 더 쉬워질것 같아. 예를 들어, 처음에 예로 든 ProcessRequest 함수에서 ServerRequestInterface 를 입력인자로 받는데, 우리가 요청을 보내는 순서대로 실제로 요청이 도착하려는지 보려고 한다면, 요청을 보낼때 쿼리 옵션으로 인덱스 번호 (1 부터 순차적으로 증가) 를 보내주고, 그걸 ProcessRequest 함수에서 차례대로 출력해보면 해당 인덱스대로 ProcessRequest 가 실행되는지는 확인할수 있을것 같아. 이런식으로 해서 문제가 발생하는 곳을 추적해 나가는것이 중요할것 같아. 다른 방법도 많이 있을수 있으니 많이 시도해보자.

kh3654po commented 1 year ago
kh3654po commented 1 year ago
kmu-leeky commented 1 year ago

코드의 시퀀스는 어느정도 파악이 되는듯 하다. 기존에 사용하던 컨테이너 이미지라면 수정이 쉽지 않을수도 있을텐데, 해당 이미지 "helmuthva/jetson-xavier-tensorflow-serving-base" 의 Dockerfile 을 받아와서 로컬에서 직접 빌드 후 사용하는게 나을것 같아. 결국 Dockerfile 에 모든 종속적인 것들이 정의되어 있을거야.

kh3654po commented 1 year ago
kh3654po commented 1 year ago
kh3654po commented 1 year ago

분석을 어느정도 완료하여 이제 tfserving 코드를 수정하고 이미지로 빌드하여 테스트 해보겠습니다.

kh3654po commented 1 year ago
kh3654po commented 1 year ago

기존에 있던 에러는 bazel 버전의 문제로 버전을 최신으로 수정 후 제거되었습니다. 비슷한 문제로 보이는 에러가 발생하여 원인파악중에 있습니다.

kh3654po commented 1 year ago
  1. 두번째 에러

    ERROR: Error in repository_rule: in call to repository_rule(), parameter 'remotable' is experimental and thus unavailable with the current flags.
    remote_python_configure = repository_rule(
        implementation = _create_local_python_repository,
        environ = _ENVIRONS,
        remotable = True,
        attrs = {
            "environ": attr.string_dict(),
            "platform_constraint": attr.string(),
        },
    )
    • 하지만 remotable 파라미터를 사용하고 있음
    • 해결 방법 : bazel build 할 때 “--experimental_repo_remote_exec” 옵션 추가
  2. 세번째 에러

    ERROR: An error occurred during the fetch of repository 'local_config_tensorrt':
       Traceback (most recent call last):
            File "/root/.cache/bazel/_bazel_root/e53bbb0b0da4e26d24b415310219b953/external/org_tensorflow/third_party/tensorrt/tensorrt_configure.bzl", line 287, column 38, in _tensorrt_configure_impl
                    _create_local_tensorrt_repository(repository_ctx)
            File "/root/.cache/bazel/_bazel_root/e53bbb0b0da4e26d24b415310219b953/external/org_tensorflow/third_party/tensorrt/tensorrt_configure.bzl", line 146, column 30, in _create_local_tensorrt_repository
                    config = find_cuda_config(repository_ctx, find_cuda_config_path, ["cuda", "tensorrt"])
            File "/root/.cache/bazel/_bazel_root/e53bbb0b0da4e26d24b415310219b953/external/org_tensorflow/third_party/gpus/cuda_configure.bzl", line 672, column 41, in find_cuda_config
                    exec_result = _exec_find_cuda_config(repository_ctx, script_path, cuda_libraries)
            File "/root/.cache/bazel/_bazel_root/e53bbb0b0da4e26d24b415310219b953/external/org_tensorflow/third_party/gpus/cuda_configure.bzl", line 666, column 19, in _exec_find_cuda_config
                    return execute(repository_ctx, [python_bin, "-c", decompress_and_execute_cmd])
            File "/root/.cache/bazel/_bazel_root/e53bbb0b0da4e26d24b415310219b953/external/org_tensorflow/third_party/remote_config/common.bzl", line 230, column 13, in execute
                    fail(
    Error in fail: Repository command failed
    Could not find any NvInferVersion.h matching version '8.2.1' in any subdirectory:
            ''
            'include'
            'include/cuda'
            'include/*-linux-gnu'
            'extras/CUPTI/include'
            'include/cuda/CUPTI'
            'local/cuda/extras/CUPTI/include'
    of:
            '/lib'
            '/lib/aarch64-linux-gnu'
            '/usr'
            '/usr/lib/aarch64-linux-gnu'
            '/usr/lib/aarch64-linux-gnu/libfakeroot'
            '/usr/local/cuda'
            '/usr/local/cuda-10.0/targets/aarch64-linux/lib'
    • 에러 원인 : NvInferVersion.h 부재로 인한 에러, NvInferVersion.h 관련한 업데이트는 2021년도로 19년도 tf serving 코드를 빌드하는 도커파일로는 최신 버전의 tf serving 코드 빌드가 어려움
kh3654po commented 1 year ago

19년도 tf serving 코드를 빌드하는 Dockerfile로는 최신 버전의 tf serving 코드를 빌드하는 것은 어려울 것 같습니다. 아까 미팅에서 말씀하신대로 최신 버전의 코드를 빌드하는 쪽으로 진행하겠습니다.