Skip to content

Commit

Permalink
Validate linux binaries change
Browse files Browse the repository at this point in the history
Add options

Import torchvision

Adding python 3.11 install

pass package to check nightly binaries date

Test

test

Add python 3.11 code

testing

Adding python 3.11 test

Add python 3.11 validation

Adding zlib develop install

Install zlib etc..

Adding zlib1g as well

testing

testing

Adding validate windows binary

Trying to workaround

testing

Refacor smoke test

Add import statement

fix datetime call
  • Loading branch information
atalman committed Oct 19, 2022
1 parent f3b676a commit 2067561
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 32 deletions.
35 changes: 24 additions & 11 deletions .github/actions/validate-binary/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ runs:
run: |
nvidia-smi
- name: Install Conda Linux
if: ${{ inputs.target_os == 'linux' }}
if: ${{ inputs.target_os == 'linux' && inputs.python_version != '3.11' }}
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ inputs.python_version }}
Expand All @@ -66,16 +66,29 @@ runs:
DESIRED_DEVTOOLSET: ${{ inputs.dev_toolset }}
PACKAGE_TYPE: ${{ inputs.package_type }}
run: |
set -ex
conda create -yp ${ENV_NAME} python=${{ inputs.python_version }} numpy
conda run -p ${ENV_NAME} $INSTALLATION
if [ $DESIRED_PYTHON == "3.11" ]; then
conda run -p ${ENV_NAME} python3 --package torchonly ./test/smoke_test/smoke_test.py
if [ $DESIRED_PYTHON == '3.11' ]; then
set -ex
export CPYTHON_VERSIONS=3.11.0
sudo apt-get install build-essential gdb lcov libbz2-dev libffi-dev \
libgdbm-dev liblzma-dev libncurses5-dev libreadline6-dev \
libsqlite3-dev libssl-dev lzma lzma-dev tk-dev uuid-dev zlib1g zlib1g-dev -y
export PYTHON_PATH="/opt/_internal/cpython-3.11.0rc2/bin/"
export PIP_PATH="${PYTHON_PATH}/pip"
export PIP_INSTALLATION="${INSTALLATION/pip3/"$PIP_PATH"}"
./common/install_cpython.sh
eval ${PYTHON_PATH}/python --version
eval ${PIP_INSTALLATION}
eval ${PYTHON_PATH}/python ./test/smoke_test/smoke_test.py --package torchonly
else
set -ex
conda create -yp ${ENV_NAME} python=${{ inputs.python_version }} numpy
conda run -p ${ENV_NAME} $INSTALLATION
conda run -p ${ENV_NAME} python3 ./test/smoke_test/smoke_test.py
export LD_LIBRARY_PATH="$(dirname $(which python))/lib"
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib
conda run -p ${ENV_NAME} env LD_LIBRARY_PATH=$LD_LIBRARY_PATH bash ${PWD}/check_binary.sh
conda env remove -p ${ENV_NAME}
fi
export LD_LIBRARY_PATH="$(dirname $(which python))/lib"
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib
conda run -p ${ENV_NAME} env LD_LIBRARY_PATH=$LD_LIBRARY_PATH bash ${PWD}/check_binary.sh
conda env remove -p ${ENV_NAME}
3 changes: 2 additions & 1 deletion .github/workflows/validate-linux-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
package-type: wheel
os: linux
channel: ${{ inputs.channel }}
with-py311: enable
generate-linux-libtorch-matrix:
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
with:
Expand Down Expand Up @@ -70,7 +71,7 @@ jobs:
- name: Checkout PyTorch builder
uses: actions/checkout@v2
- name: Validate binary wheel
uses: .github/actions/validate-binary
uses: ./.github/actions/validate-binary
with:
gpu_arch_type: ${{ matrix.gpu_arch_type }}
gpu_arch_ver: ${{ matrix.gpu_arch_version }}
Expand Down
39 changes: 19 additions & 20 deletions test/smoke_test/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import argparse
import torch



gpu_arch_ver = os.getenv("GPU_ARCH_VER")
gpu_arch_type = os.getenv("GPU_ARCH_TYPE")
# use installation env variable to tell if it is nightly channel
installation_str = os.getenv("INSTALLATION")
is_cuda_system = gpu_arch_type == "cuda"
SCRIPT_DIR = Path(__file__).parent
NIGHTLY_ALLOWED_DELTA = 3

# helper function to return the conda installed packages
# and return package we are insterseted in
Expand All @@ -35,32 +34,31 @@ def get_anaconda_output_for_package(pkg_name_str):


def check_nightly_binaries_date(package: str) -> None:
from datetime import datetime, timedelta
format_dt = '%Y%m%d'

torch_str = torch.__version__
date_t_str = re.findall("dev\d+", torch.__version__)
date_t_delta = datetime.now() - datetime.strptime(date_t_str.lstrip("dev"), format_dt)
if date_t_delta.days >= NIGHTLY_ALLOWED_DELTA:
raise RuntimeError(
f"the binaries are from {date_t_str} and are more than {NIGHTLY_ALLOWED_DELTA} days old!"
)

if(package == "all"):
ta_str = torchaudio.__version__
tv_str = torchvision.__version__
date_ta_str = re.findall("dev\d+", torchaudio.__version__)
date_tv_str = re.findall("dev\d+", torchvision.__version__)
date_ta_delta = datetime.now() - datetime.strptime(date_ta_str.lstrip("dev"), format_dt)
date_tv_delta = datetime.now() - datetime.strptime(date_tv_str.lstrip("dev"), format_dt)

# check that the above three lists are equal and none of them is empty
if not date_t_str or not date_t_str == date_ta_str == date_tv_str:
if date_ta_delta.days > NIGHTLY_ALLOWED_DELTA or date_tv_delta.days > NIGHTLY_ALLOWED_DELTA:
raise RuntimeError(
f"Expected torch, torchaudio, torchvision to be the same date. But they are from {date_t_str}, {date_ta_str}, {date_tv_str} respectively"
f"Expected torchaudio, torchvision to be less then {NIGHTLY_ALLOWED_DELTA} days. But they are from {date_ta_str}, {date_tv_str} respectively"
)

# check that the date is recent, at this point, date_torch_str is not empty
binary_date_str = date_t_str[0][3:]
from datetime import datetime

binary_date_obj = datetime.strptime(binary_date_str, "%Y%m%d").date()
today_obj = datetime.today().date()
delta = today_obj - binary_date_obj
if delta.days >= 2:
raise RuntimeError(
f"the binaries are from {binary_date_obj} and are more than 2 days old!"
)

def smoke_test_cuda(package: str) -> None:
if not torch.cuda.is_available() and is_cuda_system:
Expand All @@ -76,6 +74,8 @@ def smoke_test_cuda(package: str) -> None:
print(f"cuDNN enabled? {torch.backends.cudnn.enabled}")

if(package == 'all'):
import torchaudio
import torchvision
if installation_str.find("nightly") != -1:
# just print out cuda version, as version check were already performed during import
print(f"torchvision cuda: {torch.ops.torchvision._cuda_version()}")
Expand Down Expand Up @@ -165,6 +165,7 @@ def smoke_test_torchvision_resnet50_classify(device: str = "cpu") -> None:


def smoke_test_torchaudio() -> None:
import torchaudio
import torchaudio.compliance.kaldi # noqa: F401
import torchaudio.datasets # noqa: F401
import torchaudio.functional # noqa: F401
Expand All @@ -184,20 +185,18 @@ def main() -> None:
choices=["all", "torchonly"],
default="all",
)

options = parser.parse_args()
print(f"torch: {torch.__version__}")

smoke_test_cuda(options.package)
smoke_test_conv2d()

# only makes sense to check nightly package where dates are known
if installation_str.find("nightly") != -1:
check_nightly_binaries_date()
check_nightly_binaries_date(options.package)

if options.package == "all":
import torchaudio
# the following import would invoke
# _check_cuda_version()
# via torchvision.extension._check_cuda_version()
import torchvision
print(f"torchvision: {torchvision.__version__}")
print(f"torchaudio: {torchaudio.__version__}")
Expand Down

0 comments on commit 2067561

Please sign in to comment.