From 9b5b1c7a187f1029ddd860813a3978cbf729a6b7 Mon Sep 17 00:00:00 2001 From: roomrys <38435167+roomrys@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:08:53 -0700 Subject: [PATCH] Add warning when unable to switch back to CPU mode --- sleap/gui/app.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sleap/gui/app.py b/sleap/gui/app.py index d5abd34a2..065563e66 100644 --- a/sleap/gui/app.py +++ b/sleap/gui/app.py @@ -49,6 +49,8 @@ import platform import random import re +import traceback +from logging import getLogger from pathlib import Path from typing import Callable, List, Optional, Tuple @@ -85,6 +87,9 @@ from sleap.util import parse_uri_path +logger = getLogger(__name__) + + class MainWindow(QMainWindow): """The SLEAP GUI application. @@ -1671,7 +1676,12 @@ def main(args: Optional[list] = None, labels: Optional[Labels] = None): try: sleap.use_cpu_only() except RuntimeError: # Visible devices cannot be modified after being initialized - pass + logger.warning( + "Running processes on the GPU. Restarting your GUI should allow switching " + "back to CPU-only mode.\n" + "Received the following error when trying to switch back to CPU-only mode:" + ) + traceback.print_exc() # Print versions. print()