Skip to content

Commit 4e792cc

Browse files
committed
[scripts] Compile per component
1 parent 4849f3b commit 4e792cc

File tree

6 files changed

+292
-0
lines changed

6 files changed

+292
-0
lines changed

scripts/compile_audio.bat

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@echo off
2+
3+
set "VER_TORCHAUDIO=v2.1.0"
4+
5+
rem Be verbose now
6+
echo on
7+
8+
rem Install Python dependencies
9+
python -m pip install cmake astunparse numpy ninja pyyaml setuptools cffi typing_extensions future six requests dataclasses Pillow
10+
11+
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
12+
13+
rem TorchAudio
14+
cd audio
15+
python -m pip install -r requirements.txt
16+
set "DISTUTILS_USE_SDK=1"
17+
python setup.py clean
18+
python setup.py bdist_wheel
19+
20+
set "DISTUTILS_USE_SDK="
21+
for %%f in ("dist\*.whl") do python -m pip install --force-reinstall --no-deps "%%f"
22+
cd ..

scripts/compile_ipex.bat

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
@echo off
2+
3+
set "VER_IPEX=xpu-main"
4+
5+
if "%~2"=="" (
6+
echo Usage: %~nx0 ^<DPCPPROOT^> ^<MKLROOT^> [AOT]
7+
echo DPCPPROOT and MKLROOT are mandatory, should be absolute or relative path to the root directory of DPC++ compiler and oneMKL respectively.
8+
echo AOT is optional, should be the text string for environment variable USE_AOT_DEVLIST.
9+
exit /b 1
10+
)
11+
set "DPCPP_ROOT=%~1"
12+
set "ONEMKL_ROOT=%~2"
13+
set "AOT="
14+
if not "%~3"=="" (
15+
set "AOT=%~3"
16+
)
17+
18+
rem Check existance of DPCPP and ONEMKL environments
19+
set "DPCPP_ENV=%DPCPP_ROOT%\env\vars.bat"
20+
if NOT EXIST "%DPCPP_ENV%" (
21+
echo DPC++ compiler environment "%DPCPP_ENV%" doesn't seem to exist.
22+
exit /b 2
23+
)
24+
25+
set "ONEMKL_ENV=%ONEMKL_ROOT%\env\vars.bat"
26+
if NOT EXIST "%ONEMKL_ENV%" (
27+
echo oneMKL environment "%ONEMKL_ENV%" doesn't seem to exist.
28+
exit /b 3
29+
)
30+
31+
rem Be verbose now
32+
echo on
33+
34+
rem Install Python dependencies
35+
python -m pip install cmake astunparse numpy ninja pyyaml setuptools cffi typing_extensions future six requests dataclasses Pillow
36+
37+
call "%DPCPP_ENV%"
38+
call "%ONEMKL_ENV%"
39+
40+
rem Intel® Extension for PyTorch*
41+
cd intel-extension-for-pytorch
42+
python -m pip install -r requirements.txt
43+
if NOT "%AOT%"=="" (
44+
set "USE_AOT_DEVLIST=%AOT%"
45+
)
46+
set "BUILD_WITH_CPU=0"
47+
set "USE_MULTI_CONTEXT=1"
48+
set "DISTUTILS_USE_SDK=1"
49+
python setup.py clean
50+
python setup.py bdist_wheel
51+
52+
set "DISTUTILS_USE_SDK="
53+
set "USE_MULTI_CONTEXT="
54+
set "BUILD_WITH_CPU="
55+
for %%f in ("dist\*.whl") do python -m pip install --force-reinstall --no-deps "%%f"
56+
cd ..

