agimus-project / happypose

Toolbox and trackers for object pose-estimation. Based on the work CosyPose and MegaPose
https://agimus-project.github.io/happypose/
BSD 2-Clause "Simplified" License
23 stars 9 forks source link

Running inference on Mac M1 #75

Open EtienneAr opened 1 year ago

EtienneAr commented 1 year ago

Hello,

I started trying to run the inference on a Mac Studio (with an Apple M1 Ultra). So far I managed to install everything using conda and pip with some minor changes.

But now I am having a problem while trying to run an inference (from "Testing your installation" section of the doc, or from test_cosypose_inference.py) : https://github.com/agimus-project/happypose/blob/5ebed551bc217ba2f2e06f9c0b073da389a2b378/happypose/toolbox/renderer/panda3d_scene_renderer.py#L177 crashes because https://github.com/agimus-project/happypose/blob/5ebed551bc217ba2f2e06f9c0b073da389a2b378/happypose/toolbox/renderer/types.py#L168 returns None

Do you have any idea regarding this issue ? I will keep investigating this problem and will post here if I encounter new ones.

EtienneAr commented 1 year ago

Hello, I am putting the "latest" update here, so everyone can see it :

I tried a bunch of examples from this repo https://github.com/Schwarzbaer/panda_examples.git (with Panda3d installed from pip) All of them worked fine, even offscreen rendering. So the Panda3d install doesn't seem to be the problem.

I tried to disable the offscreen rendering in Happypose : it doesn't crash anymore, but it seems like it renders only black images when doing that. And the tests/test_renderer_panda3d.py still fails.

I did not have much more time yet to investigate on this topic, sorry.

nim65s commented 1 year ago

cc @alice-cariou FYI

Alhuuin commented 1 year ago

Hello, My fix for this was to simply set the number of back_buffer to 0 after https://github.com/agimus-project/happypose/blob/fc8efbdca9354e16635bfdd211d849ad8d833bae/happypose/toolbox/renderer/types.py#L167

The frame buffer properties needed by default are not available on mac. But you can add : frame_buffer_props = p3d.core.FrameBufferProperties(frame_buffer_props) frame_buffer_props.set_back_buffers(0)

The first line is necessary because the p3d.core.FrameBufferProperties.getDefault() is const. With that fix, the scripts run correctly, and the tests/test_renderer_panda3d.py doesn't fail on my side.

I hope it helps

Alhuuin commented 1 year ago

Hello,

I don’t know if this is the best place to ask, but : I’ve been having issues trying to use mps instead of cuda on happypose.

The first thing I did was adding mps to the possible devices to be used : For that, i replaced every occurence of torch.device('cuda' if torch.cuda.is_available() else 'cpu by torch.device('cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu')

But i had 2 errors : RuntimeError: slow_conv2d_forward_mps: input(device='cpu') and weight(device=mps:0') must be on the same device and FileNotFoundError: [Errno 2] No such file or directory

I made several attempts to fix these errors, including changing the multiprocessing method, but none worked, so i’m open to suggestions.