예제 #1
0
def test_get_driver_level_failures(mocker):
    '''
    Simple test for get_driver_level failure scenarios
    '''
    mocker.patch('subprocess.check_output',
                 side_effect=OSError(errno.ENOENT, ""))
    with pytest.raises(OpenCEError) as exc:
        utils.get_driver_level()
    assert "nvidia-smi command not found" in str(exc.value)

    mocker.patch('subprocess.check_output',
                 side_effect=OSError(errno.EPERM, ""))
    with pytest.raises(OpenCEError) as exc:
        utils.get_driver_level()
    assert "nvidia-smi command unexpectedly failed" in str(exc.value)
예제 #2
0
def build_with_container_tool(args, arg_strings):
    """
    Create a build image and run a build inside of container based on that image.
    """

    if not args.container_tool:
        raise OpenCEError(Error.NO_CONTAINER_TOOL_FOUND)

    # env_config_file being positional argument cause problem while parsing known
    # arguments. Hence removing it from arg_strings, as it is anyway being read
    # from args ahead.
    for env_file in args.provided_env_files:
        if env_file in arg_strings:
            arg_strings.remove(env_file)

    parser = make_parser()
    _, unused_args = parser.parse_known_args(arg_strings[1:])

    build_image_path, dockerfile = _generate_dockerfile_name(args.build_types, args.cuda_versions)

    if  'cuda' not in args.build_types or _capable_of_cuda_containers(args.cuda_versions):
        image_name = build_image(build_image_path, dockerfile, args.container_tool,
                                 args.cuda_versions if 'cuda' in args.build_types else None,
                                 args.container_build_args)
    else:
        raise OpenCEError(Error.INCOMPAT_CUDA, utils.get_driver_level(), args.cuda_versions)

    try:
        build_in_container(image_name, args, unused_args)
    finally:
        for conda_env_file in glob.glob(os.path.join(args.output_folder, "*.yaml")):
            utils.replace_conda_env_channels(conda_env_file,
                                             os.path.abspath(os.path.join(_home_path(args.container_tool),
                                                                          utils.DEFAULT_OUTPUT_FOLDER)),
                                                 os.path.abspath(args.output_folder))
예제 #3
0
def test_get_driver_level(mocker):
    '''
    Simple test for get_driver_level
    '''
    mocker.patch('subprocess.check_output',
                 return_value=bytes("Driver Version: 440.33.01", "utf-8"))
    assert utils.get_driver_level() == "440.33.01"
예제 #4
0
def build_with_docker(args, arg_strings):
    """
    Create a build image and run a build inside of container based on that image.
    """

    # env_config_file being positional argument cause problem while parsing known
    # arguments. Hence removing it from arg_strings, as it is anyway being read
    # from args ahead.
    for env_file in args.env_config_file:
        if env_file in arg_strings:
            arg_strings.remove(env_file)

    parser = make_parser()
    _, unused_args = parser.parse_known_args(arg_strings[1:])

    build_image_path, dockerfile = _generate_dockerfile_name(
        args.build_types, args.cuda_versions)

    if 'cuda' not in args.build_types or _capable_of_cuda_containers(
            args.cuda_versions):
        image_name = build_image(
            build_image_path, dockerfile,
            args.cuda_versions if 'cuda' in args.build_types else None,
            args.docker_build_args)
    else:
        raise OpenCEError(Error.INCOMPAT_CUDA, utils.get_driver_level(),
                          args.cuda_versions)

    build_in_container(image_name, args, unused_args)