librealsense: librealsense fails to claim USB interface on MacOS Monterey
Required Info | |
---|---|
Camera Model | D415 |
Firmware Version | N/A |
Operating System & Version | MacOS Monterey (12.0.1) |
SDK Version | 2.49 |
Language | python |
Issue Description
After upgrading my machine from macOS Catalina (10.15.6) to Monterey (12.0.1), all RealSense applications I have and pyrealsense2 code I’ve written – which all previously ran without issue – are broken. They all give me the same error message: failed to claim usb interface: 0, error: RS2_USB_STATUS_ACCESS. I’ve verified both physically and via System Preferences that the D415 is connected to the machine with a USB 3 connection using the same cable that the D415 was shipped with.
When I run rs-enumerate-devices, I get:
> rs-enumerate-devices
Could not create device - failed to set power state . Check SDK logs for details
02/11 16:49:13,578 ERROR [0x70000cff3000] (handle-libusb.h:95) failed to claim usb interface: 0, error: RS2_USB_STATUS_ACCESS
When I run realsense-viewer, I get:
> realsense-viewer
02/11 16:52:08,669 ERROR [0x70000c115000] (handle-libusb.h:95) failed to claim usb interface: 0, error: RS2_USB_STATUS_ACCESS
02/11 16:52:08,669 ERROR [0x70000bf8c000] (sensor.cpp:537) acquire_power failed: failed to set power state
02/11 16:52:08,673 WARNING [0x70000bf8c000] (rs.cpp:308) null pointer passed for argument “device”
02/11 16:52:08,673 WARNING [0x70000bf8c000] (rs.cpp:2621) Couldn’t refresh devices - failed to set power state
I wondered if something was wrong with the device firmware and tried updating it, which gives me:
> rs-fw-update -l
connected devices:
03/11 14:56:46,495 ERROR [0x70000b0b1000] (handle-libusb.h:95) failed to claim usb interface: 0, error: RS2_USB_STATUS_ACCESS
RealSense error calling rs2_create_device(info_list:0x600003554e70, index:0):
failed to set power state
03/11 14:56:46,497 ERROR [0x119b34600] (sensor.cpp:537) acquire_power failed: failed to set power state
I uninstalled and then rebuilt librealsense from scratch for Monterey using the newest version of Xcode that’s Monterey compatible, but these issues still persist even after that. The librealsense homebrew page indicates that Monterey is supported. I’d greatly appreciate any guidance on fixing the failed to claim usb interface: 0, error: RS2_USB_STATUS_ACCESS problem for Monterey, thank you!
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 121
The tutorial is ready 😃 I’m describing every step of the process.
https://lightbuzz.com/realsense-macos/
If you like it, please share to help fellow RealSense developers.
I’m glad there’s demand for this. I’ll publish a detailed guide within the next few days 😃
Hi everyone, after discussing the latest reports with my Intel RealSense colleagues, the decision was made to file an official Intel bug report to investigate the issue further. I have added an Enhancement tag to this case to indicate that it should be kept open until the investigation process is completed.
Hi everyone, does anyone known the true reason why sudo execution is now required on MacOS 12? Is this something that we can work on and expect to correct for the future? Having to launch apps using the terminal is kind of a showstopper for a standard app user. Thanks!
OK, it works on Monterey 😄 Here’s proof:
@MartyG-RealSense We have released this as part of our skeleton-tracking SDK. RealSense is a first-class citizen and we support it on Windows, Linux, and Mac.
Building RealSense binaries in a way that supports all macOS versions and chipsets is not trivial and requires re-compilation of additional C++ libraries. If anyone’s interested, I can post a detailed tutorial. Just let me know.
I am getting the same error in MacOS Monterey, but I don’t think it is the same as the Monterey USB hub issue.
This code:
Will print “1” when a RealSense camera is connected, so the python wrapper can tell that a device is connected.
But if I try to read and print the camera’s serial number:
it will fail with
RuntimeError: failed to set power state
None of the built example or realsense-viewer will be able to access the device properly.
Under system report MacOS can clearly see that a realsense device is connected under Hardware > USB
The device is also visible under Hardware > Camera
Interestingly if I open Apple’s Photobooth App
Intel(R) RealSense(TM) Depth Camera 455
is available as an option along withFaceTime HD Camera
. When selected it will show the RGB-Infrared stream and the IR projector is on at full power.To me it seems that MacOS is able to power and access the RealSense camera without issue. There is something that Apple has changed that is causing the RealSense SDK to not work properly. This will likely require a change to the SDK that someone from Intel will need to investigate.
Totally agree - as a developer it’s a huge burden. I can’t run Unity in sudo on Mac, so need to create a package every time to run from command line on sudo. As a result, I can’t debug my scripts in Visual Studio. Currently trying to migrate my dev environment to root user to get around this
@MartyG-RealSense This is great to hear. Keep in mind that you still need to uninstall and re-install
libusb
via Brew. Moreover, RealSense apps (including the RealSense Viewer) must run usingsudo
.One more thing: Brew builds are not universal, so if you still need to support Apple Silicon and Intel chips with the same binaries, you should follow our installation guide and compile from scratch.
@Dreamcreationman This is not the right place to ask those kind of questions! There are more than 29 people subscribed to this issue to get information about the librealsense problem and everyone gets notified when you write a message about your independent issue with
pyrealsense2-macosx
. Please open and discuss your issue at the correct repository, which would be: https://github.com/cansik/pyrealsense2-macosx/issuesHi everyone,
As there is now a clear and detailed installation guide for MacOS Monterey on Intel and M1 Macs, is it okay if this case is now closed as resolved? If any of you have an opinion that it should be kept open, I welcome your input. Thanks!
thanx @cansik – for some reason processing4 (did not test 3) threw the same error in its console as the real sense-viewer. Something along the lines of “could not get power state” and would immediately crash. So i am pretty happy so far as after the firmware upgrade and SKD update the sketches run without any issues so far…
Thanks very much everyone for your reports. I will highlight the issue to Intel.
MacOS 13 could be several months away yet at the time of writing this.
I have updated the prebuilt python package pyrealsense2-macosx to version
2.50.0
with support for Intel and Apple Silicon. If you are interested in the fully automated build script to create pyrealsense2 & python binaries on MacOS BigSur and MacOS Monterey, have a look here: librealsense-python-mac.ps1The prebuilt packages can be directly installed from PyPI:
Thanks again to @Vangos for his great tutorial that helped me make this happen.
First python build for version 3.6, 3.7, 3.8, 3.9, 3.10 is done. You can download the pre-built wheel packages here: https://github.com/cansik/pyrealsense2-macosx/releases/tag/macosx-v2.50.0
I can only test it on my own M1 Macbook, so would be great if someone could give it a try. Please be aware to run your python script with
sudo
, otherwise RealSense tells you that no device is connected.@Vangos Wow, great tutorial and the pre-compiled binary helps for the python wheel package too. Thank you very much, and let’s hope Intel has not given up on RealSense for MacOS completely.
@MartyG-RealSense @hajdebliem Upon doing some further debugging, I strongly doubt it’s a permissions issue.
cv::VideoCapture
).After that, I tried to debug the RealSense code a little further. I started by simply executing the following program:
Really simple, huh? The file
rs_context.hpp
throws an exception in methodquery_devices()
:UNKNOWN
failed to set power state
So, I decided to go rogue and remove the
error::handle(e);
method call from theoperator[]
overload in filers_device.hpp
. Turns out now my code correctly returns the number of connected devices! Tried with 1 and 2 devices and worked fine!However, even though it counts the connected devices, the
rs2::device
elements of the array arenullptr
s.@MartyG-RealSense Does this information help? Would you like to forward it to your team? I really think it’s something straightforward to fix if Intel engineers are still committed to this project.
As mentioned in https://github.com/IntelRealSense/librealsense/issues/10035#issuecomment-1010324381:
I have a implemented a CI pipeline to build the librealsense2 python library for MacOS (macOS Catalina (
10.15
), macOS Big Sur (11.0
)). Version2.49.0
worked as expected, but since version2.50.0
the users and I have the same problem as mentioned in this issue. It seems it is not just aMonterey
problem, but general with2.50.0
.BigSur
)No device connected
exception (tested onBigSur
)Also a nightly build (https://github.com/IntelRealSense/librealsense/commit/c94410a420b74e5fb6a414bd12215c05ddd82b69 using the head commit in the librealsense2 lib) did not help fixing this issue. Because of that I have removed the pre-built wheel packages from the repository (https://github.com/cansik/pyrealsense2-macosx/issues/2).
I have been facing the same issue since I updated to macOS Monterey.
The camera appears in the USB list and I can properly use it as a webcam.
To avoid spending time on testing different architectures, the chipset is irrelevant to this issue. I have compiled RealSense for Intel (x86_64), Apple Silicon (arm64), and Universal (x86_64 + arm64) and I’ve used it without any problems in Big Sur.
Here’s the test: I created a universal RealSense build on my M1 machine (Monterey). Obviously, it did not work on Monterey. However, when I used that exact same build on an Intel machine (Big Sur), it worked fine.
Same for x86 and ARM builds: they work on Big Sur, but not on Monterey.
Also, I recompiled libusb (latest version) and linked that to RealSense. No luck.
It seems this issue is related to Monterey and power delivery over USB.
The RealSense SDK uses the sensor in full power. I guess that’s why it requires a dedicated USB-3/C. All other apps (like FaceTime or Photobooth) use RealSense as a webcam, limiting it to 30 FPS.
There are numerous user reports here. So, for now, I tend to agree with @MartyG-RealSense that it’s something Apple should work on. However, I’m keeping the thread alive to ensure Intel engineers will take care of that for version 2.50.
Confirmed the same behavior on both a late 2019 Intel MacBook Pro as well as a late 2021 M1 Pro MacBook Pro.
MacOS Monterey Version 12.0.1 RealSense SDK Version 2.50.0 and FW 5.13.0.50