Skip to content

Commit d8c2166

Browse files
committed
custom docker image for golem service
1 parent df8ff92 commit d8c2166

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

mlweb3/golem/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# dockerfile for mnist classifier service on golem
2+
FROM nvidia/cuda:11.3.1-cudnn8-runtime
3+
4+
# patch: https://github.com/NVIDIA/nvidia-container-toolkit/issues/258
5+
RUN rm /etc/apt/sources.list.d/cuda.list
6+
RUN rm /etc/apt/sources.list.d/nvidia-ml.list
7+
8+
# install python
9+
RUN apt-get update && \
10+
apt-get install -y python3 python3-pip && \
11+
rm -rf /var/lib/apt/lists/*
12+
RUN python3 --version
13+
14+
# install packages
15+
RUN pip install torch torchvision --index-url https://download.pytorch.org/whl/cu113
16+
RUN pip install Flask~=3.0.1
17+
18+
# app
19+
WORKDIR /mlweb3
20+
COPY mlweb3/golem/app.py app.py
21+
COPY mlweb3/model.py mlweb3/model.py
22+
COPY etc/models/cnn_mnist.pth etc/models/cnn_mnist.pth
23+
24+
CMD python3 app.py

mlweb3/golem/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def classify_image():
3434
global model
3535
if model is None:
3636
model = SimpleCNN()
37-
model.load_state_dict(torch.load('./etc/models/cnn_mnist.pth'))
37+
model.load_state_dict(torch.load('./etc/models/cnn_mnist.pth', map_location=torch.device('cpu')))
3838
model.eval()
3939

4040
# parse image data

0 commit comments

Comments
 (0)