diff --git a/python/cudaq/operator/integrators/cuda_torchdiffeq_integrator.py b/python/cudaq/operator/integrators/cuda_torchdiffeq_integrator.py index 467e1a99ec..f810a2ff86 100644 --- a/python/cudaq/operator/integrators/cuda_torchdiffeq_integrator.py +++ b/python/cudaq/operator/integrators/cuda_torchdiffeq_integrator.py @@ -14,6 +14,7 @@ has_cupy = True has_torch = True has_torchdiffeq = True +has_torch_without_cuda = False try: import cupy as cp @@ -24,6 +25,8 @@ import torch import torch.utils import torch.utils.dlpack + if torch.version.cuda is None: + has_torch_without_cuda = True except ImportError: has_torch = False @@ -46,6 +49,10 @@ def __init__(self, raise ImportError( 'torch and torchdiffeq are required to use Torch-based integrators.' ) + if has_torch_without_cuda: + raise ImportError( + 'Please install a compatible version of PyTorch with CUDA support.' + ) if not has_torchdiffeq: raise ImportError( 'torchdiffeq is required to use Torch-based integrators.')