Skip to content

Commit ba7f6c1

Browse files
compile_bundle.bat for windows (#2991) (#3005)
* added compile_bundle windows batch file * remove _GLIBCXX_USE_CXX11_ABI flag --------- Signed-off-by: min-jean-cho <min.jean.cho@intel.com> Co-authored-by: Jinghui <jinghui.gu@intel.com>
1 parent d1a06aa commit ba7f6c1

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed

scripts/compile_bundle.bat

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
@echo off
2+
3+
set "VER_PYTORCH=v2.0.1"
4+
set "VER_TORCHVISION=v0.15.2"
5+
set "VER_IPEX=xpu-master"
6+
7+
if "%~2"=="" (
8+
echo Usage: %~nx0 ^<DPCPPROOT^> ^<MKLROOT^> [AOT]
9+
echo DPCPPROOT and MKLROOT are mandatory, should be absolute or relative path to the root directory of DPC++ compiler and oneMKL respectively.
10+
echo AOT is optional, should be the text string for environment variable USE_AOT_DEVLIST.
11+
exit /b 1
12+
)
13+
set "DPCPP_ROOT=%~1"
14+
set "ONEMKL_ROOT=%~2"
15+
set "AOT="
16+
if not "%~3"=="" (
17+
set "AOT=%~3"
18+
)
19+
20+
rem Check existance of DPCPP and ONEMKL environments
21+
set "DPCPP_ENV=%DPCPP_ROOT%\env\vars.bat"
22+
if NOT EXIST "%DPCPP_ENV%" (
23+
echo DPC++ compiler environment %DPCPP_ENV% doesn't seem to exist.
24+
exit /b 2
25+
)
26+
call %DPCPP_ENV%
27+
28+
set "ONEMKL_ENV=%ONEMKL_ROOT%\env\vars.bat"
29+
if NOT EXIST "%ONEMKL_ENV%" (
30+
echo oneMKL environment %ONEMKL_ENV% doesn't seem to exist.
31+
exit /b 3
32+
)
33+
call %ONEMKL_ENV%
34+
35+
rem Check existence of required Windows commands
36+
for %%A in (python git cl) do (
37+
where %%A >nul 2>&1 || (
38+
echo Error: Command "%%A" not found.
39+
exit /b 4
40+
)
41+
)
42+
43+
rem Save current directory path
44+
set "BASEFOLDER=%~dp0"
45+
cd "%BASEFOLDER%"
46+
47+
rem Be verbose now
48+
echo on
49+
50+
rem Install Python dependencies
51+
python -m pip install cmake astunparse numpy ninja pyyaml mkl-static mkl-include setuptools cffi typing_extensions future six requests dataclasses Pillow
52+
53+
rem Checkout individual components
54+
if NOT EXIST pytorch (
55+
git clone https://github.com/pytorch/pytorch.git
56+
)
57+
58+
if NOT EXIST vision (
59+
git clone https://github.com/pytorch/vision.git
60+
)
61+
62+
if NOT EXIST intel-extension-for-pytorch (
63+
git clone https://github.com/intel/intel-extension-for-pytorch.git
64+
)
65+
66+
rem Checkout required branch/commit and update submodules
67+
cd pytorch
68+
if not "%VER_PYTORCH%"=="" (
69+
git checkout %VER_PYTORCH%
70+
)
71+
git submodule sync
72+
git submodule update --init --recursive
73+
cd ..
74+
75+
cd vision
76+
if not "%VER_TORCHVISION%"=="" (
77+
git checkout %VER_TORCHVISION%
78+
)
79+
git submodule sync
80+
git submodule update --init --recursive
81+
cd ..
82+
83+
cd intel-extension-for-pytorch
84+
if not "%VER_IPEX%"=="" (
85+
git checkout %VER_IPEX%
86+
)
87+
git submodule sync
88+
git submodule update --init --recursive
89+
90+
rem Compile individual component
91+
92+
rem PyTorch
93+
cd ..\pytorch
94+
git stash
95+
git clean -f
96+
for %%f in ("..\intel-extension-for-pytorch\torch_patches\*.patch") do git apply "%%f"
97+
rem Ensure cmake can find python packages when using conda or virtualenv
98+
if defined CONDA_PREFIX (
99+
set "CMAKE_PREFIX_PATH=%CONDA_PREFIX:~1,-1%"
100+
) else if defined VIRTUAL_ENV (
101+
set "CMAKE_PREFIX_PATH=%VIRTUAL_ENV:~1,-1%"
102+
)
103+
set "USE_STATIC_MKL=1"
104+
set "USE_NUMA=0"
105+
set "USE_CUDA=0"
106+
python setup.py clean
107+
python setup.py bdist_wheel
108+
set "USE_CUDA="
109+
set "USE_NUMA="
110+
set "USE_STATIC_MKL="
111+
set "CMAKE_PREFIX_PATH="
112+
python -m pip uninstall -y mkl-static mkl-include
113+
for %%f in ("dist\*.whl") do python -m pip install --force-reinstall --no-deps "%%f"
114+
115+
rem TorchVision
116+
cd ..\vision
117+
set "DISTUTILS_USE_SDK=1"
118+
python setup.py clean
119+
python setup.py bdist_wheel
120+
set "DISTUTILS_USE_SDK="
121+
for %%f in ("dist\*.whl") do python -m pip install --force-reinstall --no-deps "%%f"
122+
123+
rem Intel® Extension for PyTorch*
124+
cd ..\intel-extension-for-pytorch
125+
python -m pip install -r requirements.txt
126+
if NOT "%AOT%"=="" (
127+
set "USE_AOT_DEVLIST=%AOT%"
128+
)
129+
set "BUILD_WITH_CPU=0"
130+
set "USE_MULTI_CONTEXT=1"
131+
set "DISTUTILS_USE_SDK=1"
132+
set "CMAKE_CXX_COMPILER=icx"
133+
python setup.py clean
134+
python setup.py bdist_wheel
135+
set "CMAKE_CXX_COMPILER="
136+
set "DISTUTILS_USE_SDK="
137+
set "USE_MULTI_CONTEXT="
138+
set "BUILD_WITH_CPU="
139+
for %%f in ("dist\*.whl") do python -m pip install --force-reinstall --no-deps "%%f"
140+
141+
rem Sanity Test
142+
cd ..
143+
python -c "import torch; import torchvision; import intel_extension_for_pytorch as ipex; print(f'torch_version: {torch.__version__}'); print(f'torchvision_version: {torchvision.__version__}'); print(f'ipex_version: {ipex.__version__}');"

0 commit comments

Comments
 (0)