clearml-docs/docs/getting_started/ds/ds_first_steps.md

143 lines
5.1 KiB
Markdown
Raw Normal View History

2021-05-13 23:48:51 +00:00
---
title: First Steps
---
## Install ClearML
2021-09-09 10:17:46 +00:00
2022-01-19 12:37:16 +00:00
First, [sign up for free](https://app.clear.ml)
2021-05-13 23:48:51 +00:00
Install the `clearml` python package:
2021-05-13 23:48:51 +00:00
```bash
pip install clearml
```
## Connect ClearML SDK to the Server
2022-09-15 13:10:11 +00:00
### Local Python
1. Execute the following command to run the ClearML setup wizard:
```bash
clearml-init
```
2024-04-30 12:31:05 +00:00
:::note
The wizard does not edit or overwrite existing configuration files, so the above command will not work if a `clearml.conf`
file already exists.
:::
2024-04-30 12:31:05 +00:00
<Collapsible type="info" title="Learn about creating multiple ClearML configuration files">
2024-04-30 12:31:05 +00:00
Additional ClearML configuration files can be created, for example, to use inside Docker containers when executing
a Task.
Use the `--file` option for `clearml-init`.
2024-06-30 06:16:11 +00:00
```
clearml-init --file MyOtherClearML.conf
```
2024-04-30 12:31:05 +00:00
and then specify it using the ``CLEARML_CONFIG_FILE`` environment variable inside the container:
2024-06-30 06:16:11 +00:00
```
CLEARML_CONFIG_FILE = MyOtherClearML.conf
```
2024-07-15 12:53:41 +00:00
For more information about running experiments inside Docker containers, see [ClearML Agent Deployment](../../clearml_agent/clearml_agent_deployment.md)
2024-04-30 12:31:05 +00:00
and [ClearML Agent Reference](../../clearml_agent/clearml_agent_ref.md).
</Collapsible>
1. The setup wizard prompts for ClearML credentials.
```console
2024-08-28 14:02:57 +00:00
Please create new clearml credentials through the settings page in your `clearml-server` web app (e.g. http://localhost:8080//settings/workspace-configuration),
or create a free account at https://app.clear.ml/settings/workspace-configuration
In the settings page, press "Create new credentials", then press "Copy to clipboard".
Paste copied configuration here:
```
1. Get ClearML credentials. Open the ClearML Web UI in a browser. On the [**SETTINGS > WORKSPACE**](https://app.clear.ml/settings/workspace-configuration)
2022-09-15 13:10:11 +00:00
page, click **Create new credentials**.
The **LOCAL PYTHON** tab shows the data required by the setup wizard (a copy to clipboard action is available on
2024-08-25 10:50:12 +00:00
hover).
1. At the command prompt `Paste copied configuration here:`, copy and paste the ClearML credentials.
2024-08-28 14:02:57 +00:00
The setup wizard verifies the credentials.
```console
Detected credentials key="********************" secret="*******"
2024-08-28 14:02:57 +00:00
CLEARML Hosts configuration:
Web App: https://app.<your-domain>
API: https://api.<your-domain>
File Store: https://files.<your-domain>
Verifying credentials ...
Credentials verified!
New configuration stored in /home/<username>/clearml.conf
CLEARML setup completed successfully.
```
2022-09-15 13:10:11 +00:00
Now you can integrate ClearML into your code! Continue [here](#auto-log-experiment).
### Jupyter Notebook
To use ClearML with Jupyter Notebook, you need to configure ClearML Server access credentials for your notebook.
1. Get ClearML credentials. Open the ClearML Web UI in a browser. On the [**SETTINGS > WORKSPACE**](https://app.clear.ml/settings/workspace-configuration)
page, click **Create new credentials**. The **JUPYTER NOTEBOOK** tab shows the commands required to configure your
notebook (a copy to clipboard action is available on hover)
1. Add these commands to your notebook
Now you can use ClearML in your notebook!
2021-05-13 23:48:51 +00:00
2021-09-09 10:17:46 +00:00
## Auto-log Experiment
2021-05-13 23:48:51 +00:00
In ClearML, experiments are organized as [Tasks](../../fundamentals/task.md).
2021-05-13 23:48:51 +00:00
2023-10-02 15:32:39 +00:00
ClearML automatically logs your experiment and code, including outputs and parameters from popular ML frameworks,
2022-05-18 08:49:31 +00:00
once you integrate the ClearML [SDK](../../clearml_sdk/clearml_sdk.md) with your code. To control what ClearML automatically logs, see this [FAQ](../../faq.md#controlling_logging).
At the beginning of your code, import the `clearml` package:
2021-05-13 23:48:51 +00:00
```python
2021-08-09 10:18:11 +00:00
from clearml import Task
2021-05-13 23:48:51 +00:00
```
2023-06-11 06:36:29 +00:00
:::tip Full Automatic Logging
To ensure full automatic logging, it is recommended to import the `clearml` package at the top of your entry script.
2021-05-13 23:48:51 +00:00
:::
Then initialize the Task object in your `main()` function, or the beginning of the script.
```python
2021-10-04 09:20:50 +00:00
task = Task.init(project_name='great project', task_name='best experiment')
2021-05-13 23:48:51 +00:00
```
2023-10-02 15:32:39 +00:00
If the project does not already exist, a new one is created automatically.
2021-05-13 23:48:51 +00:00
2023-10-02 15:32:39 +00:00
The console should display the following output:
```
ClearML Task: created new task id=1ca59ef1f86d44bd81cb517d529d9e5a
2021-07-25 13:59:09
ClearML results page: https://app.clear.ml/projects/4043a1657f374e9298649c6ba72ad233/experiments/1ca59ef1f86d44bd81cb517d529d9e5a/output/log
2021-07-25 13:59:16
```
2021-05-13 23:48:51 +00:00
2024-04-24 07:48:14 +00:00
**That's it!** You are done integrating ClearML with your code :)
2021-05-13 23:48:51 +00:00
2022-05-18 08:49:31 +00:00
Now, [command-line arguments](../../fundamentals/hyperparameters.md#tracking-hyperparameters), [console output](../../fundamentals/logger.md#types-of-logged-results) as well as Tensorboard and Matplotlib will automatically be logged in the UI under the created Task.
2021-05-13 23:48:51 +00:00
Sit back, relax, and watch your models converge :) or continue to see what else can be done with ClearML [here](ds_second_steps.md).
2022-12-27 14:01:47 +00:00
## YouTube Playlist
2024-02-06 14:06:43 +00:00
Or watch the **Getting Started** playlist on ClearML's YouTube Channel!
[![Watch the video](https://img.youtube.com/vi/bjWwZAzDxTY/hqdefault.jpg)](https://www.youtube.com/watch?v=bjWwZAzDxTY&list=PLMdIlCuMqSTnoC45ME5_JnsJX0zWqDdlO&index=2)