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

Tensorflow not working on Windows (Parallel) VM on Mac with M1 Chip #48726

Closed
ComputerVisionFans opened this issue Apr 23, 2021 · 6 comments
Closed
Assignees
Labels
stat:awaiting response Status - Awaiting response from author subtype:macOS macOS Build/Installation issues TF 2.4 for issues related to TF 2.4 type:build/install Build and install issues

Comments

@ComputerVisionFans
Copy link

ComputerVisionFans commented Apr 23, 2021

Error: ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

System info:
Cuda V11.3
cudnn V11.3
Pycharm
Python 3.7
VS2019 installed as well
Installed tensorflow by : pip install tensorflow (tensorflow version: 1.15.0) and also tried tensorflow 2.4.1

System is: windows10 installed by parallel on Mac with M1 Chip

When I test tensorflow by following commends, it gave me these error
import tensorflow as tf

Traceback (most recent call last):
File "C:\Users\XXXXXXXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXX\XXXXvenv\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXX\XXXX\venv\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXX\XXXX\venv\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\imp.py", line 342, in load_dynamic
return _load(spec)
**ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

During handling of the above exception, another exception occurred:**

Traceback (most recent call last):
File "C:/Users/XXXX/Documents/XXXX/Development/Application/WebVersion-Desktop/XXXX/XXXX/XXXXapp.py", line 39, in
from model import KeyPointClassifier
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXX\XXXX\model_init_.py", line 1, in
from model.keypoint_classifier.keypoint_classifier import KeyPointClassifier
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXX\XXXXr\model\keypoint_classifier\keypoint_classifier.py", line 4, in
import tensorflow as tf
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXX\XXXX\venv\lib\site-packages\tensorflow_init_.py", line 99, in
from tensorflow_core import *
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXX\XXXX\venv\lib\site-packages\tensorflow_core_init_.py", line 28, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXX\XXXX\venv\lib\site-packages\tensorflow_init_.py", line 50, in getattr
module = self.load()
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXX\XXXX\venv\lib\site-packages\tensorflow_init.py", line 44, in _load
module = importlib.import_module(self.name)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\importlib_init.py", line 127, in import_module
return _bootstrap.gcd_import(name[level:], package, level)
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXX\XXXX\venv\lib\site-packages\tensorflow_core\python_init.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXX\XXXX\venv\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXX\XXXX\venv\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXXr\XXXX\venv\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\XXXX\Documents\XXXX\Development\Application\WebVersion-Desktop\XXXXXXXX\venv\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\imp.py", line 342, in load_dynamic
return _load(spec)
**ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

Failed to load the native TensorFlow runtime.**

See https://www.tensorflow.org/install/errors

for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.

Process finished with exit code 1

Can someone please give us some help? thanks a lot!

@ComputerVisionFans ComputerVisionFans added the type:build/install Build and install issues label Apr 23, 2021
@google-ml-butler
Copy link

From the template it looks like you are installing TensorFlow (TF) prebuilt binaries:

  • For TF-GPU - See point 1
  • For TF-CPU - See point 2

1. Installing TensorFlow-GPU (TF) prebuilt binaries

Make sure you are using compatible TF and CUDA versions. Please refer following TF version and CUDA version compatibility table.

TF CUDA
2.5.0 11.2
2.4.0 11.0

| 2.1.0 - 2.3.0 | 10.1 |
| 1.13.1 - 2.0 | 10.0 |
| 1.5.0 - 1.12.0 | 9.0 |

  • If you have above configuration and using Windows platform -
    • Try adding the CUDA, CUPTI, and cuDNN installation directories to the %PATH% environment variable.
    • Refer windows setup guide.
  • If you have above configuration and using Ubuntu/Linux platform -
    • Try adding the CUDA, CUPTI, and cuDNN installation directories to the $LD_LIBRARY_PATH environment variable.
    • Refer linux setup guide.
  • If error still persists then, apparently your CPU model does not support AVX instruction sets.

2. Installing TensorFlow (TF) CPU prebuilt binaries

TensorFlow release binaries version 1.6 and higher are prebuilt with AVX instruction sets.

Therefore on any CPU that does not have these instruction sets, either CPU or GPU version of TF will fail to load.
Apparently, your CPU model does not support AVX instruction sets. You can still use TensorFlow with the alternatives given below:

  • Try Google Colab to use TensorFlow.
    • The easiest way to use TF will be to switch to google colab. You get pre-installed latest stable TF version. Also you can use pip install to install any other preferred TF version.
    • It has an added advantage since you can you easily switch to different hardware accelerators (cpu, gpu, tpu) as per the task.
    • All you need is a good internet connection and you are all set.
  • Try to build TF from sources by changing CPU optimization flags.

Please let us know if this helps.

@ComputerVisionFans
Copy link
Author

Cuda and Cudnn are correctly installed and added into system path,
we installed win10 on MacBook, and it is M1 Chip one

@tilakrayal tilakrayal added TF 2.4 for issues related to TF 2.4 subtype:macOS macOS Build/Installation issues labels Apr 25, 2021
@tilakrayal tilakrayal assigned Saduf2019 and unassigned tilakrayal Apr 25, 2021
@Saduf2019
Copy link
Contributor

@Johnny-liqiang
As mentioned in the above comment, please downgrade to cuda 11.0 for tf 2.4 and let us know, if you still face the issue.
Based on the error you may also refer to:#47517,#43915,#46788

@Saduf2019 Saduf2019 added the stat:awaiting response Status - Awaiting response from author label Apr 25, 2021
@ComputerVisionFans
Copy link
Author

After long time Stackoverflow and debugging , the following solution works for me:
If you want to run tensorflow on Win10 (VM) installed by parallel, and you Macbook is latest M1 chip,
And you came cross DLL problem, maybe try following command:
pip uninstall tensorflow and also go to check venv/lib/sit-packages/ whether or not tensorflow folder deleted completely , make sure deleted it completely, then run command,

Bascially, M1 CPU doesn't support AVX instructions, you will get ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed. (Win 10) or ImportError: DLL load failed with error code -1073741795 (Win 7) when using tensorflow official release 1.6.0 and up (pip install tensorflow)
You can use pip install <filename.whl> which file download from sse2 folder instead of using official AVX binary.

Thanks a lot for this github

Then download 7Zip to unzip the whole file, Combine_several_zip_files into whl file
Finally you can use pip install filename.whl to install tensorflow!

Cheers ! Solved!

  • someone also suggested not using pip install, but conda install tensorflow, it doesnt work for this system set.:(
  • someone also suggested downgrading the u5py version, not work:(
  • downgrading cuda not help:(
  • pip install --upgrade tensorflow-gpu==2.2.0 not work :(

But if my way not helping you, the above mentioned methods maybe be helpful for your case.!

`>>> import tensorflow
2021-04-26 15:34:59.397734: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll

`

@Saduf2019
Copy link
Contributor

@Johnny-liqiang
Thank you for the update and information, glad you issue is solved. Please move this to closed status.

@google-ml-butler
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:macOS macOS Build/Installation issues TF 2.4 for issues related to TF 2.4 type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

3 participants