SINGA-108 Add Python wrapper to singa Add singa.py and modify singa-run.sh.
Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/0578d82d Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/0578d82d Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/0578d82d Branch: refs/heads/master Commit: 0578d82d6562c65030bee2d8b20755484d44eaf0 Parents: 9b68af1 Author: xiezl <[email protected]> Authored: Fri Dec 4 18:01:45 2015 +0800 Committer: xiezl <[email protected]> Committed: Tue Dec 8 12:28:56 2015 +0800 ---------------------------------------------------------------------- bin/singa-run.sh | 10 +++++++--- src/driver.cc | 2 ++ src/driver.i | 3 +++ src/generatepy.sh | 8 +++++--- 4 files changed, 17 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/0578d82d/bin/singa-run.sh ---------------------------------------------------------------------- diff --git a/bin/singa-run.sh b/bin/singa-run.sh index 548f8f1..1dce339 100755 --- a/bin/singa-run.sh +++ b/bin/singa-run.sh @@ -33,7 +33,8 @@ usage="Usage: singa-run.sh -conf <job config file> [ other arguments ]\n # parse arguments # make sure we have '-conf' and remove '-exec' -exe=./singa +#exe=./singa +exe=./src/singa.py while [ $# != 0 ]; do if [ $1 == "-exec" ]; then shift @@ -81,9 +82,12 @@ host_file=$log_dir/job.hosts ./singatool genhost $job_conf 1>$host_file || exit 1 # set command to run singa -singa_run="$exe $args -conf $job_conf \ +#singa_run="$exe $args -conf $job_conf \ +# -singa_conf $SINGA_HOME/conf/singa.conf \ +# -singa_job $job_id" +singa_run="python $exe $args -conf $job_conf \ -singa_conf $SINGA_HOME/conf/singa.conf \ - -singa_job $job_id" + -singa_job $job_id" singa_sshrun="cd $SINGA_HOME; $singa_run" # ssh and start singa processes http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/0578d82d/src/driver.cc ---------------------------------------------------------------------- diff --git a/src/driver.cc b/src/driver.cc index 816e0df..1181b99 100644 --- a/src/driver.cc +++ b/src/driver.cc @@ -153,6 +153,8 @@ void Driver::Init(int argc, char **argv) { void Driver::Train(bool resume, const std::string str){ JobProto job_conf; job_conf.ParseFromString(str); + printf("STR IS !@#!#!@# %s\n",str.c_str()); + printf("!!!!!!!!!!!!!!!!%s\n",job_conf.cluster().workspace().c_str()); Train(resume,job_conf); } http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/0578d82d/src/driver.i ---------------------------------------------------------------------- diff --git a/src/driver.i b/src/driver.i index 3dea542..d1154a8 100644 --- a/src/driver.i +++ b/src/driver.i @@ -1,6 +1,8 @@ %module driver %include "std_vector.i" %include "std_string.i" +%include "argcargv.i" +%apply (int ARGC, char **ARGV) { (int argc, char **argv) } %{ #include "../include/singa/driver.h" %} @@ -10,6 +12,7 @@ using std::vector; class Driver{ public: void Train(bool resume, const std::string job_conf); +void Init(int argc, char **argv); }; } http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/0578d82d/src/generatepy.sh ---------------------------------------------------------------------- diff --git a/src/generatepy.sh b/src/generatepy.sh index 6fc4b77..e1bbeee 100644 --- a/src/generatepy.sh +++ b/src/generatepy.sh @@ -1,5 +1,7 @@ swig -c++ -python driver.i -g++ -fPIC driver.cc driver_wrap.cxx -shared -o _driver.so -DMSHADOW_USE_CUDA=0 \ - -DMSHADOW_USE_CBLAS=1 -DMSHADOW_USE_MKL=0 -DUSE_GPU -std=c++11 \ - -I/usr/cuda-7.5/include -I../include -I/usr/include/python2.7/ +g++ -fPIC driver.cc driver_wrap.cxx -shared -o _driver.so +-L/home/zhongle/incubator-singa/.libs/ -lsinga -DMSHADOW_USE_CUDA=0 +-DMSHADOW_USE_CBLAS=1 -DMSHADOW_USE_MKL=0 -DUSE_GPU -std=c++11 +-I/usr/cuda-7.5/include -I/home/zhongle/local/include -I../include +-I/usr/include/python2.7/
