TIO-IKIM / CellViT

CellViT: Vision Transformers for Precise Cell Segmentation and Classification
https://doi.org/10.1016/j.media.2024.103143
Other
236 stars 41 forks source link

Run Inference on CPU #40

Closed mzhoufulai closed 8 months ago

mzhoufulai commented 8 months ago

Hello,

Our machine doesn't support GPU, is there a way to run inference on the CPU?

Thanks ZFl

FabianHoerst commented 8 months ago

Unfortunately, we currently just implemented a GPU solution due to runtime 🐌 and computational requirements. To add, the required memory is at least 40GB, and the expected runtime would most probably be multiple hours (depending on the slide size, up to 24 hours). Therefore, I would not recommend to use CPU processing only, regardless of the number of cores. If you would try, you need to search for the part where the GPU source is selected and hardcode it to a cpu device.

As an example, try changing: https://github.com/TIO-IKIM/CellViT/blob/48ad2804215e6e820f62296fa4cdb76740e8789d/cell_segmentation/inference/cell_detection.py#L111

to self.device = "cpu"

Hope this gave you enough insight and fulfill your needs!