경고: 이 API는 더 이상 사용되지 않으며 교체가 안정되면 TensorFlow의 향후 버전에서 제거될 예정입니다.
Server
bookmark_borderbookmark
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
분산 교육에 사용하기 위한 in-process TensorFlow 서버입니다.
Server
인스턴스는 분산 훈련에 참여할 수 있는 장치 세트와 Session
대상을 캡슐화합니다. 서버는 ClusterSpec
으로 지정되는 클러스터에 속하며 명명된 작업의 특정 작업에 해당합니다. 서버는 동일한 클러스터에 있는 다른 서버와 통신할 수 있습니다. 서버는 start()
가 호출될 때까지 어떤 요청도 처리하지 않습니다. stop()
또는 close()
호출되면 서버는 요청 처리를 중지합니다. close()
메서드가 실행 중인 경우 서버를 중지한다는 점에 유의하세요.
경고: Server
close()
호출하여 명시적으로 해제 해야 하는 리소스를 소유하고 있습니다.
Server
인스턴스는 스레드로부터 안전합니다.
사용 예:
import org.tensorflow.Server;
import org.tensorflow.distruntime.ClusterDef;
import org.tensorflow.distruntime.JobDef;
import org.tensorflow.distruntime.ServerDef;
ClusterDef clusterDef = ClusterDef.newBuilder()
.addJob(JobDef.newBuilder()
.setName("worker")
.putTasks(0, "localhost:4321")
.build()
).build();
ServerDef serverDef = ServerDef.newBuilder()
.setCluster(clusterDef)
.setJobName("worker")
.setTaskIndex(0)
.setProtocol("grpc")
.build();
try (Server srv = new Server(serverDef.toByteArray())) {
srv.start();
srv.join();
}
공공 생성자
| 서버 (바이트[] serverDef) 서버의 새 인스턴스를 구성합니다. |
공개 방법
동기화된 무효 | 닫다 () 진행 중인 TensorFlow 서버를 파괴하고 메모리를 확보합니다. |
무효의 | 가입하다 () 서버가 성공적으로 중지될 때까지 차단합니다. |
동기화된 무효 | 시작 () 진행 중인 TensorFlow 서버를 시작합니다. |
동기화된 무효 | 멈추다 () 진행 중인 TensorFlow 서버를 중지합니다. |
공개 방법
공개 동기화 무효 닫기 ()
진행 중인 TensorFlow 서버를 삭제하고 메모리를 확보합니다.
공개 동기화 무효 시작 ()
진행 중인 TensorFlow 서버를 시작합니다.
공개 동기화 무효 중지 ()
진행 중인 TensorFlow 서버를 중지합니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-26(UTC)"],[],[],null,["# Server\n\npublic final class **Server** \nAn in-process TensorFlow server, for use in distributed training.\n\nA `Server` instance encapsulates a set of devices and a [Session](/api_docs/java/org/tensorflow/Session)\ntarget that can participate in distributed training. A server belongs to a cluster (specified by\na `ClusterSpec`), and corresponds to a particular task in a named job. The server can\ncommunicate with any other server in the same cluster. The server will not serve any requests\nuntil [start()](/api_docs/java/org/tensorflow/Server#start()) is invoked. The server will stop serving requests once [stop()](/api_docs/java/org/tensorflow/Server#stop()) or\n[close()](/api_docs/java/org/tensorflow/Server#close()) is invoked. Be aware that [close()](/api_docs/java/org/tensorflow/Server#close()) method stops the server if it is\nrunning.\n\n**WARNING:** A `Server` owns resources that **must** be explicitly freed by\ninvoking [close()](/api_docs/java/org/tensorflow/Server#close()).\n\nInstances of a `Server` are thread-safe.\n\nUsing example:\n\n import org.tensorflow.Server;\n import org.tensorflow.distruntime.ClusterDef;\n import org.tensorflow.distruntime.JobDef;\n import org.tensorflow.distruntime.ServerDef;\n\n ClusterDef clusterDef = ClusterDef.newBuilder()\n .addJob(JobDef.newBuilder()\n .setName(\"worker\")\n .putTasks(0, \"localhost:4321\")\n .build()\n ).build();\n\n ServerDef serverDef = ServerDef.newBuilder()\n .setCluster(clusterDef)\n .setJobName(\"worker\")\n .setTaskIndex(0)\n .setProtocol(\"grpc\")\n .build();\n\n try (Server srv = new Server(serverDef.toByteArray())) {\n srv.start();\n srv.join();\n }\n \n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### Public Constructors\n\n|---|------------------------------------------------------------------------------------------------------------------------|\n| | [Server](/api_docs/java/org/tensorflow/Server#Server(byte[]))(byte\\[\\] serverDef) Constructs a new instance of server. |\n\n### Public Methods\n\n|-------------------|----------------------------------------------------------------------------------------------------------------|\n| synchronized void | [close](/api_docs/java/org/tensorflow/Server#close())() Destroy an in-process TensorFlow server, frees memory. |\n| void | [join](/api_docs/java/org/tensorflow/Server#join())() Blocks until the server has been successfully stopped. |\n| synchronized void | [start](/api_docs/java/org/tensorflow/Server#start())() Starts an in-process TensorFlow server. |\n| synchronized void | [stop](/api_docs/java/org/tensorflow/Server#stop())() Stops an in-process TensorFlow server. |\n\n### Inherited Methods\n\nFrom class java.lang.Object \n\n|------------------|---------------------------|\n| boolean | equals(Object arg0) |\n| final Class\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| String | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nFrom interface java.lang.AutoCloseable \n\n|---------------|---------|\n| abstract void | close() |\n\nPublic Constructors\n-------------------\n\n#### public\n**Server**\n(byte\\[\\] serverDef)\n\nConstructs a new instance of server. \n\n##### Parameters\n\n| serverDef | Server definition specified as a serialized [ServerDef](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/protobuf/tensorflow_server.proto) protocol buffer. |\n|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\nPublic Methods\n--------------\n\n#### public synchronized void\n**close**\n()\n\nDestroy an in-process TensorFlow server, frees memory. \n\n##### Throws\n\n| InterruptedException | |\n|----------------------|---|\n\n#### public void\n**join**\n()\n\nBlocks until the server has been successfully stopped. \n\n#### public synchronized void\n**start**\n()\n\nStarts an in-process TensorFlow server. \n\n#### public synchronized void\n**stop**\n()\n\nStops an in-process TensorFlow server."]]