Skip to content

Commit

Permalink
Use intel Sparse on Windows
Browse files Browse the repository at this point in the history
Use Sparse  on Windows and updated mkl to 2021.4.0
  • Loading branch information
mantaionut committed Oct 15, 2023
1 parent 3e2d4a1 commit 9cfbff0
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
5 changes: 0 additions & 5 deletions conda/pytorch-nightly/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ if "%desired_cuda%" == "12.1" (

set DISTUTILS_USE_SDK=1

curl https://s3.amazonaws.com/ossci-windows/mkl_2020.2.254.7z -k -O
7z x -aoa mkl_2020.2.254.7z -omkl
set CMAKE_INCLUDE_PATH=%SRC_DIR%\mkl\include
set LIB=%SRC_DIR%\mkl\lib;%LIB%

set libuv_ROOT=%PREFIX%\Library
echo libuv_ROOT=%libuv_ROOT%

Expand Down
4 changes: 3 additions & 1 deletion conda/pytorch-nightly/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ requirements:
- python
- setuptools
- pyyaml
- mkl-devel=2021.4.0 # [win]
{% if cross_compile_arm64 == 0 %}
- mkl-include # [x86_64]
- mkl=2020.2 # [x86_64 and not win]
Expand All @@ -37,8 +38,9 @@ requirements:

run:
- python
- mkl==2021.4.0 # [win]
{% if cross_compile_arm64 == 0 %}
- mkl >=2018 # [x86_64]
- mkl==2021.4 # [x86_64]
{% endif %}
- libuv # [win]
- intel-openmp # [win]
Expand Down
2 changes: 1 addition & 1 deletion wheel/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fi
if [[ "$(uname -m)" == "arm64" ]]; then
retry conda install ${EXTRA_CONDA_INSTALL_FLAGS} -yq cmake ninja
else
retry conda install ${EXTRA_CONDA_INSTALL_FLAGS} -yq cmake ninja mkl-include==2022.2.1 mkl-static==2022.2.1 -c intel
retry conda install ${EXTRA_CONDA_INSTALL_FLAGS} -yq cmake ninja mkl-include==2022.2.1 mkl-static==2022.2.1 mkl==2021.4.0 -c intel
fi
retry pip install -qr "${pytorch_rootdir}/requirements.txt" || true

Expand Down
6 changes: 1 addition & 5 deletions windows/build_pytorch.bat
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ exit /B 1
:: Install MKL
rmdir /s /q mkl
del mkl_2020.2.254.7z
curl https://s3.amazonaws.com/ossci-windows/mkl_2020.2.254.7z -k -O
7z x -aoa mkl_2020.2.254.7z -omkl
set CMAKE_INCLUDE_PATH=%cd%\mkl\include
set LIB=%cd%\mkl\lib;%LIB%

:: Download MAGMA Files on CUDA builds
set MAGMA_VERSION=2.5.4
Expand Down Expand Up @@ -128,7 +124,7 @@ for %%v in (%DESIRED_PYTHON_PREFIX%) do (
) else (
set "PATH=%CONDA_HOME%\envs\%%v;%CONDA_HOME%\envs\%%v\scripts;%CONDA_HOME%\envs\%%v\Library\bin;%ORIG_PATH%"
)
pip install ninja
pip install ninja mkl-include==2021.4.0 mkl-devel==2021.4.0
@setlocal
:: Set Flags
if not "%CUDA_VERSION%"=="cpu" (
Expand Down
4 changes: 4 additions & 0 deletions windows/internal/copy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ copy "%CUDA_PATH%\extras\CUPTI\lib64\cupti64_*.dll*" pytorch\torch\lib

copy "C:\Program Files\NVIDIA Corporation\NvToolsExt\bin\x64\nvToolsExt64_1.dll*" pytorch\torch\lib
copy "%CONDA_LIB_PATH%\libiomp*5md.dll" pytorch\torch\lib
IF "%PACKAGE_TYPE%"=="libtorch" (
copy "%CONDA_LIB_PATH%\mkl_intel_thread.1.dll" pytorch\torch\lib
copy "%CONDA_LIB_PATH%\mkl_core.1.dll" pytorch\torch\lib
)
:: Should be set in build_pytorch.bat
copy "%libuv_ROOT%\bin\uv.dll" pytorch\torch\lib

Expand Down
6 changes: 6 additions & 0 deletions windows/internal/copy_cpu.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
@echo on
copy "%CONDA_LIB_PATH%\libiomp*5md.dll" pytorch\torch\lib
:: Should be set in build_pytorch.bat
copy "%libuv_ROOT%\bin\uv.dll" pytorch\torch\lib

IF "%PACKAGE_TYPE%"=="libtorch" (
copy "%CONDA_LIB_PATH%\mkl_intel_thread.1.dll" pytorch\torch\lib
copy "%CONDA_LIB_PATH%\mkl_core.1.dll" pytorch\torch\lib
)
19 changes: 11 additions & 8 deletions windows/internal/smoke_test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ if errorlevel 1 exit /b 1

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

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

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

conda create -qyn testenv python=%DESIRED_PYTHON%
if errorlevel 1 exit /b 1

call conda install -yq conda-build
if errorlevel 1 exit /b 1
call %CONDA_HOME%\condabin\activate.bat testenv
if errorlevel 1 exit /b 1
set "NO_ARCH_PATH=%PYTORCH_FINAL_PACKAGE_DIR:/=\%\noarch"
mkdir %NO_ARCH_PATH%
for /F "delims=" %%i in ('where /R "%PYTORCH_FINAL_PACKAGE_DIR:/=\%" *.tar.bz2') do xcopy "%%i" %NO_ARCH_PATH% /Y
if ERRORLEVEL 1 exit /b 1
call conda index %PYTORCH_FINAL_PACKAGE_DIR%
if errorlevel 1 exit /b 1
call conda install -yq -c "file:///%PYTORCH_FINAL_PACKAGE_DIR%" pytorch==%PYTORCH_BUILD_VERSION% -c pytorch -c numba/label/dev -c pytorch-nightly -c nvidia

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

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

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


:smoke_test
python -c "import torch"
Expand Down

0 comments on commit 9cfbff0

Please sign in to comment.