Skip to content

Commit 9f33088

Browse files
authored
Windows use mkl static lib. (#1790)
From pytorch issue: pytorch/pytorch#124009 I found libtorch seems use shared mkl lib and missing some mkl dll files. 1. Currently pytorch Linux already use static mkl lib. 2. Windows can also support static mkl lib, I have validated as pytorch/pytorch#116946 So, this PR will switch pytorch to use static mkl lib. I have tested PR on my local PC: <img width="1151" alt="image" src="https://github.com/pytorch/builder/assets/8433590/d727c361-3344-4d95-ac2e-8dc307b74690">
1 parent 8fd2559 commit 9f33088

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

windows/build_pytorch.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ for %%v in (%DESIRED_PYTHON_PREFIX%) do (
122122
) else (
123123
set "PATH=%CONDA_HOME%\envs\%%v;%CONDA_HOME%\envs\%%v\scripts;%CONDA_HOME%\envs\%%v\Library\bin;%ORIG_PATH%"
124124
)
125-
pip install ninja mkl-include==2021.4.0 mkl-devel==2021.4.0
125+
pip install ninja
126126
@setlocal
127127
:: Set Flags
128128
if not "%CUDA_VERSION%"=="cpu" (

windows/condaenv.bat

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ FOR %%v IN (%DESIRED_PYTHON%) DO (
99
set PYTHON_VERSION_STR=%%v
1010
set PYTHON_VERSION_STR=!PYTHON_VERSION_STR:.=!
1111
conda remove -n py!PYTHON_VERSION_STR! --all -y || rmdir %CONDA_HOME%\envs\py!PYTHON_VERSION_STR! /s
12-
if "%%v" == "3.8" call conda create -n py!PYTHON_VERSION_STR! -y -q numpy=1.11 "mkl=2020.2" pyyaml boto3 cmake ninja typing_extensions python=%%v
13-
if "%%v" == "3.9" call conda create -n py!PYTHON_VERSION_STR! -y -q numpy>=1.11 "mkl=2020.2" pyyaml boto3 cmake ninja typing_extensions python=%%v
14-
if "%%v" == "3.10" call conda create -n py!PYTHON_VERSION_STR! -y -q -c=conda-forge numpy=1.21.3 "mkl=2020.2" intel-openmp=2023.2.0 pyyaml boto3 "cmake=3.19.6" ninja typing_extensions python=%%v
15-
if "%%v" == "3.11" call conda create -n py!PYTHON_VERSION_STR! -y -q -c=conda-forge numpy=1.23.4 "mkl=2020.2" intel-openmp=2023.2.0 pyyaml boto3 "cmake=3.19.6" ninja typing_extensions python=%%v
16-
if "%%v" == "3.12" call conda create -n py!PYTHON_VERSION_STR! -y -q -c=conda-forge numpy=1.26.0 "mkl=2023.1" intel-openmp=2023.2.0 pyyaml boto3 "cmake=3.19.6" ninja typing_extensions python=%%v
12+
if "%%v" == "3.8" call conda create -n py!PYTHON_VERSION_STR! -y -q numpy=1.11 "intel::mkl-static=2020.2" "intel::mkl-include=2020.2" pyyaml boto3 cmake ninja typing_extensions python=%%v
13+
if "%%v" == "3.9" call conda create -n py!PYTHON_VERSION_STR! -y -q numpy>=1.11 "intel::mkl-static=2020.2" "intel::mkl-include=2020.2" pyyaml boto3 cmake ninja typing_extensions python=%%v
14+
if "%%v" == "3.10" call conda create -n py!PYTHON_VERSION_STR! -y -q -c=conda-forge numpy=1.21.3 "intel::mkl-static=2020.2" "intel::mkl-include=2020.2" intel-openmp=2023.2.0 pyyaml boto3 "cmake=3.19.6" ninja typing_extensions python=%%v
15+
if "%%v" == "3.11" call conda create -n py!PYTHON_VERSION_STR! -y -q -c=conda-forge numpy=1.23.4 "intel::mkl-static=2020.2" "intel::mkl-include=2020.2" intel-openmp=2023.2.0 pyyaml boto3 "cmake=3.19.6" ninja typing_extensions python=%%v
16+
if "%%v" == "3.12" call conda create -n py!PYTHON_VERSION_STR! -y -q -c=conda-forge numpy=1.26.0 "intel::mkl-static=2023.1" "intel::mkl-include=2023.1" intel-openmp=2023.2.0 pyyaml boto3 "cmake=3.19.6" ninja typing_extensions python=%%v
1717
)
1818
endlocal
1919

windows/internal/copy.bat

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ copy "%CUDA_PATH%\extras\CUPTI\lib64\cupti64_*.dll*" pytorch\torch\lib
1111

1212
copy "C:\Program Files\NVIDIA Corporation\NvToolsExt\bin\x64\nvToolsExt64_1.dll*" pytorch\torch\lib
1313
copy "%CONDA_LIB_PATH%\libiomp*5md.dll" pytorch\torch\lib
14-
IF "%PACKAGE_TYPE%"=="libtorch" (
15-
copy "%CONDA_LIB_PATH%\mkl_intel_thread.1.dll" pytorch\torch\lib
16-
copy "%CONDA_LIB_PATH%\mkl_core.1.dll" pytorch\torch\lib
17-
)
14+
1815
:: Should be set in build_pytorch.bat
1916
copy "%libuv_ROOT%\bin\uv.dll" pytorch\torch\lib
2017

windows/internal/copy_cpu.bat

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
copy "%CONDA_LIB_PATH%\libiomp*5md.dll" pytorch\torch\lib
22
:: Should be set in build_pytorch.bat
3-
copy "%libuv_ROOT%\bin\uv.dll" pytorch\torch\lib
4-
5-
IF "%PACKAGE_TYPE%"=="libtorch" (
6-
copy "%CONDA_LIB_PATH%\mkl_intel_thread.1.dll" pytorch\torch\lib
7-
copy "%CONDA_LIB_PATH%\mkl_core.1.dll" pytorch\torch\lib
8-
)
3+
copy "%libuv_ROOT%\bin\uv.dll" pytorch\torch\lib

0 commit comments

Comments
 (0)