apache/flink · error · FileNotFoundException

The gpu discovery script does not exist in path %s.

Error message

The gpu discovery script does not exist in path %s.

What it means

Thrown by the GPU external resource driver (GPUDriver) during TaskManager startup when the configured GPU discovery script cannot be found on disk. The path comes from the config option 'external-resources.<name>.gpu.discovery-script.path' (default: gpuDiscoveryScript.sh under FLINK_HOME). Relative paths are resolved against the FLINK_HOME environment variable (or '.' if unset), so a wrong FLINK_HOME also produces this error.

Source

Thrown at flink-external-resources/flink-external-resource-gpu/src/main/java/org/apache/flink/externalresource/gpu/GPUDriver.java:83

        if (StringUtils.isNullOrWhitespaceOnly(discoveryScriptPathStr)) {
            throw new IllegalConfigurationException(
                    String.format(
                            "GPU discovery script ('%s') is not configured.",
                            ExternalResourceOptions.genericKeyWithSuffix(
                                    DISCOVERY_SCRIPT_PATH.key())));
        }

        Path discoveryScriptPath = Paths.get(discoveryScriptPathStr);
        if (!discoveryScriptPath.isAbsolute()) {
            discoveryScriptPath =
                    Paths.get(
                            System.getenv().getOrDefault(ConfigConstants.ENV_FLINK_HOME_DIR, "."),
                            discoveryScriptPathStr);
        }
        discoveryScriptFile = discoveryScriptPath.toFile();

        if (!discoveryScriptFile.exists()) {
            throw new FileNotFoundException(
                    String.format(
                            "The gpu discovery script does not exist in path %s.",
                            discoveryScriptFile.getAbsolutePath()));
        }
        if (!discoveryScriptFile.canExecute()) {
            throw new FlinkException(
                    String.format(
                            "The discovery script %s is not executable.",
                            discoveryScriptFile.getAbsolutePath()));
        }

        args = config.get(DISCOVERY_SCRIPT_ARG);
    }

    @Override
    public Set<GPUInfo> retrieveResourceInfo(long gpuAmount) throws Exception {
        Preconditions.checkArgument(
                gpuAmount > 0,

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Verify the configured 'external-resources.<name>.discovery-script.path' (note: the key is under the generic external-resources prefix) points to a real file on every TaskManager
  2. If the path is relative, confirm FLINK_HOME is set and the script exists relative to it, or switch to an absolute path
  3. Ship the script with the Flink distribution or bake it into the container image and mount it read-only
  4. Check the absolute path echoed in the error message ('does not exist in path <abs>') to see where Flink actually looked

Example fix

# before (flink-conf.yaml)
external-resources: gpu
external-resources.gpu.discovery-script.path: scripts/gpu-discovery.sh

# after
external-resources: gpu
external-resources.gpu.discovery-script.path: /opt/flink/scripts/gpu-discovery.sh
Defensive patterns

Strategy: validation

Validate before calling

// before constructing/using the GPU driver, verify the script resolves
String script = config.get(GPUDriverOptions.DISCOVERY_SCRIPT_PATH());
java.nio.file.Path p = java.nio.file.Paths.get(script);
if (!p.isAbsolute()) {
    String home = System.getenv().getOrDefault("FLINK_HOME", ".");
    p = java.nio.file.Paths.get(home, script);
}
java.util.Objects.requireNonNull(p.toFile().exists(),
    "GPU discovery script missing at " + p.toAbsolutePath());

Prevention

When it happens

Trigger: Constructing GPUDriver (via ExternalResourceUtils setup at TaskManager start) with a discovery-script path that does not point to an existing file: bad absolute path, relative path resolved against a missing/wrong FLINK_HOME, or the script not shipped inside the Flink distribution/container image.

Common situations: Running Flink in Docker/Kubernetes where FLINK_HOME differs from the node setup; custom discovery script configured in flink-conf.yaml but never copied to workers; typo in the config key value; running from an IDE where FLINK_HOME is not set so '.' is used.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/c69b7aedee03231d. Report an issue: GitHub.