facebookresearch/Mask2Former

How to run this on Mac without CUDA?

fgolemo opened this issue · 5 comments

Heyhey,

I have a question about how to run inference on Mac without CUDA:

  • The install instructions say this is compatible with Linux or macOS with Python ≥ 3.6
  • There's a github issue that says inference can be run without a GPU: #169

Whenever I try to run a trained model, I get an error that MSDeformAttn is not defined because that's a class that has to be compiled with CUDA libs.

Am I missing something? Is there some way to run this on Mac without CUDA or is CUDA strictly required?

Cheers,
Flo

I got same error here:

ModuleNotFoundError: No module named 'MultiScaleDeformableAttention'

During handling of the above exception, another exception occurred:
...
ModuleNotFoundError:

Please compile MultiScaleDeformableAttention CUDA op with the following commands:
	`cd mask2former/modeling/pixel_decoder/ops`
	`sh make.sh`

Hello,

I am also facing the same issue. Any solutions for this?

Are there any solutions now? I also get stuck here... ):

metoo! macOS user need help...

Tere's how I made it work on my laptop (AMD linux, no GPU).

The repo already provides the CUDA function MSDeformAttnFunction for non CUDA/just pytorch via ms_deform_attn_core_pytorch but it's most likely disabled so it doesn't hinder performance.

Simply disable the cuda checks and it works:
In mask2former/modeling/pixel_decoder/ops/modules/ms_deform_attn.py:

try:
    from ..functions import MSDeformAttnFunction
except ModuleNotFoundError:
    pass

and
mask2former/modeling/pixel_decoder/ops/functions/ms_deform_attn_func.py:

try:
    import MultiScaleDeformableAttention as MSDA
except ModuleNotFoundError as e:
    pass

and use

cfg.MODEL.DEVICE = "cpu"
predictor = DefaultPredictor(cfg)

image