-
Notifications
You must be signed in to change notification settings - Fork 623
libusb and libuvc errors when using multiple devices on Linux #485
Comments
After discussion with @wes-b here's a few considerations. There is a maximum on memory allowed for the libusb pool, specified with the environment variable If anyone has issues with dropping frames, this could potentially be a solution. Currently, we know that 16MB of memory for However, if you go ahead and set Note that these are upper bounds; they are probably overkill. It would be nice to find a more precise specification. We should also add checks to the project on relevant calls to libusb and libuvc to check for these considerations. |
@spschul and @wes-b this appears to eliminate the libusb errors for me. Great catch! However, I then stumble into another error. Are you getting the following error after as well? This is from the master Kinect after setting up the subordinate. If not, I can provide more details. I'm having trouble pinpointing it and whether or not it's related, and am hesitant to open a separate issue for this yet.
|
This looks unrelated. If you create a new issue, we'd be happy to take a look! |
@spschul Hi Steve, thanks for helping out! I have changed /etc/default/grub according to your instruction. Now my /etc/default/grub looks like this: |
Ok so after running Is it possible to set the K4A_LOG_LEVEL environment variable to "i", try again, and post the output? This should enable more logging so the errors are more specific. Also, are you running k4aviewer to get these results? If not, try running two instances of k4aviewer at once. Hope this helps get us down the path to a solution! |
@spschul I was trying to run two k4aviewers. The first one runs normally. For the second one, the device can be detected, but cannot be started: |
I got a similar issue when using only one device:
after running |
@ruoyuwangeel4930 is seems like something may be using that device. Can you open them individually? Streaming LED turns on when the camera is running, so you can us that to confirm both cameras are working as expected. The error you shared is a failure to claim the USB interface. This is strange because you have been able to open the handle to the device at this point |
@pfagomez I think your problem can be addressed by doing this: |
@wes-b I opened the two devices individually, and they both work well. This is what I got from the log:
It threw "malloc_consolidate(): invalid chunk size", after I closed the k4aviewer. |
It's possible although not certain that the problem when you closed the viewer could be related to #353, but I don't think that it's your issue. Could you provide a log like the above log, but of the failing Thanks! |
Using Arch Linux I had the same problem. The grub fix solved the problem of program crashing when using two devices but I am still getting this message:
The usb error is coming after calling The first Kinect streams fine but the second returns empty image. BTW running two EDIT: My mistake, as @spschul wrote, 32 mb might not be enough. Used 256 and the problem is gone! |
Added Arm64 instructions to the issue information. |
Describe the bug
When streaming with multiple devices on Linux, when the program calls
start_cameras
the program will fail with errors such as an error forlibusb_submit_transfer
and similar-looking errors. Diving deeper, it becomes clear that a function withinlibusb
is failing, returningENOMEM
indicating that the kernel is out of memory. The problem is that there's a setting (readable at/sys/module/usbcore/parameters/usbfs_memory_mb
) that limits the amount of memory available for USB IO. However, some applications that require more intensive usage of that memory often use more than that. As documented at OpenKinect/libfreenect2#97, there is a fix for this: allocate more memory. I tried it with 32mb instead of 16 and it seems to be working (I ran into issues the first time I tested it but they seemed unrelated; documenting in case someone else runs into this).@wes-b I'd like to discuss how to handle this; right now I'm leaning towards having a section on it in the docs soon and somewhere early, perhaps even recommending that users preemptively add more memory.
Do we want to attempt to make this fix a part of the package? I think that is too much, and also we don't know how much memory people will have to spare, but also don't know how much memory they'll need. Using many cameras will require more memory, etc.
To fix on AMD64, using 32 mb instead of 16,
/etc/default/grub
, replacing the line that saysGRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
withGRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.usbfs_memory_mb=32"
sudo update-grub
To fix on ARM64 (Jetson Nano)
/boot/extlinux/extlinux.conf
APPEND ${cbootargs} quiet
toAPPEND ${cbootargs} usbcore.usbfs_memory_mb=128 usbcore.autosuspend=-1
. (It is probably fine to leave quiet and remove usbcore.autosuspend=-1 but that was not tested.)cat /sys/module/usbcore/parameters/usbfs_memory_mb
To Reproduce
Stream from 2 devices on Linux
Expected behavior
Programs do not crash in this case
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: