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

GPU or TPU not detected with GPU/TPU runtime post mediapipe & mediapipe_model_maker installation #5855

Open
PranayLohia opened this issue Feb 11, 2025 · 5 comments
Assignees
Labels
gpu MediaPipe GPU related issues os:linux-non-arm Issues on linux distributions which run on x86-64 architecture. DOES NOT include ARM devices. os:macOS Issues on MacOS type:bug Bug in the Source Code of MediaPipe Solution type:modelmaker Issues related to creation of custom on-device ML solutions

Comments

@PranayLohia
Copy link

PranayLohia commented Feb 11, 2025

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

Yes

OS Platform and Distribution

MacOS & Linux

Python Version

3.10.12

MediaPipe Model Maker version

0.2.1.4

Task name (e.g. Image classification, Gesture recognition etc.)

Model Training

Describe the actual behavior

I am unable to run the MobileBERT model training on GPU & TPU with proper GPU & TPU runtime, it pick tf.config.list_physical_devices() only as CPU

Describe the expected behaviour

Expected to run on all accelerators

Standalone code/steps you may have used to try to get what you need

-- coding: utf-8 -- """training_gpu.ipynb Automatically generated by Colab. Original file is located at https://colab.research.google.com/drive/10GHWGPAZJKM8RbXCpbBt2mit_gs3txbn?resourcekey=0-f-FpXhUgIbZbFHyz0sEC0g """ # @title Pre Import tensorflows import tensorflow as tf assert tf.version.startswith('2') tf.get_logger().setLevel('ERROR') import warnings warnings.filterwarnings('ignore') warnings.filterwarnings('ignore', category=UserWarning) tf.config.list_physical_devices() # @title Add Imports !pip install mediapipe-model-maker # @title Import tensorflows import tensorflow as tf assert tf.version.startswith('2') tf.get_logger().setLevel('ERROR') import warnings warnings.filterwarnings('ignore') warnings.filterwarnings('ignore', category=UserWarning) tf.config.list_physical_devices() from mediapipe_model_maker import text_classifier

Other info / Complete Logs

@PranayLohia PranayLohia added the type:modelmaker Issues related to creation of custom on-device ML solutions label Feb 11, 2025
@google-ml-butler google-ml-butler bot added the type:support General questions label Feb 11, 2025
@kuaashish
Copy link
Collaborator

Hi @PranayLohia,

Colab example you provided requires access. Could you please share it again so we can better understand the issue?

Thank you!!

@kuaashish kuaashish added task:pose landmarker Issues related to Pose Landmarker: Find people and body positions stat:awaiting response Waiting for user response and removed task:pose landmarker Issues related to Pose Landmarker: Find people and body positions labels Feb 12, 2025
@google-ml-butler google-ml-butler bot removed the stat:awaiting response Waiting for user response label Feb 12, 2025
@NValsted
Copy link

I can reproduce the problem on Google Colab with the gist from a previous, now-closed, issue about this: #4967 (comment)

At the time of writing, the default environment in Google Colab uses tensorflow=2.18.0 (and keras=3.8.0), but mediapipe-model-maker is constrained to tensorflow<2.16

After installing mediapipe-model-maker on the Google Colab instance, either:

  • The session must be restarted to use the downgraded versions of tensorflow, keras and others. After this, no GPU can be found
  • If the session is not restarted, mediapipe-model-maker throws an exception on import (which I believe is because of the breaking changes introduced with keras 3.0)

@PranayLohia
Copy link
Author

@NValsted were you able to fix it?

@NValsted
Copy link

I could temporarily resolve the issue by using the fallback runtime in Google colab - see this issue: googlecolab/colabtools#4214. But it's not a proper fix, and ideally mediapipe-model-maker should support the newest versions of the relevant libraries

@kuaashish kuaashish added type:bug Bug in the Source Code of MediaPipe Solution gpu MediaPipe GPU related issues os:macOS Issues on MacOS os:linux-non-arm Issues on linux distributions which run on x86-64 architecture. DOES NOT include ARM devices. and removed type:support General questions labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gpu MediaPipe GPU related issues os:linux-non-arm Issues on linux distributions which run on x86-64 architecture. DOES NOT include ARM devices. os:macOS Issues on MacOS type:bug Bug in the Source Code of MediaPipe Solution type:modelmaker Issues related to creation of custom on-device ML solutions
Projects
None yet
Development

No branches or pull requests

3 participants