2015-08-07 20:03:27 +03:00
#!/bin/bash
2016-06-14 18:39:24 +03:00
#
# Copyright (c) Microsoft. All rights reserved.
#
# Licensed under the MIT license. See LICENSE.md file in the project root
# for full license information.
# ==============================================================================
#
2015-08-07 20:03:27 +03:00
configure=$0
build_top=$PWD
cuda_path=
cuda_check=include/cuda.h
enable_cuda=
2016-10-06 13:19:13 +03:00
enable_python=
2017-01-13 00:24:35 +03:00
enable_java=
2016-09-16 04:10:53 +03:00
# NCCL communication library
have_nccl=no
nccl_path=
nccl_check=include/nccl.h
2016-06-14 18:39:24 +03:00
# CNTK Custom MKL Version
2017-01-02 14:52:20 +03:00
cntk_custom_mkl_version=3
2016-06-14 18:39:24 +03:00
2015-08-07 20:03:27 +03:00
have_mkl=no
mkl_path=
2016-06-14 18:39:24 +03:00
mkl_check=$cntk_custom_mkl_version/include/mkl.h
2015-08-07 20:03:27 +03:00
2016-01-30 02:44:37 +03:00
# Experimental OpenBLAS support.
have_openblas=no
openblas_path=
openblas_check=include/openblas_config.h
2016-07-19 10:34:31 +03:00
# Boost library
boost_path=
boost_check=include/boost/test/unit_test.hpp
2016-10-25 01:33:31 +03:00
# Protocol buffers library
protobuf_path=
protobuf_check=lib/libprotobuf.a
2017-01-03 23:29:58 +03:00
# MPI library
mpi_path=
mpi_check=include/mpi.h
2017-02-26 07:35:08 +03:00
# Cuda-aware MPI
# OPENMPI can auto-detect but not MVAPICH2
cuda_gdr=no
default_cuda_gdr=$cuda_gdr
2015-08-07 20:03:27 +03:00
have_kaldi=no
kaldi_path=
2016-06-14 18:39:24 +03:00
kaldi_check=src/kaldi.mk
2015-08-07 20:03:27 +03:00
have_buildtype=no
buildtype=
default_buildtype=release
2016-07-27 17:14:34 +03:00
have_gdk_include=no
gdk_include_path=
gdk_include_check=nvml.h
have_gdk_nvml_lib=no
gdk_nvml_lib_path=
gdk_nvml_lib_check=libnvidia-ml.so
2015-08-07 20:03:27 +03:00
2015-10-13 03:54:13 +03:00
have_cub=no
cub_path=
cub_check=cub/cub.cuh
2015-11-17 23:58:19 +03:00
have_cudnn=no
cudnn_path=
cudnn_check=cuda/include/cudnn.h
2015-10-14 03:24:33 +03:00
have_opencv=no
opencv_path=
opencv_check=include/opencv2/opencv.hpp
2016-02-20 04:41:40 +03:00
have_libzip=no
libzip_path=
libzip_check=include/zip.h
2016-10-06 13:19:13 +03:00
have_swig=no
swig_path=
swig_check=bin/swig
swig_required_version=3.0.10
py_check=bin/python
py_versions=
declare -A py_paths
2017-01-13 00:24:35 +03:00
jdk_check=include/jni.h
default_jdk="jvm/java-7-openjdk-amd64"
2015-08-07 20:03:27 +03:00
mathlib=
2016-10-12 10:45:46 +03:00
have_mpi=yes
default_use_mpi=$have_mpi
2016-01-14 01:29:19 +03:00
default_use_1bitsgd=no
enable_1bitsgd=$default_use_1bitsgd
2016-05-02 19:48:46 +03:00
default_use_code_coverage=no
enable_code_coverage=$default_use_code_coverage
2016-02-01 15:15:54 +03:00
default_use_asgd=yes
2016-01-28 15:51:48 +03:00
enable_asgd=$default_use_asgd
2015-08-07 20:03:27 +03:00
# List from best to worst choice
2017-01-13 00:24:35 +03:00
default_path_list="/usr /usr/local /opt /opt/local /lib /usr/lib"
2015-08-07 20:03:27 +03:00
# List from best to worst choice
2016-06-14 18:39:24 +03:00
default_mkls="CNTKCustomMKL"
2016-01-30 02:44:37 +03:00
default_openblas=""
2015-08-07 20:03:27 +03:00
2016-07-19 10:34:31 +03:00
default_boost="boost-1.60.0"
2016-11-23 21:03:37 +03:00
default_cudas="cuda-8.0 cuda-7.5"
2016-09-16 04:10:53 +03:00
default_nccls="nccl"
2016-04-01 15:41:04 +03:00
default_kaldis="kaldi-trunk kaldi-c024e8aa"
2016-07-27 17:14:34 +03:00
default_gdk_includes="include/nvidia/gdk"
default_gdk_nvml_libs="src/gdk/nvml/lib"
2015-10-13 03:54:13 +03:00
default_cubs="cub-1.4.1"
2016-08-26 12:28:51 +03:00
default_cudnns="cudnn-5.1 cudnn-5.0"
2016-06-17 19:12:32 +03:00
default_opencvs="opencv-3.1.0 opencv-3.0.0"
2016-10-25 01:33:31 +03:00
default_protobuf="protobuf-3.1.0"
2016-02-20 04:41:40 +03:00
default_libzips="libzip-1.1.2"
2016-10-06 13:19:13 +03:00
default_swig="swig-3.0.10"
2017-01-03 23:29:58 +03:00
default_mpi="mpi"
2015-08-07 20:03:27 +03:00
function default_paths ()
{
echo $build_top $HOME $default_path_list
}
# $1 is directory
# $2 is file that must be present
function check_dir ()
{
if test -e $1/$2
then
echo yes
else
echo no
fi
}
# $1 is the list of tails to search, ordered by preference
# $2 is some file that must exist in $1
function find_dir ()
{
2016-01-30 02:44:37 +03:00
# Loop over list of tails to search, including empty (just default_path + search file)
for tail in $1 ''
2015-08-07 20:03:27 +03:00
do
for head in $(default_paths)
do
2016-01-30 02:44:37 +03:00
[ -n "$tail" ] && search_path="$head/$tail" || search_path=$head
if test x$(check_dir "$search_path" $2) = xyes
2015-08-07 20:03:27 +03:00
then
2016-01-30 02:44:37 +03:00
echo $search_path
2015-08-07 20:03:27 +03:00
return 0
fi
done
done
}
function find_mkl ()
{
find_dir "$default_mkls" "$mkl_check"
}
2016-01-30 02:44:37 +03:00
function find_openblas ()
{
find_dir "$default_openblas" "$openblas_check"
}
2016-07-19 10:34:31 +03:00
function find_boost ()
{
find_dir "$default_boost" "$boost_check"
}
2016-10-25 01:33:31 +03:00
function find_protobuf ()
{
find_dir "$default_protobuf" "$protobuf_check"
}
2016-09-16 04:10:53 +03:00
function find_nccl ()
{
find_dir "$default_nccls" "$nccl_check"
}
2015-08-07 20:03:27 +03:00
function find_cuda ()
{
find_dir "$default_cudas" "$cuda_check"
}
function find_kaldi ()
{
find_dir "$default_kaldis" "$kaldi_check"
}
2016-07-27 17:14:34 +03:00
function find_gdk_include ()
{
find_dir "$default_gdk_includes" "$gdk_include_check"
}
function find_gdk_nvml_lib ()
2015-08-07 20:03:27 +03:00
{
2016-07-27 17:14:34 +03:00
find_dir "$default_gdk_nvml_libs" "$gdk_nvml_lib_check"
2015-08-07 20:03:27 +03:00
}
2015-10-13 03:54:13 +03:00
function find_cub ()
{
find_dir "$default_cubs" "$cub_check"
}
2015-11-17 23:58:19 +03:00
function find_cudnn ()
{
find_dir "$default_cudnns" "$cudnn_check"
}
2015-10-14 03:24:33 +03:00
function find_opencv ()
{
find_dir "$default_opencvs" "$opencv_check"
}
2016-02-20 04:41:40 +03:00
function find_libzip ()
{
find_dir "$default_libzips" "$libzip_check"
}
2017-01-03 23:29:58 +03:00
function find_mpi ()
{
find_dir "$default_mpi" "$mpi_check"
}
2015-08-07 20:03:27 +03:00
function is_hardlinked ()
{
r=no
if test -e $1 && test -e $2
then
r=yes
[ "`stat -c '%i' $1`" != "`stat -c '%i' $2`" ] && r=no
fi
echo $r
}
2016-10-06 13:19:13 +03:00
function check_version ()
{
local expected_version=$1
local actual_version=$2
2016-10-12 21:51:17 +03:00
[ -z "$actual_version" ] && return 1
2016-10-06 13:19:13 +03:00
[ "$( printf "%s\n" $actual_version $expected_version | sort -V | head -1)" = "$expected_version" ]
return $?
}
2016-06-14 18:39:24 +03:00
function default_use_cuda ()
2015-08-07 20:03:27 +03:00
{
2016-07-27 17:14:34 +03:00
if test x$(find_cuda) = x || test x$(find_gdk_include) = x || test x$(find_gdk_nvml_lib) = x || test x$(find_cudnn) = x || test x$(find_cub) = x
2015-08-07 20:03:27 +03:00
then
echo no
else
echo yes
fi
}
enable_cuda=$(default_use_cuda)
2016-10-06 13:19:13 +03:00
# TODO allow to pick up from path?
function check_swig ()
{
local swig_dir="$1"
local swig_bin="$swig_dir/$swig_check"
# Check that binary is executable and we can retrieve the version
test -x "$swig_bin" || return $?
"$swig_bin" -version 2>&1 1>/dev/null || return $?
local actual_version=$("$swig_bin" -version | grep '^SWIG Version ' | head -1 | grep -o '[0-9.]*')
if check_version "$swig_required_version" "$actual_version"
then
echo "$swig_dir"
return 0
else
return 1
fi
}
function find_swig ()
{
check_swig "$(find_dir "$default_swig" "$swig_check")"
}
function check_python ()
{
# Required version: exact match against major and minor version
local required_version="$1"
local py_dir="$2"
local py_bin="$py_dir/$py_check"
[ -x "$py_bin" ] || return 1
local py_version=$("$py_bin" -c "import sys; sys.stdout.write('{0}{1}'.format(sys.version_info.major,sys.version_info.minor))")
[ "$?" = "0" ] && [ -x "$py_bin" ] && [ "$py_version" = "$required_version" ] && {
echo $py_dir
return 0
}
return 1
}
# TODO allow to pick up from path?
function find_python ()
{
local required_version="$1"
local py_dir=$(find_dir "" "$py_check")
check_python "$required_version" "$py_dir"
}
function default_use_python ()
{
2016-10-12 21:51:17 +03:00
# Keeping it default "no" for a little while:
2017-03-11 16:35:49 +03:00
# if test x$(find_swig) = x || test x$(find_python 27)$(find_python 34)$(find_python 35)$(find_python 36) = x
2016-10-12 21:51:17 +03:00
# then
2016-10-06 13:19:13 +03:00
echo no
2016-10-12 21:51:17 +03:00
# else
# echo yes
# fi
2016-10-06 13:19:13 +03:00
}
enable_python=$(default_use_python)
2017-01-13 00:24:35 +03:00
function find_jdk ()
{
echo $(find_dir $default_jdk "$jdk_check")
}
function default_use_java ()
{
jdk_path=$(find_jdk)
if test x$jdk_path = x
then
echo no
else
echo yes
fi
}
enable_java=$(default_use_java)
2016-06-14 18:39:24 +03:00
function show_default ()
2015-08-07 20:03:27 +03:00
{
if test x$1 = x
then
echo "(no default)"
else
echo "(default $1)"
fi
}
function show_help ()
{
echo "Usage: configure [options]"
echo "Options:"
echo " -h|--help this help"
echo " --with-build-top=directory build directory $(show_default $build_top)"
echo " --add directory add directory to library search path"
2016-03-25 20:32:57 +03:00
echo " --1bitsgd[=(yes|no)] use 1Bit SGD $(show_default ${default_use_1bitsgd})"
2016-10-25 12:35:01 +03:00
echo " --asgd[=(yes|no)] use ASGD powered by Multiverso $(show_default $(default_use_asgd))"
2015-08-07 20:03:27 +03:00
echo " --cuda[=(yes|no)] use cuda GPU $(show_default $(default_use_cuda))"
2016-10-06 13:19:13 +03:00
echo " --python[=(yes|no)] with Python bindings $(show_default $(default_use_python))"
2017-01-13 00:24:35 +03:00
echo " --java[=(yes|no)] with Java bindings $(show_default $(default_use_java))"
echo " --with-jdk[=directory] $(show_default $(find_jdk))"
2016-11-04 18:38:55 +03:00
echo " --mpi[=(yes|no)] use MPI communication $(show_default ${default_use_mpi})"
2017-02-26 07:35:08 +03:00
echo " --gdr[=(yes|no)] use GPUDirect RDMA $(show_default ${default_cuda_gdr})"
2015-08-07 20:03:27 +03:00
echo " --with-cuda[=directory] $(show_default $(find_cuda))"
2015-10-13 03:54:13 +03:00
echo " --with-cub[=directory] $(show_default $(find_cub))"
2016-07-27 17:14:34 +03:00
echo " --with-gdk-include[=directory] $(show_default $(find_gdk_include))"
echo " --with-gdk-nvml-lib[=directory] $(show_default $(find_gdk_nvml_lib))"
2015-11-17 23:58:19 +03:00
echo " --with-cudnn[=directory] $(show_default $(find_cudnn))"
2016-09-16 04:10:53 +03:00
echo " --with-nccl[=directory] $(show_default $(find_nccl))"
2015-08-07 20:03:27 +03:00
echo " --with-mkl[=directory] $(show_default $(find_mkl))"
2016-06-14 18:39:24 +03:00
echo " --with-mkl-sequential[=directory] $(show_default $(find_mkl))"
2016-01-30 02:44:37 +03:00
echo " --with-openblas[=directory] (experimental) $(show_default $(find_openblas))"
2015-08-07 20:03:27 +03:00
echo " --with-buildtype=(debug|release) $(show_default $default_buildtype)"
echo " --with-kaldi[=directory] $(show_default $(find_kaldi))"
2015-10-14 03:24:33 +03:00
echo " --with-opencv[=directory] $(show_default $(find_opencv))"
2016-02-20 04:41:40 +03:00
echo " --with-libzip[=directory] $(show_default $(find_libzip))"
2016-05-02 19:48:46 +03:00
echo " --with-code-coverage[=(yes|no)] $(show_default ${default_use_code_coverage})"
2016-07-19 10:34:31 +03:00
echo " --with-boost[=directory] $(show_default $(find_boost))"
2016-10-25 01:33:31 +03:00
echo " --with-protobuf[=directory] $(show_default $(find_protobuf))"
2017-03-11 16:35:49 +03:00
echo " --with-py-versions=(space-separated list of 27, 34, 35, 36)"
2016-12-19 15:49:05 +03:00
echo " --with-py27-path[=directory] $(show_default $(find_python 27))"
2016-10-06 13:19:13 +03:00
echo " --with-py34-path[=directory] $(show_default $(find_python 34))"
echo " --with-py35-path[=directory] $(show_default $(find_python 35))"
2017-03-11 16:35:49 +03:00
echo " --with-py36-path[=directory] $(show_default $(find_python 36))"
2016-10-06 13:19:13 +03:00
echo " --with-swig[=directory] $(show_default $(find_swig))"
2017-01-03 23:29:58 +03:00
echo " --with-mpi[=directory] $(show_default $(find_mpi))"
2016-10-06 13:19:13 +03:00
2015-08-07 20:03:27 +03:00
echo "Libraries search path:"
for head in $(default_paths)
do
echo " $head"
done
}
while [[ $# > 0 ]]
do
key="$1"
case $key in
*=?*) optarg=`expr "X$key" : '[^=]*=\(.*\)'` ;;
*=) optarg= ;;
*) optarg= ;;
esac
case $key in
-h|--help)
show_help
exit 1
;;
--with-build-top*)
if test x$optarg != x
then
build_top=$optarg
mkdir -p $build_top
fi
;;
--add*)
if test x$optarg = x
then
shift ; optarg=$1
fi
default_path_list="$optarg $default_path_list"
;;
2016-01-14 01:29:19 +03:00
--1bitsgd*)
if test x$optarg = xyes || test x$optarg = xno
then
enable_1bitsgd=$optarg
else
echo "Invalid value for --1bitsgd $optarg"
show_help
exit
fi
;;
2016-05-02 19:48:46 +03:00
--with-code-coverage*)
if test x$optarg = xyes || test x$optarg = xno
then
enable_code_coverage=$optarg
else
echo "Invalid value for --with-code-coverage $optarg"
show_help
exit
fi
;;
2016-11-01 09:39:14 +03:00
--asgd*)
2016-01-28 15:51:48 +03:00
if test x$optarg = xyes || test x$optarg = xno
then
enable_asgd=$optarg
else
echo "Invalid value for --asgd $optarg"
show_help
exit
fi
;;
2015-08-24 17:39:15 +03:00
--cuda*)
if test x$optarg = xyes || test x$optarg = xno
2015-08-07 20:03:27 +03:00
then
enable_cuda=$optarg
else
2015-08-24 17:39:15 +03:00
echo "Invalid value for --cuda $optarg"
2015-08-07 20:03:27 +03:00
show_help
exit
fi
;;
2016-10-06 13:19:13 +03:00
--python*)
if test x$optarg = xyes || test x$optarg = xno
then
enable_python=$optarg
else
echo "Invalid value for --python $optarg"
show_help
exit
fi
;;
--with-py-versions*)
2016-10-12 21:51:17 +03:00
enable_python=yes
2016-10-06 13:19:13 +03:00
if test "x$optarg" = "x"
then
echo "Mandatory parameter for --with-py-versions missing. Use '--python no' to disable Python support completely."
show_help
exit 1
else
for ver in $optarg
do
case $ver in
2017-03-11 16:35:49 +03:00
27 | 34 | 35 | 36)
2016-10-06 13:19:13 +03:00
;;
*)
echo "Invalid value for --with-py-versions $optarg: invalid version $ver"
show_help
2016-11-04 18:38:55 +03:00
exit
2016-10-06 13:19:13 +03:00
esac
done
# TODO filter duplicates?
py_versions="$optarg"
fi
;;
2017-03-11 16:35:49 +03:00
--with-py27-path*|--with-py34-path*|--with-py35-path*|--with-py36-path*)
2016-10-06 13:19:13 +03:00
enable_python=yes
py_version=${key:9:2}
if test x$optarg = x
then
py_paths[$py_version]=$(find_python $py_version)
if test x${py_paths[$py_version]} = x
then
echo "Cannot find Python $py_version directory."
echo "Please specify a value for $key"
exit 1
2016-10-31 18:08:02 +03:00
fi
2016-10-06 13:19:13 +03:00
else
if check_python $py_version "$optarg"
then
py_paths[$py_version]=$optarg
else
echo "Invalid Python $py_version directory $optarg"
exit 1
fi
fi
;;
--with-swig*)
have_swig=yes
if test x$optarg = x
then
swig_path=$(find_swig)
if test x$swig_path = x
then
echo "Cannot find SWIG directory."
echo "Please specify a value for --with-swig"
exit 1
fi
else
if check_swig "$optarg"
then
swig_path=$optarg
else
echo "Invalid SWIG directory $optarg"
exit 1
fi
fi
;;
2017-01-13 00:24:35 +03:00
--java*)
if test x$optarg = xyes || test x$optarg = xno
then
enable_java=$optarg
else
echo "Invalid value for --java $optarg"
show_help
exit
fi
;;
--with-jdk*)
enable_java=yes
if test x$optarg = x
then
jdk_path=$(find_jdk)
if test x$jdk_path = x
then
echo "Cannot find JDK directory."
echo "Please specify a value for --with-jdk"
exit 1
fi
else
if test $(check_dir $optarg $jdk_check) = yes
then
jdk_path=$optarg
else
echo "Invalid JDK directory $optarg"
exit 1
fi
fi
;;
2016-10-06 13:19:13 +03:00
2016-10-12 10:45:46 +03:00
--mpi*)
if test x$optarg = xyes || test x$optarg = xno
then
have_mpi=$optarg
else
echo "Invalid value for --mpi $optarg"
show_help
exit
fi
;;
2017-02-26 07:35:08 +03:00
--gdr*)
if test x$optarg = xyes || test x$optarg = xno
then
cuda_gdr=$optarg
else
echo "Invalid value for --gdr $optarg"
show_help
exit
fi
;;
2015-08-07 20:03:27 +03:00
--with-cuda*)
enable_cuda=yes
if test x$optarg = x
then
cuda_path=$(find_cuda)
if test x$cuda_path = x
then
echo "Cannot find cuda directory."
echo "Please specify a value for --with-cuda"
exit 1
fi
else
if test $(check_dir $optarg $cuda_check) = yes
then
cuda_path=$optarg
else
echo "Invalid cuda directory $optarg"
exit 1
fi
fi
;;
2016-10-06 13:19:13 +03:00
2015-10-13 03:54:13 +03:00
--with-cub*)
have_cub=yes
if test x$optarg = x
then
cub_path=$(find_cub)
if test x$cub_path = x
then
echo "Cannot find NVIDIA CUB directory."
echo "Please specify a value for --with-cub"
2015-10-13 22:02:35 +03:00
echo "NVIDIA CUB can be downloaded from https://github.com/NVlabs/cub/archive/1.4.1.zip, extract the archive to /usr/local"
2015-10-13 03:54:13 +03:00
exit 1
fi
else
if test $(check_dir $optarg $cub_check) = yes
then
cub_path=$optarg
else
echo "Invalid CUB directory $optarg"
exit 1
fi
fi
;;
2016-07-27 17:14:34 +03:00
--with-gdk-include*)
have_gdk_include=yes
2015-08-07 20:03:27 +03:00
if test x$optarg = x
then
2016-07-27 17:14:34 +03:00
gdk_include_path=$(find_gdk_include)
if test x$gdk_include_path = x
2015-08-07 20:03:27 +03:00
then
2016-07-27 17:14:34 +03:00
echo "Cannot find GDK include directory."
echo "Please specify a value for --with-gdk-include"
2015-08-07 20:03:27 +03:00
exit 1
fi
else
2016-07-27 17:14:34 +03:00
if test $(check_dir $optarg $gdk_include_check) = yes
2015-08-07 20:03:27 +03:00
then
2016-07-27 17:14:34 +03:00
gdk_include_path=$optarg
2015-08-07 20:03:27 +03:00
else
2016-07-27 17:14:34 +03:00
echo "Invalid GDK include directory $optarg"
exit 1
fi
fi
;;
--with-gdk-nvml-lib*)
have_gdk_nvml_lib=yes
if test x$optarg = x
then
gdk_nvml_lib_path=$(find_gdk_nvml_lib)
if test x$gdk_nvml_lib_path = x
then
echo "Cannot find GDK NVML library directory."
echo "Please specify a value for --with-gdk-nvml-lib"
exit 1
fi
else
if test $(check_dir $optarg $gdk_nvml_lib_check) = yes
then
gdk_nvml_lib_path=$optarg
else
echo "Invalid GDK NVML library directory $optarg"
2015-08-07 20:03:27 +03:00
exit 1
fi
fi
;;
2015-11-17 23:58:19 +03:00
--with-cudnn*)
have_cudnn=yes
if test x$optarg = x
then
cudnn_path=$(find_cudnn)
if test x$cudnn_path = x
then
echo "Cannot find NVIDIA cuDNN directory."
echo "Please specify a value for --with-cudnn"
exit 1
fi
else
if test $(check_dir $optarg $cudnn_check) = yes
then
cudnn_path=$optarg
else
echo "Invalid cuDNN directory $optarg"
exit 1
fi
fi
;;
2016-09-16 04:10:53 +03:00
--with-nccl*)
have_nccl=yes
if test x$optarg = x
then
nccl_path=$(find_nccl)
if test x$nccl_path = x
then
echo "Cannot find NCCL directory."
echo "Please specify a value for --with-nccl"
echo "NCCL can be downloaded from https://github.com/NVIDIA/nccl"
exit 1
fi
else
if test $(check_dir $optarg $nccl_check) = yes
then
nccl_path=$optarg
else
echo "Invalid NCCL directory $optarg"
exit 1
fi
fi
;;
2015-08-07 20:03:27 +03:00
--with-mkl*)
have_mkl=yes
mathlib=mkl
2016-06-14 18:39:24 +03:00
mkl_threading=parallel
case $key in
--with-mkl-sequential*) mkl_threading=sequential ;;
esac
2015-08-07 20:03:27 +03:00
if test x$optarg = x
then
mkl_path=$(find_mkl)
if test x$mkl_path = x
then
2016-09-23 12:01:07 +03:00
echo "Cannot find CNTK custom MKL directory (version $cntk_custom_mkl_version)"
2015-08-07 20:03:27 +03:00
echo "Please specify a value for --with-mkl"
exit 1
fi
else
if test $(check_dir $optarg $mkl_check) = yes
then
mkl_path=$optarg
else
2016-06-14 18:39:24 +03:00
echo "Invalid CNTK custom MKL directory $optarg"
2015-08-07 20:03:27 +03:00
exit 1
fi
fi
;;
2016-01-30 02:44:37 +03:00
--with-openblas*)
have_openblas=yes
mathlib=openblas
if test x$optarg = x
then
openblas_path=$(find_openblas)
if test x$openblas_path = x
then
echo "Cannot find openblas directory"
echo "Please specify a value for --with-openblas"
exit 1
fi
else
if test $(check_dir $optarg $openblas_check) = yes
then
openblas_path=$optarg
else
echo "Invalid openblas directory $optarg"
exit 1
fi
fi
;;
2016-07-19 10:34:31 +03:00
--with-boost*)
if test x$optarg = x
then
boost_path=$(find_boost)
if test x$boost_path = x
2016-11-04 18:38:55 +03:00
then
2016-07-19 10:34:31 +03:00
echo "Cannot find Boost directory"
echo "Please specify a value for --with-boost"
exit 1
fi
else
if test $(check_dir $optarg $boost_check) = yes
2016-11-04 18:38:55 +03:00
then
2016-07-19 10:34:31 +03:00
boost_path=$optarg
else
echo "Invalid Boost directory $optarg"
exit 1
fi
fi
;;
2016-10-25 01:33:31 +03:00
--with-protobuf*)
if test x$optarg = x
then
protobuf_path=$(find_protobuf)
if test x$protobuf_path = x
then
echo "Cannot find Protocol Buffers directory"
echo "Please specify a value for --with-protobuf"
exit 1
fi
else
if test $(check_dir $optarg $protobuf_check) = yes
then
protobuf_path=$optarg
else
echo "Invalid Protocol Buffers directory $optarg"
exit 1
2016-11-04 18:38:55 +03:00
fi
2016-10-25 01:33:31 +03:00
fi
;;
2015-08-07 20:03:27 +03:00
--with-buildtype*)
have_buildtype=yes
case $optarg in
debug|release)
buildtype=$optarg
;;
*)
echo Invalid buildtype $optarg
echo Must be debug or release
exit 1
esac
;;
--with-kaldi*)
have_kaldi=yes
if test x$optarg = x
then
kaldi_path=$(find_kaldi)
if test x$kaldi_path = x
then
echo "Cannot find kaldi directory"
echo "Please specify a value for --with-kaldi"
exit 1
fi
else
if test $(check_dir $optarg $kaldi_check)
then
kaldi_path=$optarg
else
echo "Invalid kaldi directory $optarg"
exit 1
fi
fi
;;
2015-10-14 03:24:33 +03:00
--with-opencv*)
have_opencv=yes
if test x$optarg = x
then
opencv_path=$(find_opencv)
if test x$opencv_path = x
then
echo "Cannot find OpenCV directory."
echo "Please specify a value for --with-opencv"
echo "OpenCV can be downloaded from http://opencv.org/downloads.html, install instructions http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation"
exit 1
fi
else
if test $(check_dir $optarg $opencv_check) = yes
then
opencv_path=$optarg
else
echo "Invalid OpenCV directory $optarg"
exit 1
fi
fi
;;
2016-02-20 04:41:40 +03:00
--with-libzip*)
have_libzip=yes
if test x$optarg = x
then
libzip_path=$(find_libzip)
if test x$libzip_path = x
then
echo "Cannot find libzip directory."
echo "Please specify a value for --with-libzip"
2016-02-25 21:48:13 +03:00
echo "libzip (v.1.1.2 or higher) can be downloaded from http://www.nih.at/libzip/"
2016-02-20 04:41:40 +03:00
exit 1
fi
else
2016-08-01 15:27:38 +03:00
if test $(check_dir $optarg $libzip_check) = yes
2016-02-20 04:41:40 +03:00
then
libzip_path=$optarg
else
echo "Invalid libzip directory $optarg"
exit 1
fi
fi
;;
2017-01-03 23:29:58 +03:00
--with-mpi*)
if test x$optarg = x
then
mpi_path=$(find_mpi)
if test x$mpi_path = x
then
echo "Cannot find mpi directory."
exit 1
fi
else
if test $(check_dir $optarg $mpi_check) = yes
then
mpi_path=$optarg
else
echo "Invalid mpi directory $optarg"
exit 1
fi
fi
;;
2015-08-07 20:03:27 +03:00
*)
echo Invalid option $key
show_help
exit 1
esac
shift
done
if test x$buildtype = x
then
buildtype=$default_buildtype
echo Defaulting to --with-buildtype=release
fi
2016-08-16 16:08:08 +03:00
# If no math library was specified, search for mkl
if test x$have_mkl = xno && test x$have_openblas = xno
2015-08-07 20:03:27 +03:00
then
2016-11-04 18:38:55 +03:00
mkl_path=$(find_mkl)
if test x$mkl_path = x
then
echo "Cannot find a CPU math library."
echo "Please specify --with-mkl, --with-mkl-sequential, --with-openblas with a path."
exit 1
else
mathlib=mkl
fi
2015-08-07 20:03:27 +03:00
fi
# If no cuda library specified, search for one
if test x$enable_cuda = xyes && test x$cuda_path = x
then
cuda_path=$(find_cuda)
if test x$cuda_path = x ; then
echo Cannot locate a cuda directory
echo GPU will be disabled
enable_cuda=no
else
echo Found cuda at $cuda_path
fi
fi
2016-07-27 17:14:34 +03:00
if test $enable_cuda = yes && test x$gdk_include_path = x
then
gdk_include_path=$(find_gdk_include)
if test x$gdk_include_path = x ; then
echo Cannot locate a GDK include directory
echo GPU will be disabled
enable_cuda=no
else
echo Found GDK include at $gdk_include_path
fi
fi
if test $enable_cuda = yes && test x$gdk_nvml_lib_path = x
2015-08-07 20:03:27 +03:00
then
2016-07-27 17:14:34 +03:00
gdk_nvml_lib_path=$(find_gdk_nvml_lib)
if test x$gdk_nvml_lib_path = x ; then
echo Cannot locate a GDK NVML library directory
2015-08-07 20:03:27 +03:00
echo GPU will be disabled
enable_cuda=no
else
2016-07-27 17:14:34 +03:00
echo Found GDK NVML library at $gdk_nvml_lib_path
2015-08-07 20:03:27 +03:00
fi
fi
2015-10-13 03:54:13 +03:00
if test $enable_cuda = yes && test x$cub_path = x
then
cub_path=$(find_cub)
if test x$cub_path = x ; then
echo Cannot locate NVIDIA CUB directory
echo GPU will be disabled
2015-10-13 22:02:35 +03:00
echo NVIDIA CUB can be downloaded from https://github.com/NVlabs/cub/archive/1.4.1.zip, extract the archive to /usr/local
2015-10-13 03:54:13 +03:00
enable_cuda=no
else
echo Found CUB at $cub_path
fi
fi
2015-11-17 23:58:19 +03:00
if test $enable_cuda = yes && test x$cudnn_path = x
then
cudnn_path=$(find_cudnn)
if test x$cudnn_path = x ; then
echo Cannot locate NVIDIA cuDNN directory
echo CNTK will use default convolution engine.
else
echo Found cuDNN at $cudnn_path
fi
fi
2017-01-13 00:24:35 +03:00
if ( test $enable_java = yes || test $enable_python = yes ) && test x$swig_path = x
2016-10-06 13:19:13 +03:00
then
swig_path=$(find_swig)
if test x$swig_path = x
then
2017-01-13 00:24:35 +03:00
echo 'Cannot locate SWIG (>= 3.0.10), which is required Python/Java support.'
2016-10-06 13:19:13 +03:00
echo Check bindings/python/swig_install.sh for build instructions.
exit 1
fi
fi
if test $enable_python = yes
then
2017-01-05 11:11:46 +03:00
# TODO disabled for now. Default Python versions may miss dependencies we do not
# check for here yet, only support explicitly specified paths.
2016-10-12 21:51:17 +03:00
# Fill unfilled default paths
2017-01-05 11:11:46 +03:00
#[ -z "${py_paths[27]}" ] && find_python 27 && py_paths[27]=$(find_python 27)
#[ -z "${py_paths[34]}" ] && find_python 34 && py_paths[34]=$(find_python 34)
#[ -z "${py_paths[35]}" ] && find_python 35 && py_paths[35]=$(find_python 35)
2016-10-06 13:19:13 +03:00
# Unless there's a specified order or restriction, take all configured Python versions (old to new)
[ -z "$py_versions" ] && py_versions=${!py_paths[@]}
py_versions="$py_versions "
# Make sure each requested version is configured, remove other parts
2017-03-11 16:35:49 +03:00
for ver in 27 34 35 36
2016-10-06 13:19:13 +03:00
do
case $py_versions in
*$ver\ *)
# Build for version is requested, check if configured
if [ -z "${py_paths[$ver]}" ]
then
echo Build for Python version $ver was requested, but is not configured.
exit 1
fi
;;
*)
# Build for version is not requested, unconfigure
unset -v py_paths[$ver]
;;
esac
done
fi
2016-09-16 04:10:53 +03:00
if test $enable_cuda = yes && test x$nccl_path = x
then
nccl_path=$(find_nccl)
if test x$nccl_path != x; then
echo Found NCCL at $nccl_path
fi
fi
2015-12-12 05:08:27 +03:00
if test x$opencv_path = x
then
opencv_path=$(find_opencv)
if test x$opencv_path = x ; then
echo Cannot locate OpenCV 3.0.0 directory
echo ImageReader will NOT be built.
else
echo Found OpenCV at $opencv_path
fi
fi
2016-02-20 04:41:40 +03:00
if test x$libzip_path = x
then
libzip_path=$(find_libzip)
if test x$libzip_path = x ; then
echo Cannot locate libzip files
echo ImageReader will be built without zip container support.
else
echo Found libzip at $libzip_path
fi
fi
2016-04-01 15:41:04 +03:00
if test x$kaldi_path = x
then
kaldi_path=$(find_kaldi)
if test x$kaldi_path = x ; then
echo Cannot locate Kaldi files
echo Kaldi2Reader will NOT be built.
else
echo Found Kaldi at $kaldi_path
fi
fi
2016-07-19 10:34:31 +03:00
if test x$boost_path = x
then
boost_path=$(find_boost)
if test x$boost_path = x
then
2016-12-21 14:13:13 +03:00
echo Cannot locate Boost libraries. See
echo https://github.com/Microsoft/CNTK/wiki/Setup-CNTK-on-Linux#boost-library
echo for installation instructions.
exit 1
2016-07-19 10:34:31 +03:00
else
echo Found Boost at $boost_path
fi
fi
2016-10-25 01:33:31 +03:00
if test x$protobuf_path = x
then
protobuf_path=$(find_protobuf)
if test x$protobuf_path = x
then
echo Cannot locate Protocol Buffers library. See
echo https://github.com/Microsoft/CNTK/wiki/Setup-CNTK-on-Linux#protobuf
echo for installation instructions.
exit 1
else
echo Found Protocol Buffers at $protobuf_path
fi
fi
2017-01-03 23:29:58 +03:00
if test x$mpi_path = x
then
mpi_path=$(find_mpi)
if test x${mpi_path} = x
then
echo Cannot locate MPI library. See
echo https://github.com/Microsoft/CNTK/wiki/Setup-CNTK-on-Linux#open-mpi
echo for installation instructions.
exit 1
else
echo Found MPI at $mpi_path
fi
fi
2015-08-07 20:03:27 +03:00
config=$build_top/Config.make
echo Generating $config
echo "#Configuration file for cntk" > $config
echo BUILDTYPE=$buildtype >> $config
echo MATHLIB=$mathlib >> $config
case $mathlib in
mkl)
echo MKL_PATH=$mkl_path >> $config
2016-06-14 18:39:24 +03:00
echo MKL_THREADING=$mkl_threading >> $config
echo CNTK_CUSTOM_MKL_VERSION=$cntk_custom_mkl_version >> $config
2015-08-07 20:03:27 +03:00
;;
2016-01-30 02:44:37 +03:00
openblas)
echo OPENBLAS_PATH=$openblas_path >> $config
;;
2015-08-07 20:03:27 +03:00
esac
2016-10-12 10:45:46 +03:00
if test $have_mpi = yes ; then
echo HAS_MPI=1 >> $config
else
echo HAS_MPI=0 >> $config
fi
2017-02-26 07:35:08 +03:00
if test $cuda_gdr = yes ; then
echo CUDA_GDR=1 >> $config
else
echo CUDA_GDR=0 >> $config
fi
2015-08-07 20:03:27 +03:00
if test $enable_cuda = yes ; then
echo CUDA_PATH=$cuda_path >> $config
2016-07-27 17:14:34 +03:00
echo GDK_INCLUDE_PATH=$gdk_include_path >> $config
echo GDK_NVML_LIB_PATH=$gdk_nvml_lib_path >> $config
2015-10-13 03:54:13 +03:00
echo CUB_PATH=$cub_path >> $config
2015-11-17 23:58:19 +03:00
echo CUDNN_PATH=$cudnn_path >> $config
2016-11-13 09:13:13 +03:00
[ -z "$nccl_path" ] || echo NCCL_PATH=$nccl_path >> $config
2015-08-07 20:03:27 +03:00
fi
2017-01-13 00:24:35 +03:00
if test $enable_python = yes || test $enable_java = yes ; then
echo SWIG_PATH=$swig_path/bin >> $config
fi
2016-10-06 13:19:13 +03:00
if test $enable_python = yes ; then
echo PYTHON_SUPPORT=true >> $config
# N.B. PYTHON_VERSIONS at least needs to be parseable by bash (cf. Tools/generate_build_info)
echo PYTHON_VERSIONS= >> $config
for ver in $py_versions
do
echo PYTHON_VERSIONS+=$ver >> $config
echo PYTHON${ver}_PATH=${py_paths[$ver]}/$py_check >> $config
done
fi
2017-01-13 00:24:35 +03:00
if test $enable_java = yes ; then
if test x${jdk_path} = x ; then
jdk_path=$(find_jdk)
fi
if test x${jdk_path} = x
then
echo Cannot locate JDK.
exit 1
else
echo Found JDK at $jdk_path
echo JAVA_SUPPORT=true >> $config
echo JDK_PATH=$jdk_path >> $config
fi
fi
2015-08-07 20:03:27 +03:00
if test x$kaldi_path != x ; then
echo KALDI_PATH=$kaldi_path >> $config
fi
2015-10-14 03:24:33 +03:00
if test x$opencv_path != x ; then
echo OPENCV_PATH=$opencv_path >> $config
fi
2016-02-20 04:41:40 +03:00
if test x$libzip_path != x ; then
echo LIBZIP_PATH=$libzip_path >> $config
fi
2016-01-14 01:29:19 +03:00
if test $enable_1bitsgd = yes ; then
echo CNTK_ENABLE_1BitSGD=true >> $config
fi
2016-05-02 19:48:46 +03:00
if test $enable_code_coverage = yes ; then
echo CNTK_CODE_COVERAGE=true >> $config
fi
2016-07-19 10:34:31 +03:00
if test x$boost_path != x; then
echo BOOST_PATH=$boost_path >> $config
fi
2016-10-25 01:33:31 +03:00
if test x$protobuf_path != x; then
echo PROTOBUF_PATH=$protobuf_path >> $config
fi
2017-01-03 23:29:58 +03:00
if test x$mpi_path != x; then
echo MPI_PATH=$mpi_path >> $config
fi
2015-08-07 20:03:27 +03:00
2016-01-28 15:51:48 +03:00
if test $enable_asgd = yes ; then
echo CNTK_ENABLE_ASGD=true >> $config
fi
2015-08-07 20:03:27 +03:00
# If we are not in the configure directory, generate a trampoline Makefile
makefile=$build_top/Makefile
if test $(is_hardlinked "$configure" "$build_top/configure") = no
then
echo Generating $makefile
realconf=`readlink -f $configure`
dir=`dirname $realconf`
echo "#Generate Makefile" > $makefile
echo dir=$dir >> $makefile
echo BUILD_TOP=$build_top >> $makefile
echo >> $makefile
echo all clean : >> $makefile
printf '\t$(MAKE) -C $(dir) BUILD_TOP=$(BUILD_TOP) $@\n' >> $makefile
fi
2016-06-14 18:39:24 +03:00
echo run
2016-10-06 13:19:13 +03:00
echo '>make -j $(nproc) all'
2015-08-07 20:03:27 +03:00
echo to build
2016-10-06 13:19:13 +03:00
# vim:set expandtab tabstop=4 shiftwidth=4: