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

ImportError: cannot import name 'tensor' from 'tensorflow.python.framework ' error fromTensorflow object detection api model_builder_tf2_test.py #11196

Open
OscarB11 opened this issue Apr 22, 2024 · 3 comments
Assignees
Labels
models:research models that come under research directory type:support

Comments

@OscarB11
Copy link

ImportError: cannot import name 'tensor' from 'tensorflow.python.framework ' error fromTensorflow object detection api model_builder_tf2_test.py

I get this error when running the model_builder_tf2_test.py file after installing the object detection API

I got the file to pass with tensorflow 2.15 but when I tried again in different environment using tensorflow 2.10 for the GPU support this error was shown

How do I get it to pass with tensorflow 2.10?

full error message below

2024-04-22 20:39:25.792930: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2024-04-22 20:39:25.793198: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\Tensorflow\models\research\object_detection\builders\model_builder_tf2_test.py", line 24, in
from object_detection.builders import model_builder
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\object_detection-0.1-py3.9.egg\object_detection\builders\model_builder.py", line 70, in
from object_detection.models import ssd_efficientnet_bifpn_feature_extractor as ssd_efficientnet_bifpn
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\object_detection-0.1-py3.9.egg\object_detection\models\ssd_efficientnet_bifpn_feature_extractor.py", line 35, in
from official.legacy.image_classification.efficientnet import efficientnet_model
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_models_official-2.16.0-py3.9.egg\official\legacy\image_classification\efficientnet\efficientnet_model.py", line 30, in
import tensorflow as tf, tf_keras
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_keras_init_.py", line 3, in
from tf_keras import internal
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_keras_internal__init_.py", line 3, in
from tf_keras.internal import backend
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_keras_internal_\backend_init_.py", line 3, in
from tf_keras.src.backend import initialize_variables as initialize_variables
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_keras\src_init
.py", line 21, in
from tf_keras.src import applications
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_keras\src\applications_init_.py", line 18, in
from tf_keras.src.applications.convnext import ConvNeXtBase
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_keras\src\applications\convnext.py", line 28, in
from tf_keras.src import backend
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_keras\src\backend.py", line 35, in
from tf_keras.src.engine import keras_tensor
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_keras\src\engine\keras_tensor.py", line 19, in
from tf_keras.src.utils import object_identity
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_keras\src\utils_init_.py", line 53, in
from tf_keras.src.utils.feature_space import FeatureSpace
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_keras\src\utils\feature_space.py", line 20, in
from tf_keras.src.engine import base_layer
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_keras\src\engine\base_layer.py", line 35, in
from tf_keras.src.dtensor import lazy_variable
File "c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tf_keras\src\dtensor\lazy_variable.py", line 23, in
from tensorflow.python.framework import tensor
ImportError: cannot import name 'tensor' from 'tensorflow.python.framework' (c:\Users\besto\Documents\Local vscode\Tensorflow Object Detection GPU\TFODCourse\tfodgpu\lib\site-packages\tensorflow\python\framework_init_.py)

@laxmareddyp laxmareddyp added the models:research models that come under research directory label Apr 22, 2024
@Hathamwang
Copy link

Hathamwang commented May 10, 2024

hi, I also had the same problem, could you please tell me how your problem was solved:)

@OscarB11
Copy link
Author

I didnt exactly solve it but I did find a workaround. Using tensorflow version 2.13 fixed the error but this version doesn't support the GPU.

@Chathura-Ranasinghe
Copy link

I faced the same issue using tensorflow version 2.10, the latest version that supports GPU accessorization in Windows native.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
models:research models that come under research directory type:support
Projects
None yet
Development

No branches or pull requests

4 participants