Closed Lemba13 closed 1 year ago
What are you trying to do? Are you just trying to run the command line tool?
Also, which operating system were you using? Also, do you have a machine with multiple dedicated GPUs?
Will run some tests locally now to see if the tool works as intended using the GPU. Had no issues previously, AFAIK.
EDIT: Also, if you are a developer, and trying to run stain normalization on your data on-the-fly or similar, I would recommend using torchstain. However, it requires that you implement all the processing of each image in your dataset separately. fast-stain-normalization
was built on top of this library, which I also codeveloped.
I observed an issue.
In order to use the GPU, it was not possible to use it as a command line tool directly. This is because in order to use the GPU with torch, you need to link the version to the correct CUDA version. I updated the README to account for this now: https://github.com/andreped/fast-stain-normalization#install
I also upgraded fast-stain-normalization
to use torchstain==1.2.0
, which we have shown yield identical results across all backends (torch/tensorflow/numpy): 08b6942544f3e5ecebffba4d845bc79d269440a1
I also run unit tests, and it seems to be working (at least for CPU): https://github.com/andreped/fast-stain-normalization/actions/runs/3126851705
For GPU, I would suggest creating a virtual environment, installing fast-stain-normalization
in it, and handle the correct dependencies. Maybe this will solve your issue (instructions below for linux)?
virtualenv -ppython3 venv --clear
source venv/bin/activate
pip install git+https://github.com/andreped/fast-stain-normalization.git
pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
The last line is only relevant if you want to use the GPU and if you have CUDA 11.2 (or similar) installed.
NOTE: However, I just ran a benchmark now, with a small image, and I did not see a benefit of using the GPU. Might be that for smaller images, with smaller batches, performing inference on CPU with multiprocessing is the way to go. Will need to explore this further.
Thanks for the detailed reply, will try out with the multiprocessing way.
Thanks for the detailed reply, will try out with the multiprocessing way.
Let me know how it goes :)
I was trying to run the fast stain norm code using gpu and came across this error. RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking arugment for argument vec in method wrapper_mv)