apple / tensorflow_macos

TensorFlow for macOS 11.0+ accelerated using Apple's ML Compute framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

ComputerVisionFans opened this issue · comments

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!

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

`