Skip to content

Commit

Permalink
update away from numpy patterns removed in numpy 2.0, more deduplicat…
Browse files Browse the repository at this point in the history
…ion and cleanup
  • Loading branch information
jameslamb committed Dec 10, 2024
1 parent d8677bf commit 8b2d52e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ select = [
"F",
# isort
"I",
# numpy
"NPY",
# pyupgrade
"UP",
# flake8-bugbear
Expand Down
9 changes: 3 additions & 6 deletions source/cloud/azure/azureml.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ echo "kernel install completed"

Select `local file`, then `Browse`, and upload that script.

Optional to enable SSH access to your compute (if needed).

![Screenshot of the provision setup script screen](../../images/azureml-provision-setup-script.png)

Refer to [Azure ML documentation](https://learn.microsoft.com/en-us/azure/machine-learning/how-to-customize-compute-instance) for more details on how to create the setup script but it should resemble:
Expand Down Expand Up @@ -100,8 +98,7 @@ from azure.identity import DefaultAzureCredential
# If it isn't found, open a shell and look in the
# directory indicated by 'echo ${JUPYTER_SERVER_ROOT}'.
ml_client = MLClient.from_config(
credential=DefaultAzureCredential(),
path="./config.json"
credential=DefaultAzureCredential(), path="./config.json"
)
```

Expand Down Expand Up @@ -216,7 +213,7 @@ command_job = command(
"max_depth": 10,
"max_features": 1.0,
},
compute="rapids-cluster",
compute=gpu_compute.name,
)

# submit training job
Expand All @@ -239,7 +236,7 @@ command_job_for_sweep = command_job(

# apply hyperparameter sweep_job
sweep_job = command_job_for_sweep.sweep(
compute="rapids-cluster",
compute=gpu_compute.name,
sampling_algorithm="random",
primary_metric="Accuracy",
goal="Maximize",
Expand Down
15 changes: 7 additions & 8 deletions source/examples/rapids-azureml-hpo/train_rapids.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import cudf
import cuml
import mlflow
import numpy as np
from rapids_csp_azure import PerfTimer, RapidsCloudML


Expand Down Expand Up @@ -62,13 +61,13 @@ def main():
cv_folds = args.cv_folds

n_estimators = args.n_estimators
mlflow.log_param("n_estimators", np.int(args.n_estimators))
mlflow.log_param("n_estimators", int(args.n_estimators))
max_depth = args.max_depth
mlflow.log_param("max_depth", np.int(args.max_depth))
mlflow.log_param("max_depth", int(args.max_depth))
n_bins = args.n_bins
mlflow.log_param("n_bins", np.int(args.n_bins))
mlflow.log_param("n_bins", int(args.n_bins))
max_features = args.max_features
mlflow.log_param("max_features", np.str(args.max_features))
mlflow.log_param("max_features", str(args.max_features))

print("\n---->>>> cuDF version <<<<----\n", cudf.__version__)
print("\n---->>>> cuML version <<<<----\n", cuml.__version__)
Expand Down Expand Up @@ -156,9 +155,9 @@ def main():
global_best_test_accuracy = test_accuracy

mlflow.log_metric(
"Total training inference time", np.float(training_time + infer_time)
"Total training inference time", float(training_time + infer_time)
)
mlflow.log_metric("Accuracy", np.float(global_best_test_accuracy))
mlflow.log_metric("Accuracy", float(global_best_test_accuracy))
print("\n Accuracy :", global_best_test_accuracy)
print("\n accuracy per fold :", accuracy_per_fold)
print("\n train-time per fold :", train_time_per_fold)
Expand All @@ -171,5 +170,5 @@ def main():
with PerfTimer() as total_script_time:
main()
print(f"Total runtime: {total_script_time.duration:.2f}")
mlflow.log_metric("Total runtime", np.float(total_script_time.duration))
mlflow.log_metric("Total runtime", float(total_script_time.duration))
print("\n Exiting script")

0 comments on commit 8b2d52e

Please sign in to comment.