import numpy as np
import time
import theano
A = np.random.rand(1000,10000).astype(theano.config.floatX)
B = np.random.rand(10000,1000).astype(theano.config.floatX)
np_start = time.time()
AB = A.dot(B)
np_end = time.time()
X,Y = theano.tensor.matrices('XY')
mf = theano.function([X,Y],X.dot(Y))
t_start = time.time()
tAB = mf(A,B)
t_end = time.time()
print("NP time: %f[s], theano time: %f[s] (times should be close when run on CPU!)" %(
np_end-np_start, t_end-t_start))
print("Result difference: %f" % (np.abs(AB-tAB).max(), ))
import keras
Using Theano backend.
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import keras
File "C:\Python\lib\site-packages\keras\__init__.py", line 4, in <module>
from . import engine
File "C:\Python\lib\site-packages\keras\engine\__init__.py", line 10, in <module>
from .training import Model
File "C:\Python\lib\site-packages\keras\engine\training.py", line 24, in <module>
from .. import callbacks as cbks
File "C:\Python\lib\site-packages\keras\callbacks.py", line 15, in <module>
from pkg_resources import parse_version
File "C:\Python\lib\site-packages\pkg_resources\__init__.py", line 34, in <module>
import plistlib
File "C:\Python\lib\plistlib.py", line 65, in <module>
from xml.parsers.expat import ParserCreate
File "C:\Python\lib\xml\parsers\expat.py", line 4, in <module>
from pyexpat import *
ImportError: DLL load failed: The specified module could not be found.I have a guide for setting up Theano with CUDA GPU (https://github.com/titu1994/Neural-Style-Transfer/blob/master/Guide.md) (please see the very last sections). It details every step required to install Theano with GPU support on Windows. Note you can replace Cuda 7.5 with 8 everywhere and it will still work.
You may not necessarily need to install pillow or h5py but I recommend installing them anyway since they are required for many image libraries and weight saving/loading in Keras.
Some Theano flags:
blas.ldflags= -LC:\Anaconda3\envs\corrnet\Library\bin -lmkl_rt
compiledir= C:\Users\Anon\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_42_Stepping_7_GenuineIntel-3.5.2-64
floatX= float32
device= cpu
Some OS information:
sys.platform= win32
sys.version= 3.5.2 | packaged by conda-forge | (default, Jun 30 2016, 17:50:59) [MSC v.1900 64 bit (AMD64)]
sys.prefix= C:\Anaconda3\envs\ainn
Some environment variables:
MKL_NUM_THREADS= None
OMP_NUM_THREADS= None
GOTO_NUM_THREADS= None
Numpy config: (used when the Theano flag "blas.ldflags" is empty)
blas_mkl_info:
include_dirs = ['C:/Anaconda3/envs/ainn\\Library\\include']
libraries = ['mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
library_dirs = ['C:/Anaconda3/envs/ainn\\Library\\lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
openblas_lapack_info:
NOT AVAILABLE
blas_opt_info:
include_dirs = ['C:/Anaconda3/envs/ainn\\Library\\include']
libraries = ['mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
library_dirs = ['C:/Anaconda3/envs/ainn\\Library\\lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
lapack_opt_info:
include_dirs = ['C:/Anaconda3/envs/ainn\\Library\\include']
libraries = ['mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
library_dirs = ['C:/Anaconda3/envs/ainn\\Library\\lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
lapack_mkl_info:
include_dirs = ['C:/Anaconda3/envs/ainn\\Library\\include']
libraries = ['mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
library_dirs = ['C:/Anaconda3/envs/ainn\\Library\\lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
Numpy dot module: numpy.core.multiarray
Numpy location: C:\Anaconda3\envs\ainn\lib\site-packages\numpy\__init__.py
Numpy version: 1.11.2
We executed 10 calls to gemm with a and b matrices of shapes (5000, 5000) and (5000, 5000).
Total execution time: 35.04s on CPU (with direct Theano binding to blas).
Try to run this script a few times. Experience shows that the first time is not as fast as followings calls. The difference is not big, but consistent.
Process finished with exit code 0
[global]
force_device = True
device = cpu
floatx = float32
warn_float64 = warn
[blas]
ldflags = -LC:\Anaconda3\envs\corrnet\Library\bin -lmkl_rt
[gcc]
cxxflags = -LC:\Anaconda3\envs\corrnet\Library\include -LC:\Anaconda3\envs\corrnet\Library\lib -lm
[nvcc]
flags=--use-local-env --cl-version=2010 -D_FORCE_INLINES
fastmath = True
TOP = $(_HERE_)/..
NVVMIR_LIBRARY_DIR = $(TOP)/nvvm/libdevice
PATH += $(TOP)/open64/bin;$(TOP)/nvvm/bin;$(_HERE_);$(TOP)/lib;
INCLUDES += "-I$(TOP)/include" $(_SPACE_)
INCLUDES += "-I$(TOP)/include" "-I$(TOP)/include/cudart" "-IC:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include" $(_SPACE_)
LIBRARIES =+ $(_SPACE_) "/LIBPATH:$(TOP)/lib/$(_WIN_PLATFORM_)"
CUDAFE_FLAGS +=
OPENCC_FLAGS +=
PTXAS_FLAGS +=