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 usage #15

Merged
merged 5 commits into from
Apr 5, 2024
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
4 changes: 4 additions & 0 deletions src/pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
" \"faiss_index_path\":\"hf://datasets/fondant-ai/datacomp-small-clip/faiss\",\n",
" \"num_images\": 2\n",
" },\n",
" resources=Resources(\n",
" accelerator_number=number_of_accelerators,\n",
" accelerator_name=accelerator_name,\n",
" ),\n",
")\n",
"\n",
"images = image_urls.apply(\n",
Expand Down
16 changes: 12 additions & 4 deletions src/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Pipeline used to create a stable diffusion dataset from a set of initial prompts."""
from pathlib import Path

import torch
import pyarrow as pa
from fondant.pipeline import Pipeline
from fondant.pipeline import Pipeline, Resources

from components.generate_prompts import GeneratePromptsComponent


BASE_PATH = "./data_dir"
# Create data directory if it doesn't exist
Path(BASE_PATH).mkdir(parents=True, exist_ok=True)
Expand All @@ -21,7 +20,7 @@
prompts = pipeline.read(
GeneratePromptsComponent,
arguments={
"n_rows_to_load": 10
"n_rows_to_load": 50
}, # Set to 10 for small scale testing, set to None to load all rows
)

Expand All @@ -32,6 +31,9 @@
"faiss_index_path": "hf://datasets/fondant-ai/datacomp-small-clip/faiss",
"num_images": 2,
},
resources=Resources(
accelerator_name="GPU", accelerator_number=torch.cuda.device_count()
),
)

images = image_urls.apply(
Expand All @@ -54,6 +56,9 @@
"batch_size": 8,
"max_new_tokens": 50,
},
resources=Resources(
accelerator_name="GPU", accelerator_number=torch.cuda.device_count()
),
)

segmentations = captions.apply(
Expand All @@ -62,6 +67,9 @@
"model_id": "openmmlab/upernet-convnext-small",
"batch_size": 8,
},
resources=Resources(
accelerator_name="GPU", accelerator_number=torch.cuda.device_count()
),
)


Expand Down
Loading