forked from apache/mxnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dist training tested with dmlc_local.py. version 0.1.2-SNAPSHOT
- Loading branch information
Showing
19 changed files
with
138 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
scala-package/core/src/main/scala/ml/dmlc/mxnet/KVStoreServer.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package ml.dmlc.mxnet | ||
|
||
import ml.dmlc.mxnet.Base._ | ||
import org.slf4j.{Logger, LoggerFactory} | ||
|
||
/** | ||
* Server node for the key value store | ||
* @author Yizhi Liu | ||
*/ | ||
class KVStoreServer(private val kvStore: KVStore) { | ||
private val logger: Logger = LoggerFactory.getLogger(classOf[KVStoreServer]) | ||
private val handle: KVStoreHandle = kvStore.handle | ||
private val controller = new KVServerControllerCallback { | ||
override def invoke(cmdId: Int, cmdBody: String): Unit = { | ||
logger.debug("Receive cmdId {}, cmdBody: {}", cmdId, cmdBody) | ||
if (cmdId == 0) { | ||
val optimizer = Serializer.getSerializer.deserialize[Optimizer]( | ||
Serializer.decodeBase64String(cmdBody)) | ||
kvStore.setOptimizer(optimizer) | ||
} else { | ||
logger.warn(s"Server ${kvStore.rank}, unknown command ($cmdId, $cmdBody)") | ||
} | ||
} | ||
} | ||
|
||
// run the server, whose behavior is like | ||
// while receive(x): | ||
// if is_command x: controller(x) | ||
// else if is_key_value x: updater(x) | ||
def run(): Unit = { | ||
checkCall(_LIB.mxKVStoreRunServer(handle, controller)) | ||
} | ||
} | ||
|
||
object KVStoreServer { | ||
// Start server/scheduler according to env variables | ||
def start(): Unit = { | ||
val isWorker = new RefInt | ||
checkCall(_LIB.mxKVStoreIsWorkerNode(isWorker)) | ||
if (isWorker.value == 0) { | ||
val kvStore = KVStore.create("dist") | ||
val server = new KVStoreServer(kvStore) | ||
server.run() | ||
sys.exit() | ||
} | ||
} | ||
} | ||
|
||
trait KVServerControllerCallback { | ||
def invoke(cmdId: Int, cmdBody: String): Unit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.