2
votes

I´m trying to make my first try with Tensorflow using windows 8.1 and Pycharm but I get an Tensorflow error.

I also installed everything in a virtual env with pip and runned the code in the command line with the same result.

Some things I tried

  1. I read other posts relating the issue to the msvcp140.dll and I do have the C++ distributable installed.

  2. Also found info related to downgrading to python 3.5. I actually use Python 3.7 and wouldn´t like to downgrade. I´m worried other apps won´t work. Can anyone confirm it won´t work with Python greater than 3.5?

  3. Also read info about using Conda, but a the same time other info saying to avoid it, naming pip as the officialy supported method.

  4. Also found info about my Intel® Pentium® Processor B980 not supporting AVX instructions. Is this a must when using CPU or only when using the GPU?

Any clues? Thanks in advance!

The following is the error message I get:

Using TensorFlow backend. Traceback (most recent call last): File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\imp.py", line 343, in load_dynamic return _load(spec) ImportError: DLL load failed: No se puede encontrar el módulo especificado.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/Lia love/TestAi/Test1.py", line 4, in from keras.models import Sequential File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\keras__init__.py", line 3, in from . import utils File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\utils__init__.py", line 6, in from . import conv_utils File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\utils\conv_utils.py", line 9, in from .. import backend as K File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\backend__init__.py", line 89, in from .tensorflow_backend import * File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in import tensorflow as tf File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow__init__.py", line 24, in from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python__init__.py", line 49, in from tensorflow.python import pywrap_tensorflow File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in raise ImportError(msg) ImportError: Traceback (most recent call last): File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "C:\Users\Lia love\AppData\Local\Programs\Python\Python37\lib\imp.py", line 343, in load_dynamic return _load(spec) ImportError: DLL load failed: No se puede encontrar el módulo especificado.

Failed to load the native TensorFlow runtime.

Test code

I estimate this is not a problem about my code, but I include it just in case.

import pandas as pd
from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from keras.models import Sequential
from keras.layers import Dense

df = pd.read_csv("housepricedata.csv")

dataset = df.values

X = dataset[:, 0:10]
Y = dataset[:, 10]

min_max_scaler = preprocessing.MinMaxScaler()
X_scale = min_max_scaler.fit_transform(X)

X_train, X_val_and_test, Y_train, Y_val_and_test = train_test_split(X_scale, Y, test_size=0.3)

X_val, X_test, Y_val, Y_test = train_test_split(X_val_and_test, Y_val_and_test, test_size=0.5)

print("Keras model setup")
model = Sequential([
    Dense(32, activation='relu', input_shape=(10,)),
    Dense(32, activation='relu'),
    Dense(1, activation='sigmoid'),
])
2
Looks like a problem with your installation. Did you try running: python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"? You could try using 32-bit python if you're using 64-bit. Or building Tensorflow from source. - pnovotnyq

2 Answers

2
votes

Intel Pentium processors do not support Advanced Vector Instructions ( AVX ) which are needed by TensorFlow if installed from PyPI through :

pip install tensorflow

Since, your CPU doesn't support AVX, you have two options to choose from:

  1. Use Anaconda

Anaconda uses conda distribution index which is similar to PyPI. The TensorFlow conda build uses MKL ( Intel Math Kernel Library ). It works without AVX.

Download Anaconda as mentioned here and create a new conda enviroment as mentioned here. Run this command:

conda install tensorflow
  1. Use builds from tensorflow-windows-wheel repo.

This repo contains a number of TensorFlow pip wheel files which are build using SSE instead of AVX. SSE build run without any compilation errors. Use this file from the repo.

Hope this helps.

0
votes

Python virtual environments are used to isolate package installation from the system (recommended)

Make sure these installation:

python3 --version
pip3 --version
virtualenv --version

Create a new virtual environment by choosing a Python interpreter and making a .\venv directory to hold it:

virtualenv --system-site-packages -p python3 ./venv

Activate the virtual environment:

.\venv\Scripts\activate

Install packages within a virtual environment without affecting the host system setup. Start by upgrading pip:

pip install --upgrade pip
pip list  # show packages installed within the virtual environment

pip install --upgrade tensorflow

#Verify the install:
python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"

Open your project in pycharm and go to project setting and change the python run time to target this virtual env. Hope this will help.