diff --git a/Custom_EasyBlocks/nvhpc.py b/Custom_EasyBlocks/nvhpc.py
index 43853ebf95219d462ec33760a33f6e976c095682..002c1571593f4ecf81ec5e1cf591da8831ebfdd6 100644
--- a/Custom_EasyBlocks/nvhpc.py
+++ b/Custom_EasyBlocks/nvhpc.py
@@ -326,10 +326,16 @@ class EB_NVHPC(PackedBinary):
         """Add environment variable for NVHPC location"""
         txt = super(EB_NVHPC, self).make_module_extra()
         txt += self.module_generator.set_environment('NVHPC', self.installdir)
+        # NVHPC 22.7+ requires the variable NVHPC_CUDA_HOME for external CUDA. CUDA_HOME has been deprecated.
         if LooseVersion(self.version) >= LooseVersion('22.7'):
-            # NVHPC 22.7+ requires the variable NVHPC_CUDA_HOME for external CUDA. CUDA_HOME has been deprecated.
-            cuda = get_software_root('CUDA')
-            if not self.cfg['module_add_cuda'] and cuda:
-                txt += self.module_generator.set_environment(
-                    'NVHPC_CUDA_HOME', cuda)
+            # If CUDA is not available then avoid setting NVHPC_CUDA_HOME altogether
+            # and rely on the internal one
+            if not self.cfg['module_add_cuda']:
+                cuda = get_software_root('CUDA')
+                if cuda:
+                    txt += self.module_generator.set_environment(
+                        'NVHPC_CUDA_HOME', cuda)
+                else:
+                    raise EasyBuildError(
+                        "No external CUDA available and opting-out of internal CUDA. Don't know what to do")
         return txt