allegroai / clearml

ClearML - Auto-Magical CI/CD to streamline your AI workload. Experiment Management, Data Management, Pipeline, Orchestration, Scheduling & Serving in one MLOps/LLMOps solution
https://clear.ml/docs
Apache License 2.0
5.61k stars 651 forks source link

unexpected interaction between numpy's random number generator and initiating a ClearML Task #1087

Closed d13g0 closed 1 year ago

d13g0 commented 1 year ago

Describe the bug

A clear and concise description of what the bug is.

Starting a task interferes with numpy's RGN

To reproduce

Exact steps to reproduce the bug. Provide example code if possible.

import numpy as np
import uuid
from clearml import Task, Logger

def get_experiment_id():
    return str(uuid.uuid1())[:8]

def run():
    indices = np.arange(100)

    exp_id = get_experiment_id()

    task = Task.init(project_name='auto-dummy',
                     task_name=f'exp-{exp_id}',
                     reuse_last_task_id=False, 
                     continue_last_task=False,
                     tags=['demo']
                     )
    task.connect({
        'a':1
    })

    np.random.shuffle(indices)
    print(indices)

if __name__=='__main__':
    run()

Expected behaviour

What is the expected behaviour? What should've happened but didn't?

the numbers in the array should appear in a different order on consecutive runs. However the array is always shuffled the exact same way.

If I do the shuffling before doing Task.init then it works.

Environment

Related Discussion

If this continues a slack thread, please provide a link to the original slack thread.

jkhenning commented 1 year ago

Hi @d13g0,

This behavior is by design, see here: https://clear.ml/docs/latest/docs/clearml_sdk/task_sdk/#setting-random-seed

d13g0 commented 1 year ago

Thank you so much Jake! 🙏