Skip to content

Commit 68cbe34

Browse files
committed
Use dynamic MKL on Windows
Use dynamic MKL on Windows and updated MKL to 2021.4.0 On conda python 3.12 use mkl 2023.1
1 parent 524a027 commit 68cbe34

File tree

7 files changed

+27
-21
lines changed

7 files changed

+27
-21
lines changed

conda/pytorch-nightly/bld.bat

-5
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

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ requirements:
2323
- mkl-include # [x86_64]
2424
- mkl=2020.2 # [py <= 311 and x86_64 and not win]
2525
- mkl=2023.1 # [py >= 312 and x86_64]
26-
- mkl=2021.4 # [x86_64 and win and py <= 311]
26+
- mkl-devel=2021.4.0 # [x86_64 and win and py<=311]
27+
- mkl-devel=2023.1 # [x86_64 and win and py>=312]
2728
{% endif %}
2829
- typing_extensions
2930
- ninja
@@ -41,7 +42,9 @@ requirements:
4142
run:
4243
- python
4344
{% if cross_compile_arm64 == 0 %}
44-
- mkl >=2018 # [x86_64]
45+
- mkl >=2018 # [x86_64 and not win]
46+
- mkl=2021.4 # [x86_64 and win and py <= 311]
47+
- mkl=2023.1 # [x86_64 and win and py >= 312]
4548
{% endif %}
4649
- libuv # [win]
4750
- intel-openmp # [win]

windows/build_pytorch.bat

+1-5
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
@@ -126,7 +122,7 @@ for %%v in (%DESIRED_PYTHON_PREFIX%) do (
126122
) else (
127123
set "PATH=%CONDA_HOME%\envs\%%v;%CONDA_HOME%\envs\%%v\scripts;%CONDA_HOME%\envs\%%v\Library\bin;%ORIG_PATH%"
128124
)
129-
pip install ninja
125+
pip install ninja mkl-include==2021.4.0 mkl-devel==2021.4.0
130126
@setlocal
131127
:: Set Flags
132128
if not "%CUDA_VERSION%"=="cpu" (

windows/condaenv.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ FOR %%v IN (%DESIRED_PYTHON%) DO (
1919
)
2020
endlocal
2121

22-
22+
conda list
2323
:: Install libuv
2424
conda install -y -q -c conda-forge libuv=1.39
2525
set libuv_ROOT=%CONDA_HOME%\Library

windows/internal/copy.bat

+4
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

+5
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

+11-8
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if errorlevel 1 exit /b 1
5454

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

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

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

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

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

100104
set /a CUDA_VER=%CUDA_VERSION%
@@ -103,8 +107,7 @@ set CUDA_VER_MINOR=%CUDA_VERSION:~-1,1%
103107
set CUDA_VERSION_STR=%CUDA_VER_MAJOR%.%CUDA_VER_MINOR%
104108

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

109112
:smoke_test
110113
python -c "import torch"

0 commit comments

Comments
 (0)