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: DLL load failed while importing _pywrap_tf2 #66588

Closed
kotKolil opened this issue Apr 28, 2024 · 2 comments
Closed

ImportError: DLL load failed while importing _pywrap_tf2 #66588

kotKolil opened this issue Apr 28, 2024 · 2 comments
Assignees
Labels
stat:awaiting response Status - Awaiting response from author subtype:windows Windows Build/Installation Issues TF 2.16 type:bug Bug

Comments

@kotKolil
Copy link

kotKolil commented Apr 28, 2024

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

2.16.1

Custom code

Yes

OS platform and distribution

windows 10

Mobile device

No response

Python version

3.12.1

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

not have

GPU model and memory

Intel UHD Graphics

Current behavior?

Hello evereone! I tried to run this code snippet:

import cv2
from keras.applications.vgg16 import VGG16, preprocess_input
from keras.preprocessing import image
import numpy as np

model = VGG16(weights='imagenet', include_top=False)

async def detect_objects(image_path):
    img = await cv2.imread(image_path)
    img = await cv2.resize(img, (224, 224))
    
    x = await image.img_to_array(img)
    x = await np.expand_dims(x, axis=0)
    x = await preprocess_input(x)
    
    features = await model.predict(x)
    
    
    return features

with this libraries, installed via pip. List is here: https://pastebin.com/jM46gp9T
But i get this error:
from tensorflow.python.platform import _pywrap_tf2
ImportError: DLL load failed while importing _pywrap_tf2: Произошел сбой в программе инициализации библиотеки динамической компоновки (DLL).

Standalone code to reproduce the issue

my project is here:
https://github.com/kotKolil/-Strange-Library-of-Sir.-Tom-/tree/master/asynchronous%20web%20server%20for%20the%20thing%20recognition%20API

Relevant log output

Traceback (most recent call last):
  File "D:\strange library of Sir Tom\asynchronous web server for the thing recognition API\main.py", line 3, in <module>
    from recg import *
  File "D:\strange library of Sir Tom\asynchronous web server for the thing recognition API\recg.py", line 2, in <module>
    from keras.applications.vgg16 import VGG16, preprocess_input
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\__init__.py", line 10, in <module>
    from keras.api import *  # noqa: F403
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\api\__init__.py", line 7, in <module>
    from keras.api import activations
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\api\activations\__init__.py", line 7, in <module>
    from keras.src.activations import deserialize
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\__init__.py", line 1, in <module>
    from keras.src import activations
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\activations\__init__.py", line 3, in <module>
    from keras.src.activations.activations import elu
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\activations\activations.py", line 1, in <module>
    from keras.src import backend
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\backend\__init__.py", line 9, in <module>
    from keras.src.backend.common.dtypes import result_type
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\backend\common\__init__.py", line 2, in <module>
    from keras.src.backend.common.dtypes import result_type
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\backend\common\dtypes.py", line 5, in <module>
    from keras.src.backend.common.variables import standardize_dtype
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\backend\common\variables.py", line 10, in <module>
    from keras.src.utils.module_utils import tensorflow as tf
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\utils\__init__.py", line 12, in <module>
    from keras.src.utils.model_visualization import model_to_dot
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\utils\model_visualization.py", line 6, in <module>
    from keras.src import tree
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\tree\__init__.py", line 1, in <module>
    from keras.src.tree.tree_api import assert_same_structure
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\tree\tree_api.py", line 6, in <module>
    from keras.src.tree import optree_impl as tree_impl
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\tree\optree_impl.py", line 17, in <module>
    from tensorflow.python.trackable.data_structures import ListWrapper
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\__init__.py", line 42, in <module>
    from tensorflow.python import tf2 as _tf2
  File "C:\Users\Tom Fox\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\python\tf2.py", line 21, in <module>
    from tensorflow.python.platform import _pywrap_tf2
ImportError: DLL load failed while importing _pywrap_tf2: Произошел сбой в программе инициализации библиотеки динамической компоновки (DLL).
@google-ml-butler google-ml-butler bot added the type:bug Bug label Apr 28, 2024
@SuryanarayanaY SuryanarayanaY added subtype:cpu-intel To track windows cpu issues TF 2.16 subtype:windows Windows Build/Installation Issues and removed subtype:cpu-intel To track windows cpu issues labels Apr 29, 2024
@SuryanarayanaY
Copy link
Collaborator

Hi @kotKolil ,

It seems you are using tensorflow 2.16.1 which is a GPU package. GPU support not available for Windows OS since TF2.11v. Please refer the doc source for same.

Either you need to install WSL2 for enabling GPU support or use tensorflow_cpu package. For more details please refer to the documentation attached.

@SuryanarayanaY SuryanarayanaY added the stat:awaiting response Status - Awaiting response from author label Apr 29, 2024
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
stat:awaiting response Status - Awaiting response from author subtype:windows Windows Build/Installation Issues TF 2.16 type:bug Bug
Projects
None yet
Development

No branches or pull requests

2 participants