Skip to content

Commit

Permalink
Fix pyg-lib build error caused by MKL
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianSzwichtenberg committed Feb 6, 2024
1 parent 60a55f6 commit 7c95697
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/cpp_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ jobs:

gtest:
runs-on: ubuntu-latest
env:
MKL_VERSION: 2023.1.0

steps:
- name: Checkout repostiory
Expand All @@ -24,22 +22,16 @@ jobs:

- name: Configure
run: |
pip install mkl==${MKL_VERSION} mkl-include==${MKL_VERSION} mkl-devel==${MKL_VERSION}
export MKL_VERSION=`python -c 'from tools.mkl_ver import compatible_mkl_ver;print(compatible_mkl_ver())'`
pip install mkl-include==${MKL_VERSION} mkl-static==${MKL_VERSION}
export _BLAS_INCLUDE_DIR=`python -c 'import os;import sysconfig;data=sysconfig.get_path("data");print(f"{data}{os.sep}include")'`
export LIBS_DIR=`python -c 'import os;import sysconfig;data=sysconfig.get_path("data");print(f"{data}{os.sep}lib")'`
export MKL_DIR=`python -c 'import os;import sysconfig;data=sysconfig.get_path("data");print(f"{data}{os.sep}lib{os.sep}cmake{os.sep}mkl")'`
cd $LIBS_DIR
for library in `ls *.so.2`; do
ln -s ${library} ${library::-2} || true
done
cd -
mkdir build
cd build
Torch_DIR=`python -c 'import torch;print(torch.utils.cmake_prefix_path)'` cmake .. -GNinja -DBUILD_TEST=ON -DWITH_COV=ON -DCMAKE_BUILD_TYPE=DEBUG -DUSE_MKL_BLAS=OFF -DBLAS_INCLUDE_DIR=$_BLAS_INCLUDE_DIR -DMKL_DIR=${MKL_DIR}
Torch_DIR=`python -c 'import torch;print(torch.utils.cmake_prefix_path)'` cmake .. -GNinja -DBUILD_TEST=ON -DWITH_COV=ON -DCMAKE_BUILD_TYPE=DEBUG -DUSE_MKL_BLAS=ON -DBLAS_INCLUDE_DIR=$_BLAS_INCLUDE_DIR -DMKL_DIR=${MKL_DIR}
unset _BLAS_INCLUDE_DIR
cd ..
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def maybe_append_with_mkl(dependencies):
product_version = match.group(0).split(' ')[-1]

dependencies.append(f'mkl-include=={product_version}')
dependencies.append(f'mkl=={product_version}')
dependencies.append(f'mkl-devel=={product_version}')
dependencies.append(f'mkl-static=={product_version}')


install_requires = []
Expand Down
18 changes: 18 additions & 0 deletions tools/mkl_ver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import re

import torch


def compatible_mkl_ver():
torch_config = torch.__config__.show()
with_mkl_blas = 'BLAS_INFO=mkl' in torch_config
if torch.backends.mkl.is_available() and with_mkl_blas:
product_version = '2023.1.0'
pattern = r'oneAPI Math Kernel Library Version [0-9]{4}\.[0-9]+'
match = re.search(pattern, torch_config)
if match:
product_version = match.group(0).split(' ')[-1]

return product_version

return None

0 comments on commit 7c95697

Please sign in to comment.