Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/distro.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Weijnitz <per.weijnitz@gmail.com>2017-05-18 00:18:07 +0300
committerPer Weijnitz <per.weijnitz@gmail.com>2017-05-19 11:01:36 +0300
commitba1adb41109dd5d65f9c5ba278a774e2fad67b17 (patch)
treefb6a099b381b4a300e470a59f6f88ca6587f6398
parent9e2f875d0ee3d82e16d87b5abc0d64c92b50fd10 (diff)
Improve OpenBLAS dependency installation.
Change the OpenBLAS installation function to skip installation if the script detects an already installed OpenBLAS (using ldconfig). Also change the OpenBLAS installation to use PREFIX as install target rather than the hardcoded /opt/OpenBLAS. Match against both libblas.so and libopenblas.so.
-rwxr-xr-xinstall-deps53
-rwxr-xr-xinstall.sh2
2 files changed, 36 insertions, 19 deletions
diff --git a/install-deps b/install-deps
index d057f67..38982ac 100755
--- a/install-deps
+++ b/install-deps
@@ -8,25 +8,42 @@ set -e
install_openblas() {
# Get and build OpenBlas (Torch is much better with a decent Blas)
- cd /tmp/
- rm -rf OpenBLAS
- git clone https://github.com/xianyi/OpenBLAS.git
- cd OpenBLAS
- if [ $(getconf _NPROCESSORS_CONF) == 1 ]; then
- make NO_AFFINITY=1 USE_OPENMP=0 USE_THREAD=0
+ # Optionally set environment variable PREFIX to control
+ # the installation directory.
+
+
+ local PATH=$PATH:/sbin ## improve chances of finding ldconfig
+ # Only proceed installing OpenBLAS if either ldconfig is unavailable, or ldconfig
+ # reports that OpenBLAS is not already installed.
+ if ! type ldconfig >/dev/null || ! ldconfig -p | grep -q "lib\(open\)\?blas.so"; then
+ local tempdir=$(mktemp -d)
+
+ git clone https://github.com/xianyi/OpenBLAS.git "$tempdir"/OpenBLAS || { echo "Error. Cannot clone OpenBLAS." >&2 ; exit 1 ; }
+ cd "$tempdir"/OpenBLAS || { echo "Error. Cannot create tempdir." >&2 ; exit 1 ; }
+ if [ $(getconf _NPROCESSORS_CONF) == 1 ]; then
+ make NO_AFFINITY=1 USE_OPENMP=0 USE_THREAD=0
+ else
+ make NO_AFFINITY=1 USE_OPENMP=1
+ fi
+ RET=$?;
+ if [ $RET -ne 0 ]; then
+ echo "Error. OpenBLAS could not be compiled";
+ exit $RET;
+ fi
+ if [ ! -z "$PREFIX" ]; then
+ sudo make install PREFIX="$PREFIX"
+ else
+ sudo make install
+ fi
+ RET=$?;
+ if [ $RET -ne 0 ]; then
+ echo "Error. OpenBLAS could not be installed";
+ exit $RET;
+ fi
+ cd -
+ rm -rf "$tempdir"
else
- make NO_AFFINITY=1 USE_OPENMP=1
- fi
- RET=$?;
- if [ $RET -ne 0 ]; then
- echo "Error. OpenBLAS could not be compiled";
- exit $RET;
- fi
- sudo make install
- RET=$?;
- if [ $RET -ne 0 ]; then
- echo "Error. OpenBLAS could not be installed";
- exit $RET;
+ echo "Skipping install of OpenBLAS - it is already installed." >&2
fi
}
diff --git a/install.sh b/install.sh
index 40fb6a9..788a8b7 100755
--- a/install.sh
+++ b/install.sh
@@ -43,7 +43,7 @@ fi
echo "Prefix set to $PREFIX"
if [[ `uname` == 'Linux' ]]; then
- export CMAKE_LIBRARY_PATH=/opt/OpenBLAS/include:/opt/OpenBLAS/lib:$CMAKE_LIBRARY_PATH
+ export CMAKE_LIBRARY_PATH=$PREFIX/include:/opt/OpenBLAS/include:$PREFIX/lib:/opt/OpenBLAS/lib:$CMAKE_LIBRARY_PATH
fi
export CMAKE_PREFIX_PATH=$PREFIX