Skip to content

Commit 3f1b8be

Browse files
committed
Fix dot on MKL builds
Not sure why MKL_INTERFACE_LAYER used by libmkl_rt.so (linked to by numpy) would affect libmkl_intel_gf.so (linked to by pytorch). It didn't use to. Might be a bug/feature in newer MKL.
1 parent a6a2a6b commit 3f1b8be

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

recipe/meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ outputs:
403403
# We have had issues with openmp .dylibs being doubly loaded in certain cases. These two tests catch the (observed) issue
404404
- python -c "import torch; import numpy"
405405
- python -c "import numpy; import torch"
406+
- python -c "import numpy as np;import torch;x = torch.tensor([2], dtype=torch.complex128);assert torch.dot(x, x).real == 4.0"
406407
# distributed support is enabled by default on linux; for mac, we enable it manually in build.sh
407408
- python -c "import torch; assert torch.distributed.is_available()" # [linux or osx]
408409
- python -c "import torch; assert torch.backends.cuda.is_built()" # [cuda_compiler_version != "None"]

recipe/patches/0005-Use-BLAS_USE_CBLAS_DOT-for-OpenBLAS-builds.patch

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From 1572b5d176f17e2a4ebe7c859e8c2aa19607190a Mon Sep 17 00:00:00 2001
1+
From c36fe22f0b7a8d95ba04b6c3c8358a70a552ff71 Mon Sep 17 00:00:00 2001
22
From: Isuru Fernando <[email protected]>
33
Date: Wed, 18 Dec 2024 03:59:00 +0000
4-
Subject: [PATCH 05/16] Use BLAS_USE_CBLAS_DOT for OpenBLAS builds
4+
Subject: [PATCH] Use BLAS_USE_CBLAS_DOT for OpenBLAS builds
55

66
There are two calling conventions for *dotu functions
77

@@ -27,11 +27,11 @@ assists with the BLAS switching mechanism as we are not relying on
2727
a particular `cdotu` implementation with the cost of two additional
2828
functional calls.
2929
---
30-
cmake/Dependencies.cmake | 1 +
31-
1 file changed, 1 insertion(+)
30+
cmake/Dependencies.cmake | 2 ++
31+
1 file changed, 2 insertions(+)
3232

3333
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
34-
index 4bc52c05d87..c356c7cdfe2 100644
34+
index 5227204b041..d800e950540 100644
3535
--- a/cmake/Dependencies.cmake
3636
+++ b/cmake/Dependencies.cmake
3737
@@ -182,6 +182,7 @@ elseif(BLAS STREQUAL "OpenBLAS")
@@ -42,3 +42,14 @@ index 4bc52c05d87..c356c7cdfe2 100644
4242
elseif(BLAS STREQUAL "BLIS")
4343
find_package(BLIS REQUIRED)
4444
include_directories(SYSTEM ${BLIS_INCLUDE_DIR})
45+
@@ -204,6 +205,7 @@ elseif(BLAS STREQUAL "MKL")
46+
set(BLAS_INFO "mkl")
47+
set(BLAS_FOUND 1)
48+
set(BLAS_LIBRARIES ${MKL_LIBRARIES})
49+
+ set(BLAS_USE_CBLAS_DOT TRUE)
50+
else()
51+
message(WARNING "MKL could not be found. Defaulting to Eigen")
52+
set(CAFFE2_USE_EIGEN_FOR_BLAS ON)
53+
--
54+
2.47.1
55+

0 commit comments

Comments
 (0)