Floura Angel
Floura Angel

Reputation: 99

No Artifacts Recorded MLFlow

I am unable to store, view, and retrieve the artifacts in MLFlow. The artifact folder is empty irrespective of creating a new experiment and assign proper experiment name and location.

Server: mlflow server --backend-store-uri mlruns/ --default-artifact-root mlruns/ --host 0.0.0.0 --port 5000

Create an Experiment: mlflow.create_experiment(exp_name, artifact_location='mlruns/')

with mlflow.start_run():
    mlflow.log_metric("mse", float(binary))
    mlflow.log_artifact(data_path, "data")
    # log model
    mlflow.keras.log_model(model, "models")

The code compiles and runs but does not have any artifacts recorded. It has mlflow.log-model.history file but not the model.h5

Upvotes: 5

Views: 5605

Answers (4)

Nicolò Gasparini
Nicolò Gasparini

Reputation: 2396

I found out my problem was that by using PyCharm and Docker, it automatically set my tracking uri as /opt/project, which is a shared volume set automatically by PyCharm to work with its "debugger container" and the actual python container with my code. With this, I could find and see the artifacts if I run the ui in the same container but not if I used a different docker container.

You can verify if this is your problem by checking the meta.yaml file inside the mlruns folder, if the key "artifact_location" is something like "file:///opt/project/mlruns/0"

I fixed it by setting the tracking uri right after the import:

import mlflow

mlflow.set_tracking_uri("file:///<your-root-path>/mlruns")

Upvotes: 0

Maryam Bahrami
Maryam Bahrami

Reputation: 1104

I had the same problem (for mlflow.pytorch). For me it is fixed by replacing log_model() and log_atrifacts().

So the one that logged the artifact is:

mlflow.log_metric("metric name", [metric value])
mlflow.pytorch.log_model(model, "model")
mlflow.log_artifacts(output_dir)

Besides, for ui in terminal, cd to the directory where mlruns is. For example if the location of the mlruns is ...\your-project\mlruns:

cd ...\your-project

go to the environment where mlflow is installed.

...\your-project> conda activate [myenv]

Then, run mlflow ui

(myenv) ...\your-project> mlflow ui

I answered this in this post as well:

Upvotes: 0

WaterKnight
WaterKnight

Reputation: 307

Artifact Store needs to be both accesible for the server and client. If your clients are connecting from a remote machine and you haven't configured a remote Artifact Store like S3, their artifact files will be saved locally. You can check the local storage

Here you have an explanation on the different Artifact Storages supported right now: https://mlflow.org/docs/latest/tracking.html#artifact-stores

Upvotes: 0

Lakshika Parihar
Lakshika Parihar

Reputation: 1163

I got the same problem when I started working on MLflow.

So the concept is there are two different things tracking uri and artifact uri.

tracking uri store the logs and artifact uri stores the artifact( like yaml, pkl, etc.)

But if you want a common uri you can use SQLite as a local database and then your command will be something like this...

mlflow server --backend-store-uri sqlite:///mlruns.db --host 0.0.0.0 --port 5000

Note: if you are working with a remote server then your artifact store should also be remote storage it doesn't work with local database

and don't forget to set the tracking uri explicitly as well , there are two ways either :

  • inside your code mlflow.set_tracking_uri("sqlite:///mlruns.db")
  • using enviorment varible export MLFLOW_TRACKING_URI=sqlite:///mlruns.db

Upvotes: 2

Related Questions