BIOP / ijl-utilities-wrappers

Wrappers for external software calls (Cellpose, Elastix, Ilastix...) and java utilities (object conversions and display)
31 stars 6 forks source link

Cellpose in Fiji for Linux #30

Open esgomezm opened 1 year ago

esgomezm commented 1 year ago

Hi there!

Thank you for the wrappers! It's super nice. I saw that there's no doc for Cellpose installation in Linux. I followed the same as for Mac and it worked in my case :D

Basically, conda environment creation for cellpose:

conda create -n cellpose python=3.10
conda activate cellpose
python -m pip install cellpose[GUI]

After installing the PTBIOP update site in Fiji, I added the path to my miniconda env cellpose in cellpose setup and ran the cellpose wrapper with one of the pretrained models. Everything worked perfectly!

romainGuiet commented 1 year ago

Hi @esgomezm , Indeed it "works" but I didn't have time to document it, plus it was tested on a very particular setup, so thank you for reporting that it works on other machine too 😁. I'll update the documentation and close this issue when it's done 🤞 Cheers, R

ian-coccimiglio commented 1 year ago

Going to chime in here and say I also got it working on Linux with (and without) CUDA GPU acceleration.

My setup: OS: Manjaro Linux, Kernel 5.15 Environment: GNOME GPU: NVIDIA GeForce GTX 1080

The setup was pretty straightforward. To get it running without GPU acceleration, you can use the Mac instructions posted above. If you have GPU acceleration working already, then here's the commands I used (which are lifted essentially from the pytorch website and cellpose repo).

conda create -n cellpose
conda activate cellpose
conda install pytorch torchvision torchaudio pyqt pyqtgraph superqt pytorch-cuda=11.8 -c pytorch -c nvidia
python -m pip install cellpose

However, for NVIDIA GPU acceleration, here is the slightly gory documentation of how I got CUDA working. There's a lot of finicky details regarding drivers and such, but to anyone searching later I found this medium article helpful.

# 1) Check if you have an NVIDIA graphics card
lspci | grep -i nvidia 

# 2) Package installs
sudo pacman -S cuda cudnn # installation of cuda/cudnn
sudo pacman -S nvidia-dkms nvidia-utils # needed for drivers
sudo pacman -S openCL-nvidia # I am still not fully certain if this was necessary, but useful to have

# 3) Check CUDA version compatibility
nvidia-smi -q | grep -e "CUDA" -e "Driver Version" # Shows highest version of CUDA that is compatible with your graphics card

# 4) Check whether CUDA is recognized
ls -lah /opt/cuda | grep -e extras -e samples 
cd /opt/cuda/extras/demo_suite # go to the cuda install location
./deviceQuery | grep Result # Runs device query to check if your system recognizes CUDA. It should return PASS.

# 5) Check if linux-headers are available, install if not (may be unnecessary)
sudo modprobe nvidia
sudo pacman -S linux-headers

We can then cross-check in python

conda activate cellpose

{python}
>>> import sys
>>> print(sys.version_info)
>>> print(sys.prefix) # Does it recognize your conda environment?
>>> import torch
>>> print(torch.cuda.is_available()) # Is CUDA recognized?
NicoKiaru commented 2 weeks ago

Hey @romainGuiet is there anythin to be done in this issue ?