test.bat 1.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
@echo off

set SRC_DIR=%~dp0\..
pushd %SRC_DIR%

set PYTHON_VERSION=%PYTHON_PREFIX:py=cp%

if "%BUILD_VISION%" == "" (
    pip install future pytest coverage hypothesis protobuf
) ELSE (
Philip Meier's avatar
Philip Meier committed
11
    pip install future pytest "pillow>=4.1.1"
12
13
)

14
for /F "delims=" %%i in ('where /R %SRC_DIR%\output *%MODULE_NAME%*%PYTHON_VERSION%*.whl') do pip install "%%i"
15
16
17

if ERRORLEVEL 1 exit /b 1

peterjc123's avatar
peterjc123 committed
18
19
20
21
22
23
if NOT "%BUILD_VISION%" == "" (
    echo Smoke testing imports
    python -c "import torchvision"
    if ERRORLEVEL 1 exit /b 1
    goto smoke_test_end
)
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

echo Smoke testing imports
python -c "import torch"
if ERRORLEVEL 1 exit /b 1

python -c "from caffe2.python import core"
if ERRORLEVEL 1 exit /b 1

echo Checking that MKL is available
python -c "import torch; exit(0 if torch.backends.mkl.is_available() else 1)"
if ERRORLEVEL 1 exit /b 1

setlocal EnableDelayedExpansion
set NVIDIA_GPU_EXISTS=0
for /F "delims=" %%i in ('wmic path win32_VideoController get name') do (
    set GPUS=%%i
    if not "x!GPUS:NVIDIA=!" == "x!GPUS!" (
        SET NVIDIA_GPU_EXISTS=1
        goto gpu_check_end
    )
)
:gpu_check_end
endlocal & set NVIDIA_GPU_EXISTS=%NVIDIA_GPU_EXISTS%

if NOT "%CUDA_PREFIX%" == "cpu" if "%NVIDIA_GPU_EXISTS%" == "1" (
    echo Checking that CUDA archs are setup correctly
    python -c "import torch; torch.randn([3,5]).cuda()"
    if ERRORLEVEL 1 exit /b 1

    echo Checking that magma is available
    python -c "import torch; torch.rand(1).cuda(); exit(0 if torch.cuda.has_magma else 1)"
    if ERRORLEVEL 1 exit /b 1

    echo Checking that CuDNN is available
    python -c "import torch; exit(0 if torch.backends.cudnn.is_available() else 1)"
    if ERRORLEVEL 1 exit /b 1
)
:smoke_test_end

echo Not running unit tests. Hopefully these problems are caught by CI
goto test_end

if "%BUILD_VISION%" == "" (
    cd pytorch\test
    python run_test.py -v
) else (
    cd vision
    pytest .
)

if ERRORLEVEL 1 exit /b 1

:test_end

popd
exit /b 0