본문 바로가기
Engineering/토치서브(Torchserve)

[Torchserve] torchserve API PORT change

by Hyen4110 2022. 8. 30.
반응형

torchserve에는 custom API 개발을 위해 

기본적으로 설정되어있는 PORT가 있지만,

사정상 해당 포트(8080, 8081)를 쓸 수 없는 경우

매핑된 PORT를 변경하는 방법을 공유하고자 한다.

 


torchserve는 기본적으로 inference API는 8080,

model관련된 API(management) 8081 포트를 쓰도록 디폴트 설정이 되어있다

아래는 따로 설정하지 않아도 자동으로 생성되는 config파일 (config.properties)이다.

 

inference_address=http://0.0.0.0:8080
management_address=http://0.0.0.0:8081

 

하지만, 같은 서버에서 8080, 8081 포트를 사용할수 없는 경우가 생기는데,

이때 PORT를 변경하는 방법은, 

torchserve를 start할 때, 직접 만든 config 파일을 참조하도록 하는 것이다. 

 

아래 명령어를 통해 가능하다

기본 start 명령어에서 

--ts-config argument 값으로 직접 생성한 (file name)configtest.properties를 지정하였다.

 

torchserve --start --model-store model_store --models test.mar --ts-config configtest.properties

torchserve --start --model-store [ my mar file directory] --models [my mar file name] --ts-config [myconfig file name]

 

log를 보니, 정상적으로 API가 변경된것 확인

 


PORT는 정상적으로 변경되었으나,

여전히 java.io.IOException: Failed to bind 에러가 발생했다. 

문제는 huggingface에서 제공하는 SentenceTransformer로 

모델 클래스를 생성하는 과정에서 발생하는 오류로 확인되었다.

기본 API PORT (inference, management, metric) 충돌 외에

어떠한 이유로 오류가 발생하는 걸까?

반응형

댓글