From ba1b0d94a8ef6676b618ba4e5ffe8ce2ab655270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=89?= Date: Tue, 9 May 2023 20:10:15 +0200 Subject: [PATCH] GPU support on Apple Silicon (#30) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added support for MPS on Apple Silicon * Requires PyTorch 2.0.0 or greater * Update requirements.txt --------- Co-authored-by: Timo Mom Co-authored-by: Maciej Budyƛ --- manga_ocr/ocr.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manga_ocr/ocr.py b/manga_ocr/ocr.py index 4e028ef..b4cc825 100644 --- a/manga_ocr/ocr.py +++ b/manga_ocr/ocr.py @@ -18,6 +18,9 @@ class MangaOcr: if not force_cpu and torch.cuda.is_available(): logger.info('Using CUDA') self.model.cuda() + if not force_cpu and torch.backends.mps.is_available(): + logger.info('Using MPS') + self.model.to('mps') else: logger.info('Using CPU')