xref: /aosp_15_r20/external/pytorch/.ci/pytorch/win-test-helpers/setup_pytorch_env.bat (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1set PATH=C:\Program Files\CMake\bin;C:\Program Files\7-Zip;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\Amazon\AWSCLI;C:\Program Files\Amazon\AWSCLI\bin;%PATH%
2
3:: Install Miniconda3
4set INSTALLER_DIR=%SCRIPT_HELPERS_DIR%\installation-helpers
5
6:: Miniconda has been installed as part of the Windows AMI with all the dependencies.
7:: We just need to activate it here
8call %INSTALLER_DIR%\activate_miniconda3.bat
9if errorlevel 1 exit /b
10if not errorlevel 0 exit /b
11
12:: PyTorch is now installed using the standard wheel on Windows into the conda environment.
13:: However, the test scripts are still frequently referring to the workspace temp directory
14:: build\torch. Rather than changing all these references, making a copy of torch folder
15:: from conda to the current workspace is easier. The workspace will be cleaned up after
16:: the job anyway
17xcopy /s %CONDA_PARENT_DIR%\Miniconda3\Lib\site-packages\torch %TMP_DIR_WIN%\build\torch\
18
19pushd .
20if "%VC_VERSION%" == "" (
21    call "C:\Program Files (x86)\Microsoft Visual Studio\%VC_YEAR%\%VC_PRODUCT%\VC\Auxiliary\Build\vcvarsall.bat" x64
22) else (
23    call "C:\Program Files (x86)\Microsoft Visual Studio\%VC_YEAR%\%VC_PRODUCT%\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=%VC_VERSION%
24)
25if errorlevel 1 exit /b
26if not errorlevel 0 exit /b
27@echo on
28popd
29
30set DISTUTILS_USE_SDK=1
31
32if not "%USE_CUDA%"=="1" goto cuda_build_end
33
34set CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v%CUDA_VERSION%
35
36rem version transformer, for example 10.1 to 10_1.
37set VERSION_SUFFIX=%CUDA_VERSION:.=_%
38set CUDA_PATH_V%VERSION_SUFFIX%=%CUDA_PATH%
39
40set CUDNN_LIB_DIR=%CUDA_PATH%\lib\x64
41set CUDA_TOOLKIT_ROOT_DIR=%CUDA_PATH%
42set CUDNN_ROOT_DIR=%CUDA_PATH%
43set PATH=%CUDA_PATH%\bin;%CUDA_PATH%\libnvvp;%PATH%
44set NUMBAPRO_CUDALIB=%CUDA_PATH%\bin
45set NUMBAPRO_LIBDEVICE=%CUDA_PATH%\nvvm\libdevice
46set NUMBAPRO_NVVM=%CUDA_PATH%\nvvm\bin\nvvm64_32_0.dll
47
48:cuda_build_end
49
50set PYTHONPATH=%TMP_DIR_WIN%\build;%PYTHONPATH%
51
52:: Print all existing environment variable for debugging
53set
54