scripts/compile_torch.bat

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@echo off
2+
3+
set "VER_PYTORCH=v2.1.0"
4+
5+
rem Be verbose now
6+
echo on
7+
8+
rem Install Python dependencies
9+
python -m pip install cmake astunparse numpy ninja pyyaml setuptools cffi typing_extensions future six requests dataclasses Pillow
10+
11+
rem PyTorch
12+
cd pytorch
13+
for %%f in ("..\intel-extension-for-pytorch\torch_patches\*.patch") do git apply "%%f"
14+
python -m pip install -r requirements.txt
15+
call conda install --force-reinstall intel::mkl-static intel::mkl-include -y
16+
call conda install conda-forge::libuv -y
17+
rem Ensure cmake can find python packages when using conda or virtualenv
18+
if defined CONDA_PREFIX (
19+
set "CMAKE_PREFIX_PATH=%CONDA_PREFIX%"
20+
) else if defined VIRTUAL_ENV (
21+
set "CMAKE_PREFIX_PATH=%VIRTUAL_ENV%"
22+
)
23+
set "CMAKE_INCLUDE_PATH=%CONDA_PREFIX%\Library\include"
24+
set "LIB=%CONDA_PREFIX%\Library\lib;%LIB%"
25+
set "USE_NUMA=0"
26+
set "USE_CUDA=0"
27+
python setup.py clean
28+
python setup.py bdist_wheel
29+
30+
set "USE_CUDA="
31+
set "USE_NUMA="
32+
set "LIB="
33+
set "CMAKE_INCLUDE_PATH="
34+
set "CMAKE_PREFIX_PATH="
35+
call conda remove mkl-static mkl-include -y
36+
for %%f in ("dist\*.whl") do python -m pip install --force-reinstall --no-deps "%%f"

scripts/compile_vision.bat

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@echo off
2+
3+
set "VER_TORCHVISION=v0.16.0"
4+
5+
rem Be verbose now
6+
echo on
7+
8+
rem Install Python dependencies
9+
python -m pip install cmake astunparse numpy ninja pyyaml setuptools cffi typing_extensions future six requests dataclasses Pillow
10+
11+
rem TorchVision
12+
cd vision
13+
call conda install -y --force-reinstall libpng libjpeg-turbo -c conda-forge
14+
python setup.py clean
15+
python setup.py bdist_wheel
16+
17+
call conda remove libpng libjpeg-turbo -y
18+
for %%f in ("dist\*.whl") do python -m pip install --force-reinstall --no-deps "%%f"
19+
cd ..

scripts/prepare_repo.bat

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
@echo off
2+
3+
set "VER_PYTORCH=v2.1.0"
4+
set "VER_TORCHVISION=v0.16.0"
5+
set "VER_TORCHAUDIO=v2.1.0"
6+
set "VER_IPEX=xpu-main"
7+
8+
rem Checkout individual components
9+
if NOT EXIST pytorch (
10+
git clone https://github.com/pytorch/pytorch.git
11+
)
12+
if NOT EXIST vision (
13+
git clone https://github.com/pytorch/vision.git
14+
)
15+
if NOT EXIST audio (
16+
git clone https://github.com/pytorch/audio.git
17+
)
18+
if NOT EXIST intel-extension-for-pytorch (
19+
git clone https://github.com/intel/intel-extension-for-pytorch.git
20+
)
21+
22+
rem Checkout required branch/commit and update submodules
23+
cd pytorch
24+
if not "%VER_PYTORCH%"=="" (
25+
git rm -rf .
26+
git clean -fxd
27+
git reset
28+
git checkout .
29+
git checkout main
30+
git pull
31+
git checkout %VER_PYTORCH%
32+
)
33+
git submodule sync
34+
git submodule update --init --recursive
35+
cd ..
36+
37+
cd vision
38+
if not "%VER_TORCHVISION%"=="" (
39+
git rm -rf .
40+
git clean -fxd
41+
git reset
42+
git checkout .
43+
git checkout main
44+
git pull
45+
git checkout %VER_TORCHVISION%
46+
)
47+
git submodule sync
48+
git submodule update --init --recursive
49+
cd ..
50+
51+
cd audio
52+
if not "%VER_TORCHAUDIO%"=="" (
53+
git rm -rf .
54+
git clean -fxd
55+
git reset
56+
git checkout .
57+
git checkout main
58+
git pull
59+
git checkout %VER_TORCHAUDIO%
60+
)
61+
git submodule sync
62+
git submodule update --init --recursive
63+
cd ..
64+
65+
cd intel-extension-for-pytorch
66+
if not "%VER_IPEX%"=="" (
67+
git rm -rf .
68+
git clean -fxd
69+
git reset
70+
git checkout .
71+
git checkout main
72+
git pull
73+
git checkout %VER_IPEX%
74+
)
75+
git submodule sync
76+
git submodule update --init --recursive
77+
cd ..

