From 015b8917b98c8c374ec384dc9bc2ed7157c832d8 Mon Sep 17 00:00:00 2001 From: Yerdos Ordabayev Date: Fri, 10 May 2024 13:46:52 +0000 Subject: [PATCH 1/6] remove mypy ignore distributions --- pyro/distributions/coalescent.py | 2 +- pyro/distributions/conditional.py | 4 +-- pyro/distributions/constraints.py | 6 ++-- pyro/distributions/distribution.py | 8 +++-- pyro/distributions/hmm.py | 1 - pyro/distributions/kl.py | 3 +- pyro/distributions/nanmasked.py | 4 +-- pyro/distributions/projected_normal.py | 5 +++- pyro/distributions/torch.py | 36 +++++++++++++++++++++-- pyro/distributions/torch_distribution.py | 2 +- pyro/distributions/torch_patch.py | 3 +- pyro/distributions/torch_transform.py | 2 +- pyro/distributions/transforms/__init__.py | 2 +- pyro/distributions/transforms/cholesky.py | 7 ++--- setup.cfg | 4 --- 15 files changed, 62 insertions(+), 27 deletions(-) diff --git a/pyro/distributions/coalescent.py b/pyro/distributions/coalescent.py index 291e87b96f..6dd8f2f8c1 100644 --- a/pyro/distributions/coalescent.py +++ b/pyro/distributions/coalescent.py @@ -249,7 +249,7 @@ class CoalescentRateLikelihood: def __init__(self, leaf_times, coal_times, duration, *, validate_args=None): assert leaf_times.size(-1) == 1 + coal_times.size(-1) assert isinstance(duration, int) and duration >= 2 - if validate_args is True or validate_args is None and is_validation_enabled: + if validate_args is True or validate_args is None and is_validation_enabled(): constraint = CoalescentTimesConstraint(leaf_times, ordered=False) if not constraint.check(coal_times).all(): raise ValueError("Invalid (leaf_times, coal_times)") diff --git a/pyro/distributions/conditional.py b/pyro/distributions/conditional.py index bc3548ed99..23240a9449 100644 --- a/pyro/distributions/conditional.py +++ b/pyro/distributions/conditional.py @@ -43,12 +43,12 @@ def inv(self) -> "ConditionalTransformModule": class _ConditionalInverseTransformModule(ConditionalTransformModule): - def __init__(self, transform: ConditionalTransform): + def __init__(self, transform: ConditionalTransformModule): super().__init__() self._transform = transform @property - def inv(self) -> ConditionalTransform: + def inv(self) -> ConditionalTransformModule: return self._transform def condition(self, context: torch.Tensor): diff --git a/pyro/distributions/constraints.py b/pyro/distributions/constraints.py index 0ce8fd8cdf..f726b62a7b 100644 --- a/pyro/distributions/constraints.py +++ b/pyro/distributions/constraints.py @@ -8,6 +8,8 @@ try: from torch.distributions.constraints import ( Constraint, + _GreaterThan, + _LowerCholesky, boolean, cat, corr_cholesky, @@ -122,12 +124,12 @@ def check(self, value): return ordered_vector.check(value) & independent(positive, 1).check(value) -class _SoftplusPositive(type(positive)): +class _SoftplusPositive(_GreaterThan): def __init__(self): super().__init__(lower_bound=0.0) -class _SoftplusLowerCholesky(type(lower_cholesky)): +class _SoftplusLowerCholesky(_LowerCholesky): pass diff --git a/pyro/distributions/distribution.py b/pyro/distributions/distribution.py index ecac30645e..bdf73d272f 100644 --- a/pyro/distributions/distribution.py +++ b/pyro/distributions/distribution.py @@ -4,12 +4,13 @@ import functools import inspect from abc import ABCMeta, abstractmethod +from typing import Any, Callable, List import torch from pyro.distributions.score_parts import ScoreParts -COERCIONS = [] +COERCIONS: List = [] class DistributionMeta(ABCMeta): @@ -51,6 +52,7 @@ class Distribution(metaclass=DistributionMeta): has_rsample = False has_enumerate_support = False + rsample: Callable[..., torch.Tensor] def __call__(self, *args, **kwargs): """ @@ -65,7 +67,7 @@ def __call__(self, *args, **kwargs): return self.sample(*args, **kwargs) @abstractmethod - def sample(self, *args, **kwargs): + def sample(self, *args, **kwargs) -> torch.Tensor: """ Samples a random value. @@ -82,7 +84,7 @@ def sample(self, *args, **kwargs): raise NotImplementedError @abstractmethod - def log_prob(self, x, *args, **kwargs): + def log_prob(self, *args: Any, **kwargs: Any) -> torch.Tensor: """ Evaluates log probability densities for each of a batch of samples. diff --git a/pyro/distributions/hmm.py b/pyro/distributions/hmm.py index 9e5d714aa4..94626ac6d4 100644 --- a/pyro/distributions/hmm.py +++ b/pyro/distributions/hmm.py @@ -1005,7 +1005,6 @@ class LinearHMM(HiddenMarkovModel): """ arg_constraints = {} - support = constraints.independent(constraints.real, 2) has_rsample = True def __init__( diff --git a/pyro/distributions/kl.py b/pyro/distributions/kl.py index f88a0019d7..8414c9eb25 100644 --- a/pyro/distributions/kl.py +++ b/pyro/distributions/kl.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 import math +from typing import List from torch.distributions import ( Independent, @@ -53,4 +54,4 @@ def _kl_independent_mvn(p, q): raise NotImplementedError -__all__ = [] +__all__: List[str] = [] diff --git a/pyro/distributions/nanmasked.py b/pyro/distributions/nanmasked.py index 1166ec4c9c..ebd5b7b9b9 100644 --- a/pyro/distributions/nanmasked.py +++ b/pyro/distributions/nanmasked.py @@ -24,7 +24,7 @@ class NanMaskedNormal(Normal): def log_prob(self, value: torch.Tensor) -> torch.Tensor: ok = value.isfinite() if ok.all(): - return super().log_prob(value) + return super().log_prob(value) # type: ignore[no-any-return] # Broadcast all tensors. value, ok, loc, scale = torch.broadcast_tensors(value, ok, self.loc, self.scale) @@ -65,7 +65,7 @@ class NanMaskedMultivariateNormal(MultivariateNormal): def log_prob(self, value: torch.Tensor) -> torch.Tensor: ok = value.isfinite() if ok.all(): - return super().log_prob(value) + return super().log_prob(value) # type: ignore[no-any-return] # Broadcast all tensors. This might waste some computation by eagerly # broadcasting, but the optimal implementation is quite complex. diff --git a/pyro/distributions/projected_normal.py b/pyro/distributions/projected_normal.py index fcd4c29212..51cf87d050 100644 --- a/pyro/distributions/projected_normal.py +++ b/pyro/distributions/projected_normal.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 import math +from typing import Callable, Dict import torch @@ -51,7 +52,9 @@ def model(): arg_constraints = {"concentration": constraints.real_vector} support = constraints.sphere has_rsample = True - _log_prob_impls = {} # maps dim -> function(concentration, value) + _log_prob_impls: Dict[int, Callable] = ( + {} + ) # maps dim -> function(concentration, value) def __init__(self, concentration, *, validate_args=None): assert concentration.dim() >= 1 diff --git a/pyro/distributions/torch.py b/pyro/distributions/torch.py index 2f3f255d97..6a390459d6 100644 --- a/pyro/distributions/torch.py +++ b/pyro/distributions/torch.py @@ -14,6 +14,38 @@ from .. import settings from . import constraints +# Additionally try to import explicitly to help mypy static analysis. +try: + from torch.distributions import ( + Bernoulli, + Cauchy, + Chi2, + ContinuousBernoulli, + Exponential, + ExponentialFamily, + FisherSnedecor, + Gumbel, + HalfCauchy, + HalfNormal, + Kumaraswamy, + Laplace, + LKJCholesky, + LogisticNormal, + MixtureSameFamily, + NegativeBinomial, + OneHotCategoricalStraightThrough, + Pareto, + RelaxedBernoulli, + RelaxedOneHotCategorical, + StudentT, + TransformedDistribution, + VonMises, + Weibull, + Wishart, + ) +except ImportError: + pass + def _clamp_by_zero(x): # works like clamp(x, min=0) but has grad at 0 is 0.5 @@ -202,7 +234,7 @@ def log_prob(self, value): return (-value - 1) * torch.nn.functional.softplus(self.logits) + self.logits -class LogNormal(torch.distributions.LogNormal, TorchDistributionMixin): +class LogNormal(torch.distributions.LogNormal, TorchDistributionMixin): # type: ignore def __init__(self, loc, scale, validate_args=None): base_dist = Normal(loc, scale) # This differs from torch.distributions.LogNormal only in that base_dist is @@ -294,7 +326,7 @@ def log_prob(self, value): ) -class Independent(torch.distributions.Independent, TorchDistributionMixin): +class Independent(torch.distributions.Independent, TorchDistributionMixin): # type: ignore @staticmethod def infer_shapes(**kwargs): raise NotImplementedError diff --git a/pyro/distributions/torch_distribution.py b/pyro/distributions/torch_distribution.py index ace02da72a..7a287c4f2e 100644 --- a/pyro/distributions/torch_distribution.py +++ b/pyro/distributions/torch_distribution.py @@ -16,7 +16,7 @@ from .util import broadcast_shape, scale_and_mask -class TorchDistributionMixin(Distribution, Callable): +class TorchDistributionMixin(Distribution, Callable): # type: ignore[misc] """ Mixin to provide Pyro compatibility for PyTorch distributions. diff --git a/pyro/distributions/torch_patch.py b/pyro/distributions/torch_patch.py index 3a93d72780..c643976987 100644 --- a/pyro/distributions/torch_patch.py +++ b/pyro/distributions/torch_patch.py @@ -5,6 +5,7 @@ import math import warnings import weakref +from typing import List import torch @@ -92,4 +93,4 @@ def _lazy_property__call__(self): raise NotImplementedError -__all__ = [] +__all__: List[str] = [] diff --git a/pyro/distributions/torch_transform.py b/pyro/distributions/torch_transform.py index eedd8f5936..5590bcd83e 100644 --- a/pyro/distributions/torch_transform.py +++ b/pyro/distributions/torch_transform.py @@ -34,7 +34,7 @@ def __init__(self, parts, cache_size=0): def __hash__(self): return super(torch.nn.Module, self).__hash__() - def with_cache(self, cache_size=1): + def with_cache(self, cache_size=1) -> "ComposeTransformModule": if cache_size == self._cache_size: return self return ComposeTransformModule(self.parts, cache_size=cache_size) diff --git a/pyro/distributions/transforms/__init__.py b/pyro/distributions/transforms/__init__.py index 8428ce1334..9a286630f9 100644 --- a/pyro/distributions/transforms/__init__.py +++ b/pyro/distributions/transforms/__init__.py @@ -92,7 +92,7 @@ from .power import PositivePowerTransform from .radial import ConditionalRadial, Radial, conditional_radial, radial from .simplex_to_ordered import SimplexToOrderedTransform -from .softplus import SoftplusLowerCholeskyTransform, SoftplusTransform +from .softplus import SoftplusLowerCholeskyTransform, SoftplusTransform # type: ignore[assignment] from .spline import ConditionalSpline, Spline, conditional_spline, spline from .spline_autoregressive import ( ConditionalSplineAutoregressive, diff --git a/pyro/distributions/transforms/cholesky.py b/pyro/distributions/transforms/cholesky.py index c174c40d4a..7f5d9e9c71 100644 --- a/pyro/distributions/transforms/cholesky.py +++ b/pyro/distributions/transforms/cholesky.py @@ -26,8 +26,8 @@ class CholeskyTransform(Transform): """ bijective = True - domain = constraints.positive_definite - codomain = constraints.lower_cholesky + domain: constraints.Constraint = constraints.positive_definite + codomain: constraints.Constraint = constraints.lower_cholesky def __eq__(self, other): return isinstance(other, CholeskyTransform) @@ -55,8 +55,7 @@ class CorrMatrixCholeskyTransform(CholeskyTransform): bijective = True domain = constraints.corr_matrix - # TODO: change corr_cholesky_constraint to corr_cholesky when the latter is availabler - codomain = constraints.corr_cholesky_constraint + codomain = constraints.corr_cholesky def __eq__(self, other): return isinstance(other, CorrMatrixCholeskyTransform) diff --git a/setup.cfg b/setup.cfg index 1da059e331..7756adacf1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,10 +40,6 @@ ignore_errors = True [mypy-pyro.contrib.*] ignore_errors = True -[mypy-pyro.distributions.*] -ignore_errors = True -warn_unused_ignores = True - [mypy-pyro.generic.*] ignore_errors = True warn_unused_ignores = True From badf3e381b743919f8c5f46df7bdec785a0658dc Mon Sep 17 00:00:00 2001 From: Yerdos Ordabayev Date: Fri, 2 Aug 2024 14:40:50 +0000 Subject: [PATCH 2/6] relax setuptools version --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04ec6f2a8b..509f8e6fef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' + python -m pip install --upgrade pip wheel setuptools pip install ruff black mypy nbstripout nbformat - name: Lint run: | @@ -51,7 +51,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build graphviz - python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' + python -m pip install --upgrade pip wheel setuptools # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu @@ -79,7 +79,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build graphviz pandoc - python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' + python -m pip install --upgrade pip wheel setuptools # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu @@ -113,7 +113,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build - python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' + python -m pip install --upgrade pip wheel setuptools # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu @@ -147,7 +147,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build - python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' + python -m pip install --upgrade pip wheel setuptools # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu @@ -181,7 +181,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build - python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' + python -m pip install --upgrade pip wheel setuptools # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu @@ -213,7 +213,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build - python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' + python -m pip install --upgrade pip wheel setuptools # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu @@ -245,7 +245,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build - python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' + python -m pip install --upgrade pip wheel setuptools # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu From d912807e2e9d38131236f57569739a9c64f269eb Mon Sep 17 00:00:00 2001 From: Yerdos Ordabayev Date: Fri, 2 Aug 2024 14:49:02 +0000 Subject: [PATCH 3/6] force higher version of setuptools for mypy --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 509f8e6fef..2f3b83ab3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip wheel setuptools + python -m pip install --upgrade pip wheel setuptools>=60 pip install ruff black mypy nbstripout nbformat - name: Lint run: | From c5f9d4928b39a9414acc9d5d904feca46f0c0f5b Mon Sep 17 00:00:00 2001 From: Yerdos Ordabayev Date: Fri, 2 Aug 2024 14:55:03 +0000 Subject: [PATCH 4/6] force higher version of setuptools for mypy --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f3b83ab3c..e753be88ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip wheel setuptools>=60 + python -m pip install --upgrade pip wheel setuptools>=69.0.0 pip install ruff black mypy nbstripout nbformat - name: Lint run: | From 8171ce4b8da7c1038440d05dfccf643c85b10830 Mon Sep 17 00:00:00 2001 From: Yerdos Ordabayev Date: Fri, 9 Aug 2024 16:19:44 +0000 Subject: [PATCH 5/6] add torch to make lint dependency --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e753be88ed..e8d75a9cb0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ env: jobs: lint: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: python-version: [3.8] @@ -30,6 +30,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip wheel setuptools>=69.0.0 + pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu pip install ruff black mypy nbstripout nbformat - name: Lint run: | From dbd850b69ddd84ad356ae54bd934393c79e841f9 Mon Sep 17 00:00:00 2001 From: Yerdos Ordabayev Date: Fri, 9 Aug 2024 19:34:23 +0000 Subject: [PATCH 6/6] revert ci changes --- .github/workflows/ci.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8d75a9cb0..13cb535a23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ env: jobs: lint: - runs-on: ubuntu-22.04 + runs-on: ubuntu-20.04 strategy: matrix: python-version: [3.8] @@ -29,7 +29,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip wheel setuptools>=69.0.0 + python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu pip install ruff black mypy nbstripout nbformat - name: Lint @@ -52,7 +52,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build graphviz - python -m pip install --upgrade pip wheel setuptools + python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu @@ -80,7 +80,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build graphviz pandoc - python -m pip install --upgrade pip wheel setuptools + python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu @@ -114,7 +114,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build - python -m pip install --upgrade pip wheel setuptools + python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu @@ -148,7 +148,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build - python -m pip install --upgrade pip wheel setuptools + python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu @@ -182,7 +182,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build - python -m pip install --upgrade pip wheel setuptools + python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu @@ -214,7 +214,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build - python -m pip install --upgrade pip wheel setuptools + python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu @@ -246,7 +246,7 @@ jobs: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-9 g++-9 ninja-build - python -m pip install --upgrade pip wheel setuptools + python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60' # Keep track of pyro-api master branch pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu