def _matches_version(actual_version, required_version):
    """Checks whether some version meets the requirements.

    All elements of the required_version need to be present in the
    actual_version.

        required_version  actual_version  result
        -----------------------------------------
        1                 1.1             True
        1.2               1               False
        1.2               1.3             False
                          1               True

    Args:
      required_version: The version specified by the user.
      actual_version: The version detected from the CUDA installation.
    Returns: Whether the actual version matches the required one.
    """
    if actual_version is None:
        return False

    # Strip spaces from the versions.
    actual_version = actual_version.strip()
    required_version = required_version.strip()
    return actual_version.startswith(required_version)