scripts/repack_wheels.bat

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
@echo off
2+
setlocal enabledelayedexpansion
3+
4+
if "%~2"=="" (
5+
echo Usage: %~nx0 ^<DPCPPROOT^> ^<MKLROOT^>
6+
echo DPCPPROOT and MKLROOT are mandatory, should be absolute or relative path to the root directory of DPC++ compiler and oneMKL respectively.
7+
exit /b 1
8+
)
9+
10+
set "DPCPP_ROOT=%~1"
11+
set "ONEMKL_ROOT=%~2"
12+
13+
rem Check existence of DPCPP and ONEMKL environments
14+
set "DPCPP_ENV=%DPCPP_ROOT%\env\vars.bat"
15+
if NOT EXIST "%DPCPP_ENV%" (
16+
echo DPC++ compiler environment "%DPCPP_ENV%" doesn't seem to exist.
17+
exit /b 2
18+
)
19+
call "%DPCPP_ENV%"
20+
21+
set "ONEMKL_ENV=%ONEMKL_ROOT%\env\vars.bat"
22+
if NOT EXIST "%ONEMKL_ENV%" (
23+
echo oneMKL environment "%ONEMKL_ENV%" doesn't seem to exist.
24+
exit /b 3
25+
)
26+
call "%ONEMKL_ENV%"
27+
28+
python -m pip install wheel
29+
30+
set "CWD=%cd%\repack"
31+
if EXIST "%CWD%" rmdir "%CWD%" /s /q
32+
mkdir "%CWD%"
33+
cd "%CWD%"
34+
35+
for %%a in ("../pytorch/dist/*") do set TORCH_WHL=%%a
36+
for %%a in ("../intel-extension-for-pytorch/dist/*") do set IPEX_WHL=%%a
37+
38+
wheel unpack "../pytorch/dist/%TORCH_WHL%"
39+
for /f "tokens=*" %%g in ('dir /a:d /b ^| findstr ^^torch') do set TORCH_REPACK_DIR=%%g
40+
41+
wheel unpack "../intel-extension-for-pytorch/dist/%IPEX_WHL%"
42+
for /f "tokens=*" %%g in ('dir /a:d /b ^| findstr ^^intel_extension_for_pytorch') do set IPEX_REPACK_DIR=%%g
43+
44+
set "torch_dlls=uv.dll;libiomp5md.dll"
45+
for %%d in ("%torch_dlls:;=";"%") do (
46+
set /a FOUND=0
47+
for %%p in ("%PATH:;=";"%") do (
48+
if !FOUND! EQU 0 (
49+
if EXIST "%%~p\%%~d" (
50+
set /a FOUND=1
51+
xcopy /s "%%~p\%%~d" "%TORCH_REPACK_DIR%\torch\lib"
52+
)
53+
)
54+
)
55+
if !FOUND! EQU 0 (
56+
echo %%d not found in current environment!
57+
exit /b 1
58+
)
59+
)
60+
61+
set "ipex_dlls=sycl7.dll;pi_level_zero.dll;pi_win_proxy_loader.dll;mkl_core.2.dll;mkl_sycl_blas.4.dll;mkl_sycl_lapack.4.dll;mkl_sycl_dft.4.dll;mkl_tbb_thread.2.dll;libmmd.dll;svml_dispmd.dll"
62+
63+
for %%d in ("%ipex_dlls:;=";"%") do (
64+
set /a FOUND=0
65+
for %%p in ("%PATH:;=";"%") do (
66+
if !FOUND! EQU 0 (
67+
if EXIST "%%~p\%%~d" (
68+
set /a FOUND=1
69+
xcopy /s "%%~p\%%~d" "%IPEX_REPACK_DIR%\intel_extension_for_pytorch\bin"
70+
)
71+
)
72+
)
73+
if !FOUND! EQU 0 (
74+
echo %%d not found in current environment!
75+
exit /b 1
76+
)
77+
)
78+
79+
wheel pack %TORCH_REPACK_DIR%
80+
wheel pack %IPEX_REPACK_DIR%
81+
82+
cd ..

0 commit comments

Comments
 (0)