Server
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Dağıtılmış eğitimde kullanıma yönelik bir süreç içi TensorFlow sunucusu.
Server
örneği, dağıtılmış eğitime katılabilecek bir dizi cihazı ve bir Session
hedefini kapsüller. Sunucu bir kümeye aittir ( ClusterSpec
tarafından belirtilir) ve adlandırılmış bir işteki belirli bir göreve karşılık gelir. Sunucu aynı kümedeki herhangi bir sunucuyla iletişim kurabilir. Sunucu, start()
çağrılıncaya kadar hiçbir isteği yerine getirmeyecektir. stop()
veya close()
çağrıldığında sunucu istekleri sunmayı durduracaktır. close()
yönteminin sunucu çalışıyorsa onu durdurduğunu unutmayın.
UYARI: Bir Server
close()
çağrılarak açıkça serbest bırakılması gereken kaynaklara sahiptir.
Bir Server
örnekleri iş parçacığı açısından güvenlidir.
Örnek kullanarak:
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();
}
Kamu İnşaatçıları
| Sunucu (bayt[] sunucuDef) Sunucunun yeni bir örneğini oluşturur. |
Genel Yöntemler
senkronize geçersiz | kapalı () İşlem içi bir TensorFlow sunucusunu yok edin, belleği boşaltın. |
geçersiz | katılmak () Sunucu başarıyla durduruluncaya kadar engeller. |
senkronize geçersiz | başlangıç () İşlem içi bir TensorFlow sunucusunu başlatır. |
senkronize geçersiz | durmak () İşlem içi bir TensorFlow sunucusunu durdurur. |
Kalıtsal Yöntemler
Java.lang.Object sınıfından boolean | eşittir (Nesne arg0) |
son Sınıf<?> | getClass () |
int | hashKodu () |
son boşluk | bildir () |
son boşluk | tümünü bildir () |
Sicim | toString () |
son boşluk | bekle (uzun arg0, int arg1) |
son boşluk | bekle (uzun arg0) |
son boşluk | Beklemek () |
Java.lang.AutoCloseable arayüzünden Kamu İnşaatçıları
genel Sunucu (bayt[] sunucuDef)
Sunucunun yeni bir örneğini oluşturur.
Parametreler
sunucuDef | Serileştirilmiş bir ServerDef protokol arabelleği olarak belirtilen sunucu tanımı. |
---|
Genel Yöntemler
genel senkronize void close ()
İşlem içi bir TensorFlow sunucusunu yok edin, belleği boşaltın.
genel geçersiz katılım ()
Sunucu başarıyla durduruluncaya kadar engeller.
genel senkronize geçersiz başlangıç ()
İşlem içi bir TensorFlow sunucusunu başlatır.
genel senkronize geçersiz durdurma ()
İşlem içi bir TensorFlow sunucusunu durdurur.
Aksi belirtilmediği sürece bu sayfanın içeriği Creative Commons Atıf 4.0 Lisansı altında ve kod örnekleri Apache 2.0 Lisansı altında lisanslanmıştır. Ayrıntılı bilgi için Google Developers Site Politikaları'na göz atın. Java, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır. İçeriklerin bir bölümü NumPy lisansı kapsamındadır.
Son güncelleme tarihi: 2025-07-27 UTC.
[null,null,["Son güncelleme tarihi: 2025-07-27 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](/versions/r2.12/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()](/versions/r2.12/api_docs/java/org/tensorflow/Server#start()) is invoked. The server will stop serving requests once [stop()](/versions/r2.12/api_docs/java/org/tensorflow/Server#stop()) or\n[close()](/versions/r2.12/api_docs/java/org/tensorflow/Server#close()) is invoked. Be aware that [close()](/versions/r2.12/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()](/versions/r2.12/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](/versions/r2.12/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](/versions/r2.12/api_docs/java/org/tensorflow/Server#close())() Destroy an in-process TensorFlow server, frees memory. |\n| void | [join](/versions/r2.12/api_docs/java/org/tensorflow/Server#join())() Blocks until the server has been successfully stopped. |\n| synchronized void | [start](/versions/r2.12/api_docs/java/org/tensorflow/Server#start())() Starts an in-process TensorFlow server. |\n| synchronized void | [stop](/versions/r2.12/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."]]