-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91145f9
commit 52809a1
Showing
10 changed files
with
476 additions
and
368 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import importlib | ||
|
||
import mlrun | ||
|
||
|
||
def assert_build(): | ||
for module_name in [ | ||
"torch", | ||
"transformers", | ||
"datasets", | ||
"accelerate", | ||
"evaluate", | ||
"deepspeed", | ||
"mpi4py", | ||
]: | ||
module = importlib.import_module(module_name) | ||
print(module.__version__) | ||
|
||
|
||
def setup( | ||
project: mlrun.projects.MlrunProject | ||
): | ||
""" | ||
Creating the project for this demo. | ||
:returns: a fully prepared project for this demo. | ||
""" | ||
print(project.get_param("source")) | ||
# Set or build the default image: | ||
if project.get_param("default_image") is None: | ||
print("Building image for the demo:") | ||
image_builder = project.set_function( | ||
"project_setup.py", | ||
name="image-builder", | ||
handler="assert_build", | ||
kind="job", | ||
image="mlrun/ml-models-gpu", | ||
requirements=[ | ||
"torch", | ||
"transformers[deepspeed]", | ||
"datasets", | ||
"accelerate", | ||
"evaluate", | ||
"mpi4py", | ||
], | ||
) | ||
assert image_builder.deploy() | ||
default_image = image_builder.spec.image | ||
project.set_default_image(project.get_param("default_image")) | ||
|
||
# Set the project git source: | ||
|
||
project.set_source(project.get_param("source"), pull_at_runtime=True) | ||
|
||
# Set the data collection function: | ||
data_collection_function = project.set_function( | ||
"src/data_collection.py", | ||
name="data-collecting", | ||
image="mlrun/mlrun", | ||
kind="job", | ||
|
||
) | ||
data_collection_function.apply(mlrun.auto_mount()) | ||
data_collection_function.save() | ||
|
||
# Set the data preprocessing function: | ||
project.set_function( | ||
"src/data_preprocess.py", | ||
name="data-preparing", | ||
kind="job", | ||
) | ||
|
||
# Set the training function: | ||
train_function = project.set_function( | ||
"src/trainer.py", | ||
name="training", | ||
kind="job", | ||
) | ||
train_function.with_limits( | ||
gpus=project.get_param("num_gpus_per_replica") or 4, | ||
cpu=project.get_param("num_cpus_per_replica") or 48, | ||
mem=project.get_param("memory_per_replica") or "192Gi", | ||
) | ||
train_function.save() | ||
|
||
project.set_function( | ||
"src/serving.py", | ||
name="serving", | ||
kind="serving", | ||
) | ||
|
||
# Set the training workflow: | ||
project.set_workflow("training_workflow", "src/training_workflow.py") | ||
|
||
# Save and return the project: | ||
project.save() | ||
return project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,6 @@ transformers | |
datasets | ||
accelerate | ||
evaluate | ||
bs4 | ||
bs4 | ||
einops | ||
xformers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.