From da4a976b68d77b4d03e9359a83f48d008369c8d3 Mon Sep 17 00:00:00 2001 From: yangulei Date: Wed, 27 Apr 2022 16:18:44 +0800 Subject: [PATCH 1/6] enable CI to get and build latest oneDNN release --- docker/install/ubuntu_install_dnnl.sh | 37 ++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/docker/install/ubuntu_install_dnnl.sh b/docker/install/ubuntu_install_dnnl.sh index 34f917ce6606..692e7fdf11e2 100755 --- a/docker/install/ubuntu_install_dnnl.sh +++ b/docker/install/ubuntu_install_dnnl.sh @@ -20,10 +20,35 @@ set -e set -u set -o pipefail +old_dir=`pwd` + cd /usr/local/ -wget -q https://github.com/oneapi-src/oneDNN/releases/download/v2.2/dnnl_lnx_2.2.0_cpu_gomp.tgz -tar -xzf dnnl_lnx_2.2.0_cpu_gomp.tgz -mv dnnl_lnx_2.2.0_cpu_gomp/include/* /usr/local/include/ -mv dnnl_lnx_2.2.0_cpu_gomp/lib/libdnnl* /usr/local/lib/ -rm -rf dnnl_lnx_2.2.0_cpu_gomp.tgz dnnl_lnx_2.2.0_cpu_gomp -cd - +current_dir=`pwd` + +rls_tag=$(curl -s https://github.com/oneapi-src/oneDNN/releases/latest \ + | cut -d '"' -f 2 \ + | grep -o '[^\/]*$') +dnnl_ver=`echo ${rls_tag} | sed 's/v//g'` +echo "The latest oneDNN release is version ${dnnl_ver} with tag '${rls_tag}'" + +tar_file="${rls_tag}.tar.gz" +src_dir="${current_dir}/oneDNN-${dnnl_ver}" + +if [ -d ${src_dir} ]; then + echo "source files exist." +else + if [ -f ${tar_file} ]; then + echo "${tar_file} exists, skip downloading." + else + echo "downloading ${tar_file}." + tar_url="https://github.com/oneapi-src/oneDNN/archive/refs/tags/${tar_file}" + wget ${tar_url} ${tar_file} + fi + tar -xzvf ${tar_file} +fi + +install_dir="/usr/local/" +cd ${src_dir} +cmake . -DCMAKE_INSTALL_PREFIX=${install_dir} && make -j16 && make install + +cd ${old_dir} From cbcc6e9ac699c96daad494e404898177a78da83f Mon Sep 17 00:00:00 2001 From: yangulei Date: Wed, 27 Apr 2022 16:39:27 +0800 Subject: [PATCH 2/6] remove the source code after installed --- docker/install/ubuntu_install_dnnl.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/install/ubuntu_install_dnnl.sh b/docker/install/ubuntu_install_dnnl.sh index 692e7fdf11e2..f7306edab398 100755 --- a/docker/install/ubuntu_install_dnnl.sh +++ b/docker/install/ubuntu_install_dnnl.sh @@ -51,4 +51,7 @@ install_dir="/usr/local/" cd ${src_dir} cmake . -DCMAKE_INSTALL_PREFIX=${install_dir} && make -j16 && make install +cd ${current_dir} +rm -rf ${tar_file} ${src_dir} + cd ${old_dir} From 48021d75a4d4cef9b3f89f103668ba72bb07e4af Mon Sep 17 00:00:00 2001 From: yangulei Date: Wed, 27 Apr 2022 21:17:52 +0800 Subject: [PATCH 3/6] fix wget error and improve naming --- docker/install/ubuntu_install_dnnl.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docker/install/ubuntu_install_dnnl.sh b/docker/install/ubuntu_install_dnnl.sh index f7306edab398..e4579667e8b1 100755 --- a/docker/install/ubuntu_install_dnnl.sh +++ b/docker/install/ubuntu_install_dnnl.sh @@ -20,11 +20,12 @@ set -e set -u set -o pipefail -old_dir=`pwd` +pre_dir=`pwd` -cd /usr/local/ -current_dir=`pwd` +build_dir="/usr/local/" +install_dir="/usr/local/" +cd ${build_dir} rls_tag=$(curl -s https://github.com/oneapi-src/oneDNN/releases/latest \ | cut -d '"' -f 2 \ | grep -o '[^\/]*$') @@ -32,7 +33,7 @@ dnnl_ver=`echo ${rls_tag} | sed 's/v//g'` echo "The latest oneDNN release is version ${dnnl_ver} with tag '${rls_tag}'" tar_file="${rls_tag}.tar.gz" -src_dir="${current_dir}/oneDNN-${dnnl_ver}" +src_dir="${build_dir}/oneDNN-${dnnl_ver}" if [ -d ${src_dir} ]; then echo "source files exist." @@ -42,16 +43,15 @@ else else echo "downloading ${tar_file}." tar_url="https://github.com/oneapi-src/oneDNN/archive/refs/tags/${tar_file}" - wget ${tar_url} ${tar_file} + wget ${tar_url} fi tar -xzvf ${tar_file} fi -install_dir="/usr/local/" cd ${src_dir} cmake . -DCMAKE_INSTALL_PREFIX=${install_dir} && make -j16 && make install -cd ${current_dir} +cd ${build_dir} rm -rf ${tar_file} ${src_dir} -cd ${old_dir} +cd ${pre_dir} From c8c61fb2bf7bdada0a2a5c241ad18c669ace36b8 Mon Sep 17 00:00:00 2001 From: Youlei Yang Date: Thu, 28 Apr 2022 08:09:19 +0800 Subject: [PATCH 4/6] refine the cmake/make commands Co-authored-by: driazati <9407960+driazati@users.noreply.github.com> --- docker/install/ubuntu_install_dnnl.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docker/install/ubuntu_install_dnnl.sh b/docker/install/ubuntu_install_dnnl.sh index e4579667e8b1..2aec464fb02d 100755 --- a/docker/install/ubuntu_install_dnnl.sh +++ b/docker/install/ubuntu_install_dnnl.sh @@ -49,7 +49,10 @@ else fi cd ${src_dir} -cmake . -DCMAKE_INSTALL_PREFIX=${install_dir} && make -j16 && make install +NPROC=$(nproc) +cmake . -GNinja -DCMAKE_INSTALL_PREFIX=${install_dir} +make -j"$NPROC" +make install cd ${build_dir} rm -rf ${tar_file} ${src_dir} From a55bb62c40d8559dae5aaf90d4d55534f978ce1d Mon Sep 17 00:00:00 2001 From: yangulei Date: Thu, 28 Apr 2022 09:18:22 +0800 Subject: [PATCH 5/6] pinned to v2.6 by default --- docker/install/ubuntu_install_dnnl.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docker/install/ubuntu_install_dnnl.sh b/docker/install/ubuntu_install_dnnl.sh index 2aec464fb02d..bd336bd2ab22 100755 --- a/docker/install/ubuntu_install_dnnl.sh +++ b/docker/install/ubuntu_install_dnnl.sh @@ -24,6 +24,7 @@ pre_dir=`pwd` build_dir="/usr/local/" install_dir="/usr/local/" +pinned_tag="v2.6" # unset or set to "" to build latest release cd ${build_dir} rls_tag=$(curl -s https://github.com/oneapi-src/oneDNN/releases/latest \ @@ -32,6 +33,12 @@ rls_tag=$(curl -s https://github.com/oneapi-src/oneDNN/releases/latest \ dnnl_ver=`echo ${rls_tag} | sed 's/v//g'` echo "The latest oneDNN release is version ${dnnl_ver} with tag '${rls_tag}'" +if [[ -v pinned_tag && -n ${pinned_tag} ]]; then + rls_tag=${pinned_tag} + dnnl_ver=`echo ${rls_tag} | sed 's/v//g'` + echo "Using pinned oneDNN release version ${dnnl_ver} with tag '${rls_tag}'" +fi + tar_file="${rls_tag}.tar.gz" src_dir="${build_dir}/oneDNN-${dnnl_ver}" @@ -45,16 +52,16 @@ else tar_url="https://github.com/oneapi-src/oneDNN/archive/refs/tags/${tar_file}" wget ${tar_url} fi + echo "extracting source files." tar -xzvf ${tar_file} fi cd ${src_dir} -NPROC=$(nproc) -cmake . -GNinja -DCMAKE_INSTALL_PREFIX=${install_dir} -make -j"$NPROC" +cmake . -DCMAKE_INSTALL_PREFIX="${install_dir}" +make -j"$(nproc)" make install cd ${build_dir} -rm -rf ${tar_file} ${src_dir} +rm -rfv ${tar_file} ${src_dir} cd ${pre_dir} From 987532f9dcd1c80ec31b1c5112fd500051978ea1 Mon Sep 17 00:00:00 2001 From: yangulei Date: Thu, 12 May 2022 19:32:54 +0800 Subject: [PATCH 6/6] simplify the logic and install to /usr/lib --- docker/install/ubuntu_install_dnnl.sh | 47 ++++++++------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/docker/install/ubuntu_install_dnnl.sh b/docker/install/ubuntu_install_dnnl.sh index bd336bd2ab22..3654d140f55b 100755 --- a/docker/install/ubuntu_install_dnnl.sh +++ b/docker/install/ubuntu_install_dnnl.sh @@ -21,47 +21,28 @@ set -u set -o pipefail pre_dir=`pwd` +tmpdir=$(mktemp -d) -build_dir="/usr/local/" -install_dir="/usr/local/" -pinned_tag="v2.6" # unset or set to "" to build latest release +rls_tag="v2.6" -cd ${build_dir} -rls_tag=$(curl -s https://github.com/oneapi-src/oneDNN/releases/latest \ - | cut -d '"' -f 2 \ - | grep -o '[^\/]*$') dnnl_ver=`echo ${rls_tag} | sed 's/v//g'` -echo "The latest oneDNN release is version ${dnnl_ver} with tag '${rls_tag}'" +echo "Using oneDNN release version ${dnnl_ver} with tag '${rls_tag}'" -if [[ -v pinned_tag && -n ${pinned_tag} ]]; then - rls_tag=${pinned_tag} - dnnl_ver=`echo ${rls_tag} | sed 's/v//g'` - echo "Using pinned oneDNN release version ${dnnl_ver} with tag '${rls_tag}'" -fi +archive_name="${rls_tag}.tar.gz" +archive_url="https://github.com/oneapi-src/oneDNN/archive/refs/tags/${archive_name}" +archive_folder="${tmpdir}/oneDNN-${dnnl_ver}" +archive_hash="4cb7b80bfe16920bc096e18e7d8caa56b9ab7a4dab2a091a230bcf562c09533392f4a4ccd4db22754a10293670efdea20382db0994dc47949005a4c77f14b64c" -tar_file="${rls_tag}.tar.gz" -src_dir="${build_dir}/oneDNN-${dnnl_ver}" +cd "${tmpdir}" -if [ -d ${src_dir} ]; then - echo "source files exist." -else - if [ -f ${tar_file} ]; then - echo "${tar_file} exists, skip downloading." - else - echo "downloading ${tar_file}." - tar_url="https://github.com/oneapi-src/oneDNN/archive/refs/tags/${tar_file}" - wget ${tar_url} - fi - echo "extracting source files." - tar -xzvf ${tar_file} -fi +curl -sL "${archive_url}" -o "${archive_name}" +echo "$archive_hash" ${archive_name} | sha512sum -c +tar xf "${archive_name}" -cd ${src_dir} -cmake . -DCMAKE_INSTALL_PREFIX="${install_dir}" +cd "${archive_folder}" +cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib make -j"$(nproc)" make install -cd ${build_dir} -rm -rfv ${tar_file} ${src_dir} - cd ${pre_dir} +rm -rf "${tmpdir}"