Skip to content

Commit

Permalink
GPU in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
raxtemur committed Dec 14, 2023
1 parent f3ec0e5 commit 09632a7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ENV RESOURCES_PATH "/dedoc_root/resources"

ADD requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
RUN pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 -f https://download.pytorch.org/whl/torch_stable.html


RUN mkdir /dedoc_root
RUN mkdir /dedoc_root/dedoc
Expand Down
2 changes: 1 addition & 1 deletion dedoc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# --------------------------------------------GPU SETTINGS----------------------------------------------------------
# set gpu in XGBoost and torch models
on_gpu=False,
on_gpu=True,

# ---------------------------------------------API SETTINGS---------------------------------------------------------
# max file size in bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ def net(self) -> ClassificationModelTorch:
self._load_weights(net)
else:
net = ClassificationModelTorch(None)
net.to(self.device)
self._nets[self.checkpoint_path] = net
if self.device != next(self._nets[self.checkpoint_path].parameters()).device:
self._nets[self.checkpoint_path].to(self.device)
return self._nets[self.checkpoint_path]

@staticmethod
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ services:
- 1231:1231
environment:
DOCREADER_PORT: 1231

NVIDIA_VISIBLE_DEVICES: 0
runtime: nvidia

test:
depends_on:
Expand All @@ -26,6 +27,8 @@ services:
DOCREADER_PORT: 1231
is_test: $test
PYTHONPATH: $PYTHONPATH:/dedoc_root/tests:/dedoc_root
NVIDIA_VISIBLE_DEVICES: 0
runtime: nvidia
command:
bash dedoc_root/tests/run_tests_in_docker.sh

Expand Down

0 comments on commit 09632a7

Please sign in to comment.