Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Cellpose issue with imports #263

Open
MikeLippincott opened this issue Dec 5, 2024 · 0 comments
Open

Run Cellpose issue with imports #263

MikeLippincott opened this issue Dec 5, 2024 · 0 comments

Comments

@MikeLippincott
Copy link

After clicking the "Test GPU" button in the RunCellpose module, this error shows up in my stdout:

Traceback (most recent call last):
  File "/path/to/conda/env/lib/python3.8/site-packages/cellprofiler/gui/module_view/_module_view.py", line 1206, in callback
    self.__on_do_something(event, setting)
  File "/path/to/conda/env/lib/python3.8/site-packages/cellprofiler/gui/module_view/_module_view.py", line 2247, in __on_do_something
    setting.on_event_fired()
  File "/path/to/conda/env/lib/python3.8/site-packages/cellprofiler_core/setting/do_something/_do_something.py", line 27, in on_event_fired
    self.__callback(*self.__args)
  File "/path/to/CP.plugins/CellProfiler-plugins/active_plugins/runcellpose.py", line 724, in do_check_gpu
    if self.save_probabilities.value:
NameError: name 'core' is not defined`

I can open a PR to patch this with the proposed change below:

Starting on current line 799 of runcellpose.py - add the import core statement

def do_check_gpu(self):
        import importlib.util

        from cellpose import core

        torch_installed = importlib.util.find_spec("torch") is not None
        self.cellpose_ver = importlib.metadata.version("cellpose")
        # if the old version of cellpose <2.0, then use istorch kwarg
        if float(self.cellpose_ver[0:3]) >= 0.7 and int(self.cellpose_ver[0]) < 2:
            GPU_works = core.use_gpu(istorch=torch_installed)
        else:  # if new version of cellpose, use use_torch kwarg
            GPU_works = core.use_gpu(use_torch=torch_installed)
        if GPU_works:
            message = "GPU appears to be working correctly!"
        else:
            message = (
                "GPU test failed. There may be something wrong with your configuration."
            )
        import wx

        wx.MessageBox(message, caption="GPU Test")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant