Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable GPU for local runner #377

Merged
merged 3 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/fondant/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def ignore_aliases(self, data):
return True

with open(output_path, "w") as outfile:
yaml.dump(spec, outfile, Dumper=NoAliasDumper)
yaml.dump(spec, outfile, Dumper=NoAliasDumper, default_flow_style=False)

logger.info(f"Successfully compiled to {output_path}")

Expand Down Expand Up @@ -176,6 +176,21 @@ def _generate_spec(
"volumes": volumes,
}

if component_op.number_of_gpus is not None:
services[component_name]["deploy"] = {
"resources": {
"reservations": {
"devices": [
{
"driver": "nvidia",
"count": component_op.number_of_gpus,
"capabilities": ["gpu"],
},
],
},
},
}

if component_op.dockerfile_path is not None:
logger.info(
f"Found Dockerfile for {component_name}, adding build step.",
Expand All @@ -186,6 +201,7 @@ def _generate_spec(
}
else:
services[component_name]["image"] = component_op.component_spec.image

return {
"name": pipeline.name,
"version": "3.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ services:
{"type": "binary"}}}, "captions": {"fields": {"data": {"type": "string"}}}},
"args": {"storage_args": {"description": "Storage arguments", "type": "str"}}}'
depends_on: {}
deploy:
resources:
reservations:
devices:
- capabilities:
- gpu
count: 1
driver: nvidia
volumes: []
second_component:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ spec:
- --output_manifest_path
- /tmp/outputs/output_manifest_path/data
image: example_component:latest
resources:
limits:
nvidia.com/gpu: 1
inputs:
artifacts:
- name: input_manifest_path
Expand Down
1 change: 1 addition & 0 deletions tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Path(COMPONENTS_PATH / "example_1" / "first_component"),
arguments={"storage_args": "a dummy string arg"},
input_partition_rows="disable",
number_of_gpus=1,
),
ComponentOp(
Path(COMPONENTS_PATH / "example_1" / "second_component"),
Expand Down
Loading