From 7cf8e0c9e6a619cc27c678cd2624c74717ad51ce Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Tue, 6 Sep 2016 20:09:52 +0800 Subject: [PATCH 1/3] Lazy install Paddle wheels * install wheels when invoke paddle script if current python don't have paddle packages, or installed a previous version. * Also add `make install` to travis --- .travis.yml | 1 + paddle/scripts/submit_local.sh.in | 34 +++++++++++++++++++++++++++ paddle/scripts/travis/build.sh | 6 +---- paddle/scripts/travis/common.sh | 5 ++++ paddle/scripts/travis/make_install.sh | 5 ++++ paddle/scripts/travis/unittest.sh | 3 +-- python/CMakeLists.txt | 4 ---- 7 files changed, 47 insertions(+), 11 deletions(-) create mode 100755 paddle/scripts/travis/common.sh create mode 100755 paddle/scripts/travis/make_install.sh diff --git a/.travis.yml b/.travis.yml index 644b8dfb23..a78853e15b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ before_install: script: - paddle/scripts/travis/build.sh - paddle/scripts/travis/unittest.sh + - paddle/scripts/travis/make_install.sh notifications: email: on_success: change diff --git a/paddle/scripts/submit_local.sh.in b/paddle/scripts/submit_local.sh.in index eed2d31593..6d2cab6b16 100644 --- a/paddle/scripts/submit_local.sh.in +++ b/paddle/scripts/submit_local.sh.in @@ -43,6 +43,40 @@ fi export PYTHONPATH=${PWD}:${PYTHONPATH} + +# Check python lib installed or not. +pip --help > /dev/null +if [ $? -ne 0 ]; then + echo "pip should be installed to run paddle." + exit 1 +fi + +INSTALLED_VERSION=`pip freeze 2>/dev/null | grep '^paddle' | sed 's/.*==//g'` + +if [ -z ${INSTALLED_VERSION} ]; then + INSTALLED_VERSION="0.0.0" # not installed +fi +cat < Date: Fri, 9 Sep 2016 16:25:00 +0800 Subject: [PATCH 2/3] Exit when pip install failed --- paddle/scripts/submit_local.sh.in | 1 + 1 file changed, 1 insertion(+) diff --git a/paddle/scripts/submit_local.sh.in b/paddle/scripts/submit_local.sh.in index 6d2cab6b16..4cf5f41f19 100644 --- a/paddle/scripts/submit_local.sh.in +++ b/paddle/scripts/submit_local.sh.in @@ -73,6 +73,7 @@ if [ $? -eq 1 ]; then # Older version installed, or not installed at all echo "pip install wheels failed. " echo "Please use 'sudo paddle' at the first time you use PaddlePaddle" echo "PaddlePaddle will install some python dependencies automatically." + exit 1 fi echo "Python dependencies are installed." fi From 0c8aeffb9acd1d727d4f1c4bb18d4c6ce3346891 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Fri, 9 Sep 2016 17:01:20 +0800 Subject: [PATCH 3/3] Fix a PyDataProvider2 bug when use calc_batch_size * Need PyGuard when set args for calc_batch_size --- paddle/gserver/dataproviders/PyDataProvider2.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/paddle/gserver/dataproviders/PyDataProvider2.cpp b/paddle/gserver/dataproviders/PyDataProvider2.cpp index f7886c4e01..8e51752dc2 100644 --- a/paddle/gserver/dataproviders/PyDataProvider2.cpp +++ b/paddle/gserver/dataproviders/PyDataProvider2.cpp @@ -340,6 +340,7 @@ private: size_t additionalBatchSize = 1; if (calcBatchSize_) { + PyGuard guard; py::CallableHelper calcBatchSize(this->calcBatchSize_); calcBatchSize.setArgsSize(1); calcBatchSize.getArgs().set(0, data); @@ -513,6 +514,7 @@ public: } { if (calcBatchSize_) { // custom calc batch size. + PyGuard guard; Py_INCREF(data.back().get()); py::CallableHelper calcBatchSize(calcBatchSize_); calcBatchSize.setArgsSize(1); @@ -575,6 +577,11 @@ public: scanners[i]->finishFill(inArgs[i]); } + { + PyGuard g; + cache_->drop(&data); + } + DBG << "Reading CPU Batch Done."; if (useGpu_) { @@ -592,10 +599,6 @@ public: *batch = cpuBatch; } - { - PyGuard g; - cache_->drop(&data); - } return bsize; } };