Skip to content

Commit 8cae5af

Browse files
committed
Fix cuda version check
Fix Audio and Vision version check Add check binary to libtorch test test testing testing testing Testing Testing testing
1 parent 0b8c2f3 commit 8cae5af

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

.github/workflows/validate-linux-binaries.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,19 @@ jobs:
5858
export CUDA_VER="${{ matrix.desired_cuda }}"
5959
export DESIRED_PYTHON="${{ matrix.python_version }}"
6060
export DESIRED_CUDA="${{ matrix.desired_cuda }}"
61-
export DESIRED_DEVTOOLSET="${{ matrix.dev_toolset }}"
61+
export DESIRED_DEVTOOLSET="${{ matrix.devtoolset }}"
6262
export PACKAGE_TYPE="${{ matrix.package_type }}"
6363
export TARGET_OS="linux"
64+
conda create -y -n ${ENV_NAME} python=${{ matrix.python_version }} numpy pillow
65+
conda activate ${ENV_NAME}
66+
export CONDA_LIBRARY_PATH="$(dirname $(which python))/../lib"
67+
export LD_LIBRARY_PATH=$CONDA_LIBRARY_PATH:$LD_LIBRARY_PATH
6468
6569
if [[ ${{ matrix.package_type }} == "libtorch" ]]; then
6670
curl ${{ matrix.installation }} -o libtorch.zip
6771
unzip libtorch.zip
6872
else
69-
conda create -y -n ${ENV_NAME} python=${{ matrix.python_version }} numpy pillow
70-
conda activate ${ENV_NAME}
7173
eval $INSTALLATION
72-
export CONDA_LIBRARY_PATH="$(dirname $(which python))/../lib"
73-
export LD_LIBRARY_PATH=$CONDA_LIBRARY_PATH:$LD_LIBRARY_PATH
74-
75-
python --version
7674
python ./test/smoke_test/smoke_test.py
77-
7875
${PWD}/check_binary.sh
7976
fi

test/smoke_test/smoke_test.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ def check_nightly_binaries_date(package: str) -> None:
4242
f"Expected torchaudio, torchvision to be less then {NIGHTLY_ALLOWED_DELTA} days. But they are from {date_ta_str}, {date_tv_str} respectively"
4343
)
4444

45+
def check_cuda_version(version: str, dlibary: str):
46+
version = torch.ops.torchaudio.cuda_version()
47+
if version is not None and torch.version.cuda is not None:
48+
version_str = str(version)
49+
ta_version = f"{version_str[:-3]}.{version_str[-2]}"
50+
t_version = torch.version.cuda.split(".")
51+
t_version = f"{t_version[0]}.{t_version[1]}"
52+
if ta_version != t_version:
53+
raise RuntimeError(
54+
"Detected that PyTorch and {dlibary} were compiled with different CUDA versions. "
55+
f"PyTorch has CUDA version {t_version} whereas {dlibary} has CUDA version {ta_version}. "
56+
)
4557

4658
def smoke_test_cuda(package: str) -> None:
4759
if not torch.cuda.is_available() and is_cuda_system:
@@ -56,20 +68,14 @@ def smoke_test_cuda(package: str) -> None:
5668
print(f"torch cudnn: {torch.backends.cudnn.version()}")
5769
print(f"cuDNN enabled? {torch.backends.cudnn.enabled}")
5870

59-
if(package == 'all'):
71+
if(package == 'all' and is_cuda_system):
6072
import torchaudio
6173
import torchvision
62-
6374
print(f"torchvision cuda: {torch.ops.torchvision._cuda_version()}")
6475
print(f"torchaudio cuda: {torch.ops.torchaudio.cuda_version()}")
65-
if (
66-
gpu_arch_ver != torch.ops.torchvision._cuda_version() or
67-
gpu_arch_ver != torch.ops.torchaudio.cuda_version()
68-
):
69-
raise RuntimeError(
70-
f"Wrong CUDA version. Vision: {torch.ops.torchvision._cuda_version()} \
71-
Audio: {ttorch.ops.torchaudio.cuda_version()} Expected: {gpu_arch_ver}"
72-
)
76+
check_cuda_version(torch.ops.torchvision._cuda_version(), "TorchVision")
77+
check_cuda_version(torch.ops.torchaudio.cuda_version(), "TorchAudio")
78+
7379

7480
def smoke_test_conv2d() -> None:
7581
import torch.nn as nn

0 commit comments

Comments
 (0)