bonito icon indicating copy to clipboard operation
bonito copied to clipboard

bonito on CPU (AMD)

Open lpryszcz opened this issue 2 years ago • 8 comments

Can bonito be used on CPU (AMD)? I'm interested in using pretrained fast model, so Intel (openvino) optimizations may not be needed. I'd really appreciate some installation guidance of CPU-only version :)

My error when I try --device cpu

  File "/lib/python3.7/site-packages/koi/ctc.py", line 201, in logZ_fwd_cu
    assert Ms.device.index is not None
AssertionError

lpryszcz avatar Jun 29 '22 10:06 lpryszcz

I have got the same error. File "/lib/python3.8/site-packages/koi/ctc.py", line 201, in logZ_fwd_cu assert Ms.device.index is not None AssertionError

Hi @lpryszcz - What is the full command you are running?

It looks like CPU support may not be working for your use-case, CPU training/basecalling is not something we ever run internally so these issue can creep in.

I would strongly advise against using CPU with Bonito - It is a GPU-first application and even when this issue is resolved, for anything but the smallest workloads performance will likely be unsatisfactory.

vellamike avatar Jul 01 '22 14:07 vellamike

Hi, I'm only using fast models. We're developing an app and providing only CPU-mode should be enough for our use cases (and cheaper to deploy for end users :) ), so having working CPU version would be fantastic.

To me it seems that assert Ms.device.index is not None requires cuda device ID ie 1 for cuda:1, that's why it fails with CPU. Am I right?

lpryszcz avatar Jul 05 '22 13:07 lpryszcz

Yes, I think your theory is correct. Can you try using Guppy? For your use case of AMD CPU-based basecalling this may be a more appropriate solution.

vellamike avatar Jul 07 '22 23:07 vellamike

so I've edited koi/ctc.py

  • commented out assert Ms.device.index is not None
  • and replaced Ms.device.index with Ms.device.index if Ms.device.type=='cuda' else None

and it was executing on CPU, but there were some errors about wrong data placement. But at least it made me realise that even fast model was running several times longer on CPU (on all 16-cores!) than on GPU. So I dropped the effort - it's as you said, running bonito models on CPU is likely a blind alley :)

lpryszcz avatar Jul 08 '22 13:07 lpryszcz

Thanks @lpryszcz - will get this patched into koi.

vellamike avatar Jul 08 '22 13:07 vellamike

Have the fixes been implemented in the koi package to allow it to run on a cpu?

dberma15 avatar Jul 12 '22 19:07 dberma15

Have the fixes been implemented in the koi package to allow it to run on a cpu?

This hasn't happened yet. However as noted running Bonito on CPU is usually too slow for any practical purpose anyway. Is there a reason for not running on GPU?

vellamike avatar Jul 13 '22 18:07 vellamike

Any news regarding Bonito on CPU?

I Have no access to GPU computer at the moment and need to test Bonito on a small data set for future use. I get the assertion error as well and gues its due to the luck of Cuda. Any suggestions?

assafgrw avatar Dec 05 '22 18:12 assafgrw

@assafgrw please use dorado for this use-case https://github.com/nanoporetech/dorado

iiSeymour avatar May 31 '23 15:05 iiSeymour