@@ -32,46 +32,46 @@ collaboration and sharing of results.
32
32
## ❔ Exercises
33
33
34
34
1 . Start by creating an account at [ wandb] ( https://wandb.ai/site ) . I recommend using your github account but feel
35
- free to choose what you want. When you are logged in you should get an API key of length 40. Copy this for later
36
- use (HINT: if you forgot to copy the API key, you can find it under settings).
35
+ free to choose what you want. When you are logged in you should get an API key of length 40. Copy this for later
36
+ use (HINT: if you forgot to copy the API key, you can find it under settings).
37
37
38
38
2 . Next install wandb on your laptop
39
39
40
- ``` bash
41
- pip install wandb
42
- ```
40
+ ``` bash
41
+ pip install wandb
42
+ ```
43
43
44
44
3. Now connect to your wandb account
45
45
46
- ``` bash
47
- wandb login
48
- ```
46
+ ` ` ` bash
47
+ wandb login
48
+ ` ` `
49
49
50
- you will be asked to provide the 40 length API key. The connection should be remain open to the wandb server
51
- even when you close the terminal, such that you do not have to login each time. If using ` wandb ` in a notebook
52
- you need to manually close the connection using ` wandb.finish() ` .
50
+ you will be asked to provide the 40 length API key. The connection should be remain open to the wandb server
51
+ even when you close the terminal, such that you do not have to login each time. If using ` wandb` in a notebook
52
+ you need to manually close the connection using `wandb.finish ()` .
53
53
54
54
4. With it all setup we are now ready to incorporate ` wandb` into our code. The interface is fairly simple, and
55
- this [ guide] ( https://docs.wandb.ai/guides/integrations/pytorch ) should give enough hints to get you through
56
- the exercise. (HINT: the two methods you need to call are ` wandb.init ` and ` wandb.log ` ). To start with, logging
57
- the training loss of your model will be enough.
55
+ this [guide](https://docs.wandb.ai/guides/integrations/pytorch) should give enough hints to get you through
56
+ the exercise. (HINT: the two methods you need to call are ` wandb.init` and ` wandb.log` ). To start with, logging
57
+ the training loss of your model will be enough.
58
58
59
59
5. After running your model, checkout the webpage. Hopefully you should be able to see at least one run with something
60
- logged.
60
+ logged.
61
61
62
62
6. Now log something else than scalar values. This could be a image, a histogram or a matplotlib figure. In all
63
- cases the logging is still going to use ` wandb.log ` but you need extra calls to ` wandb.Image ` etc. depending
64
- on what you choose to log.
63
+ cases the logging is still going to use ` wandb.log` but you need extra calls to ` wandb.Image` etc. depending
64
+ on what you choose to log.
65
65
66
66
7. Finally, lets create a report that you can share. Click the ** Create report** button and include some of the
67
- graphs/plots/images that you have generated in the report.
67
+ graphs/plots/images that you have generated in the report.
68
68
69
69
8. To make sure that you have completed todays exercises, make the report shareable by clicking the * Share* button
70
- and create * view-only-link* . Send the link to my email ` nsde@dtu.dk ` , so I can checkout your awesome work 😃
70
+ and create * view-only-link* . Send the link to my email ` nsde@dtu.dk` , so I can checkout your awesome work 😃
71
71
72
72
9. When calling ` wandb.init` you have two arguments called ` project` and ` entity` . Make sure that you understand these
73
- and try them out. It will come in handy for your group work as they essentially allows multiple users to upload their
74
- own runs to the same project in ` wandb ` .
73
+ and try them out. It will come in handy for your group work as they essentially allows multiple users to upload their
74
+ own runs to the same project in ` wandb` .
75
75
76
76
10. Wandb also comes with build in feature for doing [hyperparameter sweeping](https://docs.wandb.ai/guides/sweeps)
77
77
which can be beneficial to get a better working model. Look through the documentation on how to do a hyperparameter
@@ -85,32 +85,32 @@ collaboration and sharing of results.
85
85
previous exercise, it needs to happen automatically. Lets therefore look into how we can do that.
86
86
87
87
1. First we need to generate an authentication key, or more precise an API key. This is in general the way any
88
- service (like a docker container) can authenticate. Start by going < https://wandb.ai/home > , click your profile
89
- icon in the upper right corner and then go to settings. Scroll down to the danger zone and generate a new API
90
- key and finally copy it.
88
+ service (like a docker container) can authenticate. Start by going < https://wandb.ai/home> , click your profile
89
+ icon in the upper right corner and then go to settings. Scroll down to the danger zone and generate a new API
90
+ key and finally copy it.
91
91
92
92
2. Next create a new docker file called ` wandb.docker` and add the following code
93
93
94
- ``` dockerfile
95
- FROM python:3.9
96
- RUN apt update && \
97
- apt install --no-install-recommends -y build-essential gcc && \
98
- apt clean && rm -rf /var/lib/apt/lists/*
99
- RUN pip install wandb
100
- COPY s4_debugging_and_logging/exercise_files/wandb_tester.py wandb_tester.py
101
- ENTRYPOINT ["python" , "-u" , "wandb_tester.py" ]
102
- ```
94
+ ` ` ` dockerfile
95
+ FROM python:3.9
96
+ RUN apt update && \
97
+ apt install --no-install-recommends -y build-essential gcc && \
98
+ apt clean && rm -rf /var/lib/apt/lists/*
99
+ RUN pip install wandb
100
+ COPY s4_debugging_and_logging/exercise_files/wandb_tester.py wandb_tester.py
101
+ ENTRYPOINT [" python" , " -u" , " wandb_tester.py" ]
102
+ ` ` `
103
103
104
- please take a look at the script being copied into the image and afterwards build the docker image.
104
+ please take a look at the script being copied into the image and afterwards build the docker image.
105
105
106
106
3. When we want to run the image, what we need to do is including a environment variables that contains the API key
107
- we generated. This will then authenticate the docker container with the wandb server:
107
+ we generated. This will then authenticate the docker container with the wandb server:
108
108
109
- ```bash
110
- docker run -e WANDB_API_KEY=<your-api-key> wandb:latest
111
- ```
109
+ ` ` ` bash
110
+ docker run -e WANDB_API_KEY=< your-api-key> wandb:latest
111
+ ` ` `
112
112
113
- Try running it an confirm that the results are uploaded to the wandb server.
113
+ Try running it an confirm that the results are uploaded to the wandb server.
114
114
115
115
12. Feel free to experiment more with ` wandb` as it is a great tool for logging, organizing and sharing experiments.
116
116
@@ -122,7 +122,6 @@ We want to stress that the combination of tools presented in this course may not
122
122
projects, and we recommend finding a setup that fits you. That said, each framework provide specific features
123
123
that the others does not.
124
124
125
- \
126
125
Finally, we want to note that we during the course really try to showcase a lot of open source frameworks, Wandb is not
127
126
one. It is free to use for personal usage (with a few restrictions) but for enterprise it does require a license. If you
128
127
are eager to only work with open-source tools we highly recommend trying out [MLFlow](https://mlflow.org/) which offers
0 commit comments