Skip to content

Commit c0883a2

Browse files
authored
fix: anchor in pytorch 1.6 (#4)
* fix: anchor in pytorch 1.6 * fix: fastcore version for fastai<2.1 * chore: dockerfile reformatting * add: address first API call latency
1 parent 54ca872 commit c0883a2

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM pytorch/pytorch
1+
FROM pytorch/pytorch:1.6.0-cuda10.1-cudnn7-runtime
22

33
ENV PYTHONUNBUFFERED TRUE
44

@@ -40,8 +40,8 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
4040
&& rm -rf /var/lib/apt/lists/*
4141

4242
# FASTAI
43-
RUN git clone https://github.com/fastai/fastai.git --depth 1 && git clone https://github.com/fastai/fastcore.git --depth 1
44-
RUN /bin/bash -c "cd fastai && pip install . && cd ../fastcore && pip install ."
43+
RUN git clone https://github.com/fastai/fastai.git && git clone https://github.com/fastai/fastcore.git
44+
RUN /bin/bash -c "cd fastai && git checkout 2.0.18 && pip install . && cd ../fastcore && git checkout 1.1.0 && pip install ."
4545

4646
# TORCHSERVE
4747
RUN git clone https://github.com/pytorch/serve.git
@@ -53,7 +53,6 @@ RUN chmod +x /usr/local/bin/dockerd-entrypoint.sh
5353
RUN mkdir -p /home/model-server/ && mkdir -p /home/model-server/tmp
5454
COPY ./deployment/config.properties /home/model-server/config.properties
5555

56-
5756
WORKDIR /home/model-server
5857
ENV TEMP=/home/model-server/tmp
5958
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ user 0m0.280s
515515
sys 0m0.039s
516516
```
517517

518-
For more details about TorchServe setup and usage, please refere to `notebook/03_TorchServe.ipynb` [[link](notebook/03_TorchServe.ipynb)].
518+
The first call would have longer latency due to model weights loading defined in `initialize`, but this will be moderated from the second call onward. For more details about TorchServe setup and usage, please refere to `notebook/03_TorchServe.ipynb` [[link](notebook/03_TorchServe.ipynb)].
519519

520520
## Deployment to Amazon SageMaker Inference Endpoint
521521

deployment/handler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def initialize(self, ctx):
3333
if torch.cuda.is_available()
3434
else "cpu"
3535
)
36+
37+
logger.info(f"Device on initialization is: {self.device}")
3638
model_dir = properties.get("model_dir")
3739

3840
manifest = ctx.manifest
@@ -84,6 +86,7 @@ def inference(self, img):
8486
"""
8587
Predict the chip stack mask of an image using a trained deep learning model.
8688
"""
89+
logger.info(f"Device on inference is: {self.device}")
8790
self.model.eval()
8891
inputs = Variable(img).to(self.device)
8992
outputs = self.model.forward(inputs)

0 commit comments

Comments
 (0)