Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python theano undefined symbol: _ZdlPvm error

I'm trying to execute this code:

import matplotlib.pyplot as plt
import numpy as np
from keras.models import Sequential
from keras.layers import Dense

x = np.linspace(-3, 3, 1000).reshape(-1, 1)

def f(x):    
    return 2 * x + 5

f = np.vectorize(f)
y = f(x)    

def baseline_model():
    model = Sequential()
    model.add(Dense(1, input_dim=1, activation='linear'))
    model.compile(loss='mean_squared_error', optimizer='sgd')
    return model

model = baseline_model()
model.fit(x, y, nb_epoch=100, verbose = 0)

But on last line it throws this error: ImportError: /home/puck/.theano/compiledir_Linux-4.4--MANJARO-x86_64-with-glibc2.2.5--3.6.0-64/tmpgk36rmkt/mf0c860ada3decf909d2c7248bdfcff39.so: undefined symbol: _ZdlPvm

Here is full traceback. This is my first experience with keras and theano, so I have no idea what to do.

Some info about software versions:

Linux 4.4.52-1-MANJARO
GCC 6.3.1
Anaconda 4.3.0
Python 3.6.0 
IPython 5.1.0
Theano 0.8.2
Keras 1.2.2
like image 598
KgOfHedgehogs Avatar asked Oct 17 '22 15:10

KgOfHedgehogs


2 Answers

To fix problem I installed gcc 4.9.3 and added in ~/.theanorc these lines:

[global]
cxx = /usr/bin/g++-4.9.3
like image 149
KgOfHedgehogs Avatar answered Oct 20 '22 09:10

KgOfHedgehogs


As you have installed pre-built theano package in your machine it is expecting certain gcc and dependent libs to be in the machine to make the call. The solution provided in the github link is still valid for you however because you are not building the code, that solution will not work for you because theano is still accessing the preinstalled libs.

Here is what you can try:

  • You must have gcc and g++ higher version which are not compatible to theano so remove the gcc and g++ by uninstalling them using OS commands
  • Remove theano package
  • Install gcc and g++ to 4.9 version as this is most command version
  • Reinstall theano > $ pip3 install theano --user

I believe this help you to get your theano working.

like image 26
AvkashChauhan Avatar answered Oct 20 '22 09:10

AvkashChauhan