I am running Theano with Anaconda on Windows. Ihave pretty much followed the steps in the comments here. I can import theano with no problems:
import theano
from theano import tensor as T
x = T.vector('x')
W = T.matrix('W')
dot = T.dot(x, W)
This works fine. But when I do
f = theano.function(inputs=[x, W], outputs=dot)
I get warnings:
WARNING (theano.gof.compilelock): Overriding existing lock by dead process '4844' (I am process '3908')
WARNING:theano.gof.compilelock:Overriding existing lock by dead process '4844' (I am process '3908')
and a long error, which ends with:
ImportError: ('The following error happened while compiling the node', CGemv{inplace}(AllocEmpty{dtype='float64'}.0, TensorConstant{1.0}, W.T, x, TensorConstant{0.0}), '\n', 'DLL load failed: The specified module could not be found.', '[CGemv{inplace}(<TensorType(float64, vector)>, TensorConstant{1.0}, W.T, x, TensorConstant{0.0})]')
Any ideas on how to fix this?
Theano on Windows need Theano development version and not last Theano version:
http://deeplearning.net/software/theano/install.html#bleeding-edge-install-instructions
So just update Theano and it should work.
Related
I am attempting to run some simple PyMC3 code in PyCharm on MacOS Big Sur but the execution fails and throws the following error:
Exception: ('Compilation failed (return status=1): ld: library not found for -lSystem. clang-10: error: linker command failed with exit code 1 (use -v to see invocation). ', '[Elemwise{add,no_inplace}(TensorConstant{1.0}, TensorConstant{1.0})]')
I am using PyCharm 2020.3.2. I am able to install pymc3 (version 3.8) and theano (1.0.4) into the environment. Code I am attempting to run follows:
import numpy as np
import scipy.stats as stats
import matplotlib.pyplot as plt
import pymc3 as pm
np.random.seed(123)
n_experiments = 4
theta_real = 0.35
data = stats.bernoulli.rvs(p=theta_real, size=n_experiments)
with pm.Model() as our_first_model:
theta = pm.Beta('theta', alpha=1, beta=1)
y = pm.Bernoulli('y', p=theta, observed=data)
start = pm.find_MAP()
step = pm.Metropolis()
trace = pm.sample(1000, step=step, start=start)
burnin = 100
chain = trace[burnin:]
pm.traceplot(chain, lines={'theta':theta_real});
I disabled Apple System Integrity Protection on some speculation that maybe Apple hiding /usr/include might be the source of the problem; it made no difference. No clue how else to fix this.
From the information in comments it seems like your anaconda is broken.
Update anaconda and try again.
If that doesn't work, try to install PyMC3 in the system Python not the Anaconda one.
This will use the system clang and not the Anaconda clang.
when I run this code :
from scipy.misc import imread, imsave, imresize
first = imread('aa.jpg')
sec = imresize(first, (3000,3000))
imsave('aaa.jpg',sec)
it shows error :
File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs
ImportError: DLL load failed: The specified module could not be found.
how can I solve this problem ????!
please help
Note : I also installed pillow
This typically a symptom of a broken scipy installation. Best reinstall it, using whatever means you used for i stalling it in first place.
So i finally managed to get theano up and running on the GPU using this guide. (the test code runs fine, telling me it used the GPU, YAY!!)
I then wanted to try it out and followed this guide for training a CNN on digit recognition.
problem is: i get errors from the way lasagne calls theano (i guess there is a version mismatch here):
Using gpu device 0: GeForce GT 730M (CNMeM is disabled, cuDNN not available)
Traceback (most recent call last):
File "C:\Users\Soren Jensen\Desktop\CNN-test\CNNTest-one.py", line 7, in <module>
import lasagne
File "C:\Users\Soren Jensen\Anaconda3\lib\site-packages\lasagne\__init__.py", line 19, in <module>
from . import layers
File "C:\Users\Soren Jensen\Anaconda3\lib\site-packages\lasagne\layers\__init__.py", line 7, in <module>
from .pool import *
File "C:\Users\Soren Jensen\Anaconda3\lib\site-packages\lasagne\layers\pool.py", line 6, in <module>
from theano.tensor.signal import downsample
ImportError: cannot import name 'downsample'
Press any key to continue . . .
From reading about the error message, it seems that 'downsample' was changed, so why is my lasagne still calling it??
trying to update my lasagne version gives:
C:\WINDOWS\system32>pip3.5 install Lasagne==0.1
Collecting Lasagne==0.1
Requirement already satisfied: numpy in c:\users\soren jensen\anaconda3\lib\site-packages (from Lasagne==0.1)
and running the code sample
import theano
import os
print(theano.config.compiledir)
print("Theano version %s" % theano.__version__)
theano_dir = os.path.dirname(theano.__file__)
print("theano is installed in %s" % theano_dir)
reveals that python3.5 uses theano v 0.9
Using gpu device 0: GeForce GT 730M (CNMeM is disabled, cuDNN not available)
C:\theano_compiledir\compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-3.5.2-64
Theano version 0.9.0.dev-e5bedc0de240eca42433c34c05fc00f4a5ef6cbe
theano is installed in C:\Users\Soren Jensen\Anaconda3\lib\site-packages\theano\theano
Press any key to continue . . .
Sorry for the long post, but i'm going a little crazy of this not working.. Maybe i am wrong in the version mismatch and the error is something else?
Try to reinstall Theano and Lasagne like this:
pip install --upgrade https://github.com/Theano/Theano/archive/master.zip
pip install --upgrade https://github.com/Lasagne/Lasagne/archive/master.zip
Because: "An even more recent version of Theano will often work as well, but at the time of writing, a simple pip install Theano will give you a version that is too old."
Read more: lasagne.readthedocs.io/en/latest/user/installation.html
I'm new to Theano and trying out some examples.
import numpy
import theano.tensor as T
from theano import function
import datetime
print datetime.datetime.now()
x = T.dscalar('x')
y = T.dscalar('y')
z = x + y
f = function([x, y], z)
print f(2, 3)
print numpy.allclose(f(16.3, 12.1), 28.4)
print datetime.datetime.now()
And it took 15 minutes to run this. I'm using a 2GB ram, and there aren't many processes running simultaneously.
Check the Theano Flags first.
If you didnt run with : THEANO_FLAGS=mode=FAST_RUN or ran with not the default flag or if you changed the .theanorc , it might take some time.
--
However, read here:
http://deeplearning.net/software/theano/tutorial/using_gpu.html
You can also see more about Theano Flags here:
http://deeplearning.net/software/theano/library/config.html
Since you must be running from an IDE, you will have to edit the .theanorc
As described on the Theano Link above:
"
It defaults to $HOME/.theanorc. On Windows, it defaults to $HOME/.theanorc:$HOME/.theanorc.txt to make Windows users’ life easier.
"
The exact flag is this :
config.mode
String value: 'Mode', 'ProfileMode' (deprecated), 'DebugMode', 'FAST_RUN', 'FAST_COMPILE'
In case this doesnt help, be sure to update Theano to bleeding edge and edit your question with the theanorc settings!
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
You can also use OpenMP to use extra Threads/cores :
THEANO_FLAGS=mode=FAST_RUN THEANO_FLAGS='openmp=True' OMP_NUM_THREADS=4 python x.py
i am trying to create an executable from my python script. My script runs fine, but after freezing it, starting the .exe gives me the following error:
http://www.bild.me/bild.php?file=4663406scipyerror.png
I am using Python 3.2.3, Scipy 0.12.0b1, Numpy 1.7.0 and Matplotlib 1.2.0 (all 32bit).
Any ideas/hints on how to solve this? My guess is i have to include something manually in my freezing script, but i am running out of guesses :-(
I got it finally to work, but I am very unsatisfied with my solution:
1) copy _odepack.pyd and odepack.py from the SciPy package to my program folder
2) in odepack.py change from . import _odepack to import _odepack (otherwise ValueError: Attempted relative import in non-package is raised)
3) in my main change from scipy.integrate import odeint to from odepack import odeint
Now it is working as expected and after using cx_freeze it is still working.
Still got no idea why it would not work before :-(
Thanks ThomasK for pushing me in the right direction though :-)
I finally got around this vode-problem by specifying "scipy.integrate.vode" as an include in the cx setup-file. This resulted in a file "scipy.integrate.vode.pyd" to end up in the build folder. I am using SciPy 0.11, Python 3.2.3 and the latest cx on Windows.
But adding such a "scipy.integrate.vode" file manually to the build folder would not fix the problem for me either, even though such manual-include-fixes were needed for many other .pyd files cx could not find either (and whereby the above setup.py include-solution would not work instead)...
Thanks for sharing your distress and wisdom, would not have managed to freeze my program otherwize...