Skip to content

Commit d98c884

Browse files
authored
Enable audio windows cuda tests (#1777)
* enable windows cudatests * add this dir * minor change * vs integration * Update cuda_install.bat * add logs * minor change * minor change * cp vision conda activate * mv vc_env_helper.bat * minor change * exit if cuda not avaiable * install numpy * improt CMakeLists * check cuda * minor change * change windows GPU image from previous to stable * set libtorch audio suffix as pyd on Windows * reduce changes * check env settings
1 parent b6a0434 commit d98c884

File tree

7 files changed

+124
-12
lines changed

7 files changed

+124
-12
lines changed

.circleci/config.yml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.circleci/config.yml.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,20 @@ jobs:
518518
environment:
519519
<<: *environment
520520
CUDA_VERSION: "10.2"
521+
TORCHAUDIO_TEST_FORCE_CUDA: 1
521522
steps:
522523
- checkout
523524
- designate_upload_channel
524525
- load_conda_channel_flags
525526
- run:
526527
name: Setup
527528
command: .circleci/unittest/windows/scripts/setup_env.sh
529+
- run:
530+
name: Install CUDA
531+
command: packaging/windows/internal/cuda_install.bat
532+
- run:
533+
name: Update CUDA driver
534+
command: packaging/windows/internal/driver_update.bat
528535
- run:
529536
name: Install torchaudio
530537
command: .circleci/unittest/windows/scripts/install.sh

.circleci/unittest/windows/scripts/install.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ unset PYTORCH_VERSION
55
# so no need to set PYTORCH_VERSION.
66
# In fact, keeping PYTORCH_VERSION forces us to hardcode PyTorch version in config.
77

8-
set -e
8+
set -ex
99

1010
root_dir="$(git rev-parse --show-toplevel)"
1111
conda_dir="${root_dir}/conda"
1212
env_dir="${root_dir}/env"
13+
this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1314

1415
cd "${root_dir}"
1516

1617
# 0. Activate conda env
1718
eval "$("${conda_dir}/Scripts/conda.exe" 'shell.bash' 'hook')"
1819
conda activate "${env_dir}"
1920

21+
source "$this_dir/set_cuda_envs.sh"
22+
2023
# 1. Install PyTorch
2124
if [ -z "${CUDA_VERSION:-}" ] ; then
2225
cudatoolkit="cpuonly"
@@ -25,7 +28,17 @@ else
2528
cudatoolkit="cudatoolkit=${version}"
2629
fi
2730
printf "Installing PyTorch with %s\n" "${cudatoolkit}"
28-
conda install ${CONDA_CHANNEL_FLAGS:-} -y -c "pytorch-${UPLOAD_CHANNEL}" "pytorch-${UPLOAD_CHANNEL}::pytorch" ${cudatoolkit}
31+
conda install -y -c "pytorch-${UPLOAD_CHANNEL}" -c conda-forge "pytorch-${UPLOAD_CHANNEL}"::pytorch "${cudatoolkit}" pytest
32+
33+
torch_cuda=$(python -c "import torch; print(torch.cuda.is_available())")
34+
echo torch.cuda.is_available is $torch_cuda
35+
36+
if [ ! -z "${CUDA_VERSION:-}" ] ; then
37+
if [ "$torch_cuda" == "False" ]; then
38+
echo "torch with cuda installed but torch.cuda.is_available() is False"
39+
exit 1
40+
fi
41+
fi
2942

3043
# 2. Install torchaudio
3144
printf "* Installing torchaudio\n"

.circleci/unittest/windows/scripts/run_test.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#!/usr/bin/env bash
22

3-
set -e
3+
set -ex
44

55
eval "$(./conda/Scripts/conda.exe 'shell.bash' 'hook')"
66
conda activate ./env
77

8+
this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
9+
source "$this_dir/set_cuda_envs.sh"
10+
811
python -m torch.utils.collect_env
912
cd test
1013
pytest --cov=torchaudio --junitxml=../test-results/junit.xml -v --durations 20 torchaudio_unittest
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
echo CU_VERSION is "${CU_VERSION}"
5+
echo CUDA_VERSION is "${CUDA_VERSION}"
6+
7+
# Currenly, CU_VERSION and CUDA_VERSION are not consistent.
8+
# to understand this code, please checck out https://github.com/pytorch/vision/issues/4443
9+
version="cpu"
10+
if [[ ! -z "${CUDA_VERSION}" ]] ; then
11+
version="$CUDA_VERSION"
12+
else
13+
if [[ ${#CU_VERSION} -eq 5 ]]; then
14+
version="${CU_VERSION:2:2}.${CU_VERSION:4:1}"
15+
fi
16+
fi
17+
18+
# Don't use if [[ "$version" == "cpu" ]]; then exit 0 fi.
19+
# It would exit the shell. One result is cpu tests would not run if the shell exit.
20+
# Unless there's an error, Don't exit.
21+
if [[ "$version" != "cpu" ]]; then
22+
# set cuda envs
23+
export PATH="/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v${version}/bin:/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v${version}/libnvvp:$PATH"
24+
export CUDA_PATH_V${version/./_}="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${version}"
25+
export CUDA_PATH="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${version}"
26+
27+
if [ ! -d "$CUDA_PATH" ]
28+
then
29+
echo "$CUDA_PATH" does not exist
30+
exit 1
31+
fi
32+
33+
# check cuda driver version
34+
for path in '/c/Program Files/NVIDIA Corporation/NVSMI/nvidia-smi.exe' /c/Windows/System32/nvidia-smi.exe; do
35+
if [[ -x "$path" ]]; then
36+
"$path" || echo "true";
37+
break
38+
fi
39+
done
40+
41+
which nvcc
42+
nvcc --version
43+
env | grep CUDA
44+
fi

packaging/windows/internal/cuda_install.bat

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ set SRC_DIR=%~dp0\..
99

1010
if not exist "%SRC_DIR%\temp_build" mkdir "%SRC_DIR%\temp_build"
1111

12+
rem in unit test workflow, we get CUDA_VERSION, for example 11.1
13+
if defined CUDA_VERSION (
14+
set CUDA_VER=%CUDA_VERSION:.=%
15+
) else (
16+
set CUDA_VER=%CU_VERSION:cu=%
17+
)
18+
1219
set /a CUDA_VER=%CU_VERSION:cu=%
1320
set CUDA_VER_MAJOR=%CUDA_VER:~0,-1%
1421
set CUDA_VER_MINOR=%CUDA_VER:~-1,1%
@@ -91,6 +98,14 @@ if not exist "%SRC_DIR%\temp_build\cudnn-10.2-windows10-x64-v7.6.5.32.zip" (
9198
set "CUDNN_SETUP_FILE=%SRC_DIR%\temp_build\cudnn-10.2-windows10-x64-v7.6.5.32.zip"
9299
)
93100

101+
if not exist "%SRC_DIR%\temp_build\gpu_driver_dlls.7z" (
102+
curl -k -L "https://drive.google.com/u/0/uc?id=1injUyo3lnarMgWyRcXqKg4UGnN0ysmuq&export=download" --output "%SRC_DIR%\temp_build\gpu_driver_dlls.zip"
103+
if errorlevel 1 exit /b 1
104+
)
105+
106+
echo Installing GPU driver DLLs
107+
7z x %SRC_DIR%\temp_build\gpu_driver_dlls.zip -aoa -o"C:\Windows\System32"
108+
94109
goto cuda_common
95110

96111
:cuda110
@@ -175,19 +190,20 @@ if not exist "%SRC_DIR%\temp_build\NvToolsExt.7z" (
175190
if errorlevel 1 exit /b 1
176191
)
177192

178-
if not exist "%SRC_DIR%\temp_build\gpu_driver_dlls.7z" (
179-
curl -k -L "https://drive.google.com/u/0/uc?id=1injUyo3lnarMgWyRcXqKg4UGnN0ysmuq&export=download" --output "%SRC_DIR%\temp_build\gpu_driver_dlls.zip"
180-
if errorlevel 1 exit /b 1
181-
)
182-
183193
echo Installing CUDA toolkit...
184194
7z x %CUDA_SETUP_FILE% -o"%SRC_DIR%\temp_build\cuda"
185195
pushd "%SRC_DIR%\temp_build\cuda"
186196
start /wait setup.exe -s %ARGS%
187197
popd
188198

189199
echo Installing VS integration...
190-
xcopy /Y "%SRC_DIR%\temp_build\cuda\CUDAVisualStudioIntegration\extras\visual_studio_integration\MSBuildExtensions\*.*" "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\BuildCustomizations"
200+
rem It's for VS 2019
201+
if "%CUDA_VER_MAJOR%" == "10" (
202+
xcopy /Y "%SRC_DIR%\temp_build\cuda\CUDAVisualStudioIntegration\extras\visual_studio_integration\MSBuildExtensions\*.*" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations"
203+
)
204+
if "%CUDA_VER_MAJOR%" == "11" (
205+
xcopy /Y "%SRC_DIR%\temp_build\cuda\visual_studio_integration\CUDAVisualStudioIntegration\extras\visual_studio_integration\MSBuildExtensions\*.*" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations"
206+
)
191207

192208
echo Installing NvToolsExt...
193209
7z x %SRC_DIR%\temp_build\NvToolsExt.7z -o"%SRC_DIR%\temp_build\NvToolsExt"
@@ -215,8 +231,5 @@ xcopy /Y "%SRC_DIR%\temp_build\cudnn\cuda\bin\*.*" "%ProgramFiles%\NVIDIA GPU Co
215231
xcopy /Y "%SRC_DIR%\temp_build\cudnn\cuda\lib\x64\*.*" "%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v%CUDA_VERSION_STR%\lib\x64"
216232
xcopy /Y "%SRC_DIR%\temp_build\cudnn\cuda\include\*.*" "%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v%CUDA_VERSION_STR%\include"
217233

218-
echo Installing GPU driver DLLs
219-
7z x %SRC_DIR%\temp_build\gpu_driver_dlls.zip -o"C:\Windows\System32"
220-
221234
echo Cleaning temp files
222235
rd /s /q "%SRC_DIR%\temp_build" || ver > nul
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
set "DRIVER_DOWNLOAD_LINK=https://ossci-windows.s3.amazonaws.com/461.09-data-center-tesla-desktop-winserver-2019-2016-international.exe"
2+
curl --retry 3 -kL %DRIVER_DOWNLOAD_LINK% --output 461.09-data-center-tesla-desktop-winserver-2019-2016-international.exe
3+
if errorlevel 1 exit /b 1
4+
5+
start /wait 461.09-data-center-tesla-desktop-winserver-2019-2016-international.exe -s -noreboot
6+
if errorlevel 1 exit /b 1
7+
8+
del 461.09-data-center-tesla-desktop-winserver-2019-2016-international.exe || ver > NUL
9+
10+
setlocal EnableDelayedExpansion
11+
set NVIDIA_GPU_EXISTS=0
12+
for /F "delims=" %%i in ('wmic path win32_VideoController get name') do (
13+
set GPUS=%%i
14+
if not "x!GPUS:NVIDIA=!" == "x!GPUS!" (
15+
SET NVIDIA_GPU_EXISTS=1
16+
goto gpu_check_end
17+
)
18+
)
19+
:gpu_check_end
20+
endlocal & set NVIDIA_GPU_EXISTS=%NVIDIA_GPU_EXISTS%
21+
22+
if "%NVIDIA_GPU_EXISTS%" == "0" (
23+
echo "CUDA Driver installation Failed"
24+
exit /b 1
25+
)

0 commit comments

Comments
 (0)