SHI-Labs / OneFormer

OneFormer: One Transformer to Rule Universal Image Segmentation, arxiv 2022 / CVPR 2023
https://praeclarumjj3.github.io/oneformer
MIT License
1.44k stars 130 forks source link

RuntimeError: Not implemented on the CPU (When running example notebook) #15

Closed Robotatron closed 1 year ago

Robotatron commented 1 year ago

Using your example notebook getting an error RuntimeError: Not implemented on the CPU

image

Changing cfg.MODEL.DEVICE and cpu_device = torch.device("cpu") to "cuda" throws a different error

image

praeclarumjj3 commented 1 year ago

Hi @Robotatron, thanks for your interest in our work.

It is strange that you are encountering this error, as the notebook works perfectly fine when I execute the cells. It would be best if you do not replace cpu with cuda in cpu_device = torch.device("cpu") as we need to transfer the result to the CPU to convert it into a NumPy array. Are you sure you did not make any other changes to the notebook?

I would like you to confirm if you are cloning the OneFormer-Colab repo. If you still face issues, you may look at the Roboflow youtube video covering our demo.

Screenshot 2022-12-05 at 6 06 07 PM
praeclarumjj3 commented 1 year ago

Closing this issue for now. Feel free to reopen if you face any issues.

Robotatron commented 1 year ago

Are you sure you did not make any other changes to the notebook?

I am using the notebook locally, in a freshly created conda env following your guides.

Robotatron commented 1 year ago
  1. Your google colab notebooks works.
  2. However if I clone this repo locally and using your exact code (https://pastebin.com/bn0v0Ce5) I get the "RuntimeError: Not implemented on the CPU"
  3. Using CUDA 11.3 Pytorch install, however "nvidia-smi" shows me I have CUDA 11.2 installed. And under cat /usr/local/cuda/version.txt it says "11.0". Could this be a problem?
  4. Also the path for CUDA_HOME, should it be /usr/local/cuda/or /usr/local/cuda/bin ? I tried both to no avail. image
praeclarumjj3 commented 1 year ago

Hi @Robotatron, yeah, that's precisely the issue. When you use Pytorch with cuda build 11.3, it expects CUDA >= 11.3. If you have a lower cuda version, try installing torch with cuda 11.0. That should solve the issue.

Robotatron commented 1 year ago

@praeclarumjj3 Thank you very much, it was indeed an issue with PyTorch installed with CUDA 11.3. Using PyTorch with 11.1 on a machine with 11.2 solved the issue!

image