Skip to content

Commit d73636b

Browse files
committed
Use dynamic MKL on Windows
Use dynamic MKL on Windows and updated MKL to 2021.4.0
1 parent 3e2d4a1 commit d73636b

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

conda/pytorch-nightly/bld.bat

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ if "%desired_cuda%" == "12.1" (
3434

3535
set DISTUTILS_USE_SDK=1
3636

37-
curl https://s3.amazonaws.com/ossci-windows/mkl_2020.2.254.7z -k -O
38-
7z x -aoa mkl_2020.2.254.7z -omkl
39-
set CMAKE_INCLUDE_PATH=%SRC_DIR%\mkl\include
40-
set LIB=%SRC_DIR%\mkl\lib;%LIB%
41-
4237
set libuv_ROOT=%PREFIX%\Library
4338
echo libuv_ROOT=%libuv_ROOT%
4439

conda/pytorch-nightly/meta.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ requirements:
1919
- python
2020
- setuptools
2121
- pyyaml
22+
- mkl-devel=2021.4.0 # [win]
2223
{% if cross_compile_arm64 == 0 %}
2324
- mkl-include # [x86_64]
2425
- mkl=2020.2 # [x86_64 and not win]
@@ -37,8 +38,9 @@ requirements:
3738

3839
run:
3940
- python
41+
- mkl==2021.4.0 # [win]
4042
{% if cross_compile_arm64 == 0 %}
41-
- mkl >=2018 # [x86_64]
43+
- mkl==2021.4 # [x86_64]
4244
{% endif %}
4345
- libuv # [win]
4446
- intel-openmp # [win]

windows/build_pytorch.bat

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ exit /B 1
6767
:: Install MKL
6868
rmdir /s /q mkl
6969
del mkl_2020.2.254.7z
70-
curl https://s3.amazonaws.com/ossci-windows/mkl_2020.2.254.7z -k -O
71-
7z x -aoa mkl_2020.2.254.7z -omkl
72-
set CMAKE_INCLUDE_PATH=%cd%\mkl\include
73-
set LIB=%cd%\mkl\lib;%LIB%
7470

7571
:: Download MAGMA Files on CUDA builds
7672
set MAGMA_VERSION=2.5.4
@@ -128,7 +124,7 @@ for %%v in (%DESIRED_PYTHON_PREFIX%) do (
128124
) else (
129125
set "PATH=%CONDA_HOME%\envs\%%v;%CONDA_HOME%\envs\%%v\scripts;%CONDA_HOME%\envs\%%v\Library\bin;%ORIG_PATH%"
130126
)
131-
pip install ninja
127+
pip install ninja mkl-include==2021.4.0 mkl-devel==2021.4.0
132128
@setlocal
133129
:: Set Flags
134130
if not "%CUDA_VERSION%"=="cpu" (

windows/internal/copy.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ 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+
)
1418
:: Should be set in build_pytorch.bat
1519
copy "%libuv_ROOT%\bin\uv.dll" pytorch\torch\lib
1620

windows/internal/copy_cpu.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
copy "%CONDA_LIB_PATH%\libiomp*5md.dll" pytorch\torch\lib
22
:: Should be set in build_pytorch.bat
33
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+
)

windows/internal/smoke_test.bat

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ if errorlevel 1 exit /b 1
5353

5454
set "PATH=%CD%\Python%PYTHON_VERSION%\Scripts;%CD%\Python;%PATH%"
5555

56-
pip install -q numpy protobuf "mkl>=2019"
56+
pip install -q numpy protobuf
5757
if errorlevel 1 exit /b 1
5858

5959
for /F "delims=" %%i in ('where /R "%PYTORCH_FINAL_PACKAGE_DIR:/=\%" *.whl') do pip install "%%i"
@@ -86,14 +86,18 @@ set "PATH=%CONDA_HOME%;%CONDA_HOME%\scripts;%CONDA_HOME%\Library\bin;%PATH%"
8686

8787
conda create -qyn testenv python=%DESIRED_PYTHON%
8888
if errorlevel 1 exit /b 1
89-
89+
call conda install -yq conda-build
90+
if errorlevel 1 exit /b 1
9091
call %CONDA_HOME%\condabin\activate.bat testenv
9192
if errorlevel 1 exit /b 1
93+
set "NO_ARCH_PATH=%PYTORCH_FINAL_PACKAGE_DIR:/=\%\noarch"
94+
mkdir %NO_ARCH_PATH%
95+
for /F "delims=" %%i in ('where /R "%PYTORCH_FINAL_PACKAGE_DIR:/=\%" *.tar.bz2') do xcopy "%%i" %NO_ARCH_PATH% /Y
96+
if ERRORLEVEL 1 exit /b 1
97+
call conda index %PYTORCH_FINAL_PACKAGE_DIR%
98+
if errorlevel 1 exit /b 1
99+
call conda install -yq -c "file:///%PYTORCH_FINAL_PACKAGE_DIR%" pytorch==%PYTORCH_BUILD_VERSION% -c pytorch -c numba/label/dev -c nvidia
92100

93-
:: do conda install to make sure all the dependencies are installed
94-
:: Install numpy see: https://github.com/pytorch/pytorch/issues/107228
95-
:: todo: Remove numpy install once the issue above is resolved
96-
call conda install -yq numpy pytorch %CONDA_EXTRA_ARGS%
97101
if ERRORLEVEL 1 exit /b 1
98102

99103
set /a CUDA_VER=%CUDA_VERSION%
@@ -102,8 +106,7 @@ set CUDA_VER_MINOR=%CUDA_VERSION:~-1,1%
102106
set CUDA_VERSION_STR=%CUDA_VER_MAJOR%.%CUDA_VER_MINOR%
103107

104108
:: Install package we just build
105-
for /F "delims=" %%i in ('where /R "%PYTORCH_FINAL_PACKAGE_DIR:/=\%" *.tar.bz2') do call conda install -yq "%%i" --offline
106-
if ERRORLEVEL 1 exit /b 1
109+
107110

108111
:smoke_test
109112
python -c "import torch"

0 commit comments

Comments
 (0)