From 232e4a7e3d73abdc3dee55ff79a29ed134afc557 Mon Sep 17 00:00:00 2001 From: Jeremy Reizenstein Date: Sat, 25 Apr 2020 16:01:41 -0700 Subject: [PATCH] Driver update for ci, easier diagnosing Summary: Bump the nvidia driver used in the conda tests. Add an environment variable (unused) to allow building without ninja. Print relative error on assertClose failure. Reviewed By: nikhilaravi Differential Revision: D21227373 fbshipit-source-id: 5dd8eb097151da27d3632daa755a1e7b9ac97845 --- .circleci/config.in.yml | 2 +- .circleci/config.yml | 2 +- pytorch3d/io/mtl_io.py | 2 +- setup.py | 14 +++++++++++++- tests/common_testing.py | 16 ++++++++++++++-- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.circleci/config.in.yml b/.circleci/config.in.yml index 5cc750d1..21be6e17 100644 --- a/.circleci/config.in.yml +++ b/.circleci/config.in.yml @@ -157,7 +157,7 @@ jobs: sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit=${NVIDIA_CONTAINER_VERSION} sudo systemctl restart docker - DRIVER_FN="NVIDIA-Linux-x86_64-410.104.run" + DRIVER_FN="NVIDIA-Linux-x86_64-440.59.run" wget "https://s3.amazonaws.com/ossci-linux/nvidia_driver/$DRIVER_FN" sudo /bin/bash "$DRIVER_FN" -s --no-drm || (sudo cat /var/log/nvidia-installer.log && false) nvidia-smi diff --git a/.circleci/config.yml b/.circleci/config.yml index fbe94001..2bb1e617 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -157,7 +157,7 @@ jobs: sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit=${NVIDIA_CONTAINER_VERSION} sudo systemctl restart docker - DRIVER_FN="NVIDIA-Linux-x86_64-410.104.run" + DRIVER_FN="NVIDIA-Linux-x86_64-440.59.run" wget "https://s3.amazonaws.com/ossci-linux/nvidia_driver/$DRIVER_FN" sudo /bin/bash "$DRIVER_FN" -s --no-drm || (sudo cat /var/log/nvidia-installer.log && false) nvidia-smi diff --git a/pytorch3d/io/mtl_io.py b/pytorch3d/io/mtl_io.py index 663ae276..ba0d53c9 100644 --- a/pytorch3d/io/mtl_io.py +++ b/pytorch3d/io/mtl_io.py @@ -62,7 +62,7 @@ def make_mesh_texture_atlas( # the convention GL_REPEAT in OpenGL i.e the integer part of the coordinate # will be ignored and a repeating pattern is formed. # Shapenet data uses this format see: - # https://shapenet.org/qaforum/index.php?qa=15&qa_1=why-is-the-texture-coordinate-in-the-obj-file-not-in-the-range + # https://shapenet.org/qaforum/index.php?qa=15&qa_1=why-is-the-texture-coordinate-in-the-obj-file-not-in-the-range # noqa: B950 if (faces_verts_uvs > 1).any() or (faces_verts_uvs < 0).any(): msg = "Texture UV coordinates outside the range [0, 1]. \ The integer part will be ignored to form a repeating pattern." diff --git a/setup.py b/setup.py index bf25bede..35895f21 100755 --- a/setup.py +++ b/setup.py @@ -72,6 +72,18 @@ __version__ = "" with open("pytorch3d/__init__.py", "r") as init: exec(init.read()) + +if os.getenv("PYTORCH3D_NO_NINJA", "0") == "1": + + class BuildExtension(torch.utils.cpp_extension.BuildExtension): + def __init__(self, *args, **kwargs): + super().__init__(use_ninja=False, *args, **kwargs) + + +else: + BuildExtension = torch.utils.cpp_extension.BuildExtension + + setup( name="pytorch3d", version=__version__, @@ -86,5 +98,5 @@ setup( "dev": ["flake8", "isort", "black==19.3b0"], }, ext_modules=get_extensions(), - cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension}, + cmdclass={"build_ext": BuildExtension}, ) diff --git a/tests/common_testing.py b/tests/common_testing.py index ddf1fc3d..27eafc2c 100644 --- a/tests/common_testing.py +++ b/tests/common_testing.py @@ -138,7 +138,19 @@ class TestCaseMixin(unittest.TestCase): ) if not close and msg is None: - max_diff = backend.abs(input - other).max() - self.fail(f"Not close. max diff {max_diff}.") + diff = backend.abs(input - other) + 0.0 + ratio = diff / backend.abs(other) + try_relative = (diff <= atol) | (backend.isfinite(ratio) & (ratio > 0)) + if try_relative.all(): + if backend == np: + # Avoid a weirdness with zero dimensional arrays. + ratio = np.array(ratio) + ratio[diff <= atol] = 0 + extra = f" Max relative diff {ratio.max()}" + else: + extra = "" + shape = tuple(input.shape) + max_diff = diff.max() + self.fail(f"Not close. Max diff {max_diff}.{extra} Shape {shape}.") self.assertTrue(close, msg)