Update Dockerfile
Browse files- Dockerfile +53 -99
Dockerfile
CHANGED
@@ -1,99 +1,53 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
model.train()
|
55 |
-
train_loss = 0
|
56 |
-
correct = 0
|
57 |
-
total = 0
|
58 |
-
|
59 |
-
for batch_idx, (data, target) in enumerate(tqdm(train_loader, desc="Training", leave=False)):
|
60 |
-
optimizer.zero_grad()
|
61 |
-
output = model(data)
|
62 |
-
loss = criterion(output, target)
|
63 |
-
loss.backward()
|
64 |
-
optimizer.step()
|
65 |
-
|
66 |
-
train_loss += loss.item()
|
67 |
-
_, predicted = torch.max(output.data, 1)
|
68 |
-
total += target.size(0)
|
69 |
-
correct += (predicted == target).sum().item()
|
70 |
-
|
71 |
-
acc = correct / total
|
72 |
-
items = {'accuracy': acc, 'loss': train_loss / len(train_loader)}
|
73 |
-
aim_run.track(items, epoch=epoch, context={'subset': 'train'})
|
74 |
-
|
75 |
-
track_params_dists(model, aim_run, epoch=epoch, context={'subset': 'train'})
|
76 |
-
track_gradients_dists(model, aim_run, epoch=epoch, context={'subset': 'train'})
|
77 |
-
|
78 |
-
model.eval()
|
79 |
-
test_loss = 0
|
80 |
-
correct = 0
|
81 |
-
total = 0
|
82 |
-
|
83 |
-
with torch.no_grad():
|
84 |
-
for batch_idx, (data, target) in enumerate(tqdm(test_loader, desc="Testing", leave=False)):
|
85 |
-
output = model(data)
|
86 |
-
loss = criterion(output, target)
|
87 |
-
test_loss += loss.item()
|
88 |
-
_, predicted = torch.max(output.data, 1)
|
89 |
-
total += target.size(0)
|
90 |
-
correct += (predicted == target).sum().item()
|
91 |
-
|
92 |
-
acc = correct / total
|
93 |
-
items = {'accuracy': acc, 'loss': test_loss / len(test_loader)}
|
94 |
-
aim_run.track(items, epoch=epoch, context={'subset': 'test'})
|
95 |
-
|
96 |
-
track_params_dists(model, aim_run, epoch=epoch, context={'subset': 'test'})
|
97 |
-
track_gradients_dists(model, aim_run, epoch=epoch, context={'subset': 'test'})
|
98 |
-
|
99 |
-
torch.save(model.state_dict(), 'mnist_cnn.pth')
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
|
9 |
+
RUN useradd -m -u 1000 aim_user
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
# Switch to the "aim_user" user
|
14 |
+
USER aim_user
|
15 |
+
|
16 |
+
# Set home to the user's home directory
|
17 |
+
ENV HOME=/home/aim_user \
|
18 |
+
PATH=/home/aim_user/.local/bin:$PATH
|
19 |
+
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
# Set the working directory to the user's home directory
|
26 |
+
WORKDIR $HOME
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
# install the `aim` package on the latest version
|
34 |
+
RUN pip install aim
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
RUN aim telemetry off
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
ENTRYPOINT ["/bin/sh", "-c"]
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
COPY aim_repo.tar.gz .
|
47 |
+
RUN tar xvzf aim_repo.tar.gz
|
48 |
+
# have to run `aim init` in the directory that stores aim data for
|
49 |
+
# otherwise `aim up` will prompt for confirmation to create the directory itself.
|
50 |
+
# We run aim listening on 0.0.0.0 to expose all ports. Also, we run
|
51 |
+
# using `--dev` to print verbose logs. Port 43800 is the default port of
|
52 |
+
# `aim up` but explicit is better than implicit.
|
53 |
+
CMD ["aim up --host 0.0.0.0 --port 7860 --workers 2"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|