Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge TPU devices not seen #679

Closed
gsirocco opened this issue Nov 8, 2022 · 13 comments
Closed

Edge TPU devices not seen #679

gsirocco opened this issue Nov 8, 2022 · 13 comments
Assignees
Labels
Hardware:Accelerator Module Coral Accelerator Module issues subtype:ubuntu/linux Ubuntu/Linux Build/installation issues type:support Support question or issue

Comments

@gsirocco
Copy link

gsirocco commented Nov 8, 2022

Description

I'm running the multithreaded example on my Ubuntu x86_64 system, however it's not seeing the 8 TPUs that are present on the PCIe card in the system. I can do a lspci and see them as below. However, the code that enumerates them does not see them through either method below. The card is (https://github.com/kkohtaka/edgetpu-device-plugin). Is there some persmissions or something that's preventing it from being seen? Thanks!

$ lspci|grep -i tpu
b1:00.0 System peripheral: Global Unichip Corp. Coral Edge TPU
b3:00.0 System peripheral: Global Unichip Corp. Coral Edge TPU
b5:00.0 System peripheral: Global Unichip Corp. Coral Edge TPU
b7:00.0 System peripheral: Global Unichip Corp. Coral Edge TPU
b9:00.0 System peripheral: Global Unichip Corp. Coral Edge TPU
bb:00.0 System peripheral: Global Unichip Corp. Coral Edge TPU
bd:00.0 System peripheral: Global Unichip Corp. Coral Edge TPU
bf:00.0 System peripheral: Global Unichip Corp. Coral Edge TPU

const auto& available_tpus =
edgetpu::EdgeTpuManager::GetSingleton()->EnumerateEdgeTpu();
printf("num TPUs found %d\n",available_tpus.size());
// Find TPU device.
size_t num_devices;
std::unique_ptr<edgetpu_device, decltype(&edgetpu_free_devices)> devices(
edgetpu_list_devices(&num_devices), &edgetpu_free_devices);

if (num_devices == 0) {
std::cerr << "No connected TPU found" << std::endl;
return 1;
}

Click to expand!

Issue Type

Support

Operating System

Ubuntu

Coral Device

Accelerator Module

Other Devices

No response

Programming Language

C++

Relevant Log Output

No response

@google-coral-bot google-coral-bot bot added Hardware:Accelerator Module Coral Accelerator Module issues subtype:ubuntu/linux Ubuntu/Linux Build/installation issues type:support Support question or issue labels Nov 8, 2022
@hjonnala
Copy link
Contributor

hjonnala commented Nov 8, 2022

Please let us know which version of ubuntu are you trying to use and do the examples working fine without the card?

@gsirocco
Copy link
Author

gsirocco commented Nov 8, 2022

It is Ubuntu 22.04 LTS (GNU/Linux 5.15.0-52-generic x86_64)
The example two_models_two_tpus_threaded does not see the TPUs either.

@hjonnala
Copy link
Contributor

hjonnala commented Nov 8, 2022

Is it a native operating system or is it on the virtual box? Also please let me know the python version if its installed on Ubuntu 22.04.

@gsirocco
Copy link
Author

gsirocco commented Nov 8, 2022

It is native, not virtual.
Python is 3.10.6 (main, Nov 2 2022, 18:53:38) [GCC 11.3.0] on linux

@gsirocco
Copy link
Author

gsirocco commented Nov 8, 2022

After running this I see the edge tpu library does not appear to be there

$ python3 examples/classify_image.py
--model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite
--labels test_data/inat_bird_labels.txt
--input test_data/parrot.jpg
Traceback (most recent call last):
File "/home/gsosnow/coral/pycoral/examples/classify_image.py", line 40, in
from pycoral.utils.edgetpu import make_interpreter
File "/home/gsosnow/.local/lib/python3.10/site-packages/pycoral/utils/edgetpu.py", line 24, in
from pycoral.pybind._pywrap_coral import GetRuntimeVersion as get_runtime_version
ImportError: libedgetpu.so.1: cannot open shared object file: No such file or directory

@hjonnala
Copy link
Contributor

hjonnala commented Nov 8, 2022

Please install the runtime with the instructions at: https://coral.ai/docs/accelerator/get-started/#1-install-the-edge-tpu-runtime

@gsirocco
Copy link
Author

gsirocco commented Nov 8, 2022

I have installed and tried to run again but getting the below error:

$ python3 examples/classify_image.py --model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels test_data/inat_bird_labels.txt --input test_data/parrot.jpg
Traceback (most recent call last):
File "/home/gsosnow/.local/lib/python3.10/site-packages/tflite_runtime/interpreter.py", line 160, in load_delegate
delegate = Delegate(library, options)
File "/home/gsosnow/.local/lib/python3.10/site-packages/tflite_runtime/interpreter.py", line 119, in init
raise ValueError(capture.message)
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/gsosnow/coral/pycoral/examples/classify_image.py", line 121, in
main()
File "/home/gsosnow/coral/pycoral/examples/classify_image.py", line 71, in main
interpreter = make_interpreter(*args.model.split('@'))
File "/home/gsosnow/.local/lib/python3.10/site-packages/pycoral/utils/edgetpu.py", line 87, in make_interpreter
delegates = [load_edgetpu_delegate({'device': device} if device else {})]
File "/home/gsosnow/.local/lib/python3.10/site-packages/pycoral/utils/edgetpu.py", line 52, in load_edgetpu_delegate
return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {})
File "/home/gsosnow/.local/lib/python3.10/site-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
raise ValueError('Failed to load delegate from {}\n{}'.format(
ValueError: Failed to load delegate from libedgetpu.so.1

@hjonnala
Copy link
Contributor

hjonnala commented Nov 8, 2022

please try the demo with the below lines here and share the logs..

from pycoral.pybind._pywrap_coral import SetVerbosity as set_verbosity
set_verbosity(10)

@gsirocco
Copy link
Author

gsirocco commented Nov 8, 2022

Here is the output after adding the 2 lines:

$ python3 examples/classify_image.py --model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels test_data/inat_bird_labels.txt --input test_data/parrot.jpg
I tflite/edgetpu_manager_direct.cc:453] No matching device is already opened for shared ownership.
I driver/driver_factory_default.cc:31] Failed to open /sys/class/apex: No such file or directory
I driver/usb/local_usb_device.cc:944] EnumerateDevices: vendor:0x1a6e, product:0x89a
I driver/usb/local_usb_device.cc:979] EnumerateDevices: checking bus[2] port[0]
I driver/usb/local_usb_device.cc:979] EnumerateDevices: checking bus[1] port[4]
I driver/usb/local_usb_device.cc:979] EnumerateDevices: checking bus[1] port[8]
I driver/usb/local_usb_device.cc:979] EnumerateDevices: checking bus[1] port[0]
I driver/usb/local_usb_device.cc:944] EnumerateDevices: vendor:0x18d1, product:0x9302
I driver/usb/local_usb_device.cc:979] EnumerateDevices: checking bus[2] port[0]
I driver/usb/local_usb_device.cc:979] EnumerateDevices: checking bus[1] port[4]
I driver/usb/local_usb_device.cc:979] EnumerateDevices: checking bus[1] port[8]
I driver/usb/local_usb_device.cc:979] EnumerateDevices: checking bus[1] port[0]
I tflite/edgetpu_manager_direct.cc:471] No device of type Apex (PCIe) is available.
I tflite/edgetpu_manager_direct.cc:471] No device of type Apex (USB) is available.
I tflite/edgetpu_manager_direct.cc:471] No device of type Apex (Reference) is available.
I tflite/edgetpu_manager_direct.cc:502] Failed allocating Edge TPU device for shared ownership.
Traceback (most recent call last):
File "/home/gsosnow/.local/lib/python3.10/site-packages/tflite_runtime/interpreter.py", line 160, in load_delegate
delegate = Delegate(library, options)
File "/home/gsosnow/.local/lib/python3.10/site-packages/tflite_runtime/interpreter.py", line 119, in init
raise ValueError(capture.message)
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/gsosnow/coral/pycoral/examples/classify_image.py", line 122, in
main()
File "/home/gsosnow/coral/pycoral/examples/classify_image.py", line 72, in main
interpreter = make_interpreter(*args.model.split('@'))
File "/home/gsosnow/.local/lib/python3.10/site-packages/pycoral/utils/edgetpu.py", line 87, in make_interpreter
delegates = [load_edgetpu_delegate({'device': device} if device else {})]
File "/home/gsosnow/.local/lib/python3.10/site-packages/pycoral/utils/edgetpu.py", line 52, in load_edgetpu_delegate
return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {})
File "/home/gsosnow/.local/lib/python3.10/site-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
raise ValueError('Failed to load delegate from {}\n{}'.format(
ValueError: Failed to load delegate from libedgetpu.so.1

@hjonnala
Copy link
Contributor

hjonnala commented Nov 8, 2022

I tflite/edgetpu_manager_direct.cc:471] No device of type Apex (PCIe) is available.
I tflite/edgetpu_manager_direct.cc:471] No device of type Apex (USB) is available.
I tflite/edgetpu_manager_direct.cc:471] No device of type Apex (Reference) is available.

Wondering if you have any USB accelerator device with you. Please try installing the pcie drivers and save the installation logs for reference. If they are any issues with gasket-dkms installation please try building from the source code at: https://github.com/google/gasket-driver

@gsirocco
Copy link
Author

gsirocco commented Nov 8, 2022

Thank you!! After installing the pcie drivers, it works!! The C++ example two_models_two_tpus_threaded is able to see the tpus now.

@gsirocco gsirocco closed this as completed Nov 8, 2022
@google-coral-bot
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hardware:Accelerator Module Coral Accelerator Module issues subtype:ubuntu/linux Ubuntu/Linux Build/installation issues type:support Support question or issue
Projects
None yet
Development

No branches or pull requests

2 participants