问题
I am trying to run this code:
x_set = np.random.rand(100,100,100)
x = T.dtensor3('x')
inp = x.reshape((100, 1, 100, 100))
W_stdDev = np.sqrt(2. / (3 * 3 * 2))
W = theano.shared(
np.asarray(
np.random.normal(loc=.0, scale=W_stdDev, size=(3,1,3,3)),
dtype=theano.config.floatX
),
borrow=True
)
conv_out = conv2d(
input=inp,
filters=W,
filter_shape=(3,1,3,3),
)
train_model = theano.function(
inputs=[x],
outputs=conv_out,
)
print(train_model(x_set))
but receive the error:
AssertionError: AbstractConv2d Theano optimization failed: there is no implementation available supporting the requested options. Did you exclude both "conv_dnn" and "conv_gemm" from the optimizer? If on GPU, is cuDNN available and does the GPU support it? If on CPU, do you have a BLAS library installed Theano can link against?
I am working on Windows 10 64bit and an Anaconda 4.1.1 installation with:
python 3.4.5; numpy 1.11.1; theano 0.9.0.dev2; mkl 11.3.3; mkl-service 1.1.2;
I tried to figure out how to link theano to mkl but got stuck. Because the numpy.show_config() says:
blas_opt_info:
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['C:\\Minonda\\envs\\_build\\Library\\include']
libraries = ['mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
library_dirs = ['C:\\Minonda\\envs\\_build\\Library\\lib']
openblas_lapack_info:
NOT AVAILABLE
lapack_mkl_info:
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['C:\\Minonda\\envs\\_build\\Library\\include']
libraries = ['mkl_lapack95_lp64', 'mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
library_dirs = ['C:\\Minonda\\envs\\_build\\Library\\lib']
mkl_info:
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['C:\\Minonda\\envs\\_build\\Library\\include']
libraries = ['mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
library_dirs = ['C:\\Minonda\\envs\\_build\\Library\\lib']
lapack_opt_info:
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['C:\\Minonda\\envs\\_build\\Library\\include']
libraries = ['mkl_lapack95_lp64', 'mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
library_dirs = ['C:\\Minonda\\envs\\_build\\Library\\lib']
blas_mkl_info:
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['C:\\Minonda\\envs\\_build\\Library\\include']
libraries = ['mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
library_dirs = ['C:\\Minonda\\envs\\_build\\Library\\lib']
but the Path 'C:\Minonda\envs\_build\Library\lib' does not exist on my system.
I tried also to find the mkl installation inside C:\Anaconda\pkgs, but there is just a mkl-11.3.3-1.tar.bz2 file.
Also I installed Intel MKL separately and tried to add
[blas]
ldflags = -LC:\Program Files(x86)\IntelSWTools\compilers_and_libraries_2016.3.207\windows\mkl\include
to my theanorc.txt, which leads to the error:
ValueError: ('The following error happened while compiling the node', CorrMM{valid, (1, 1), (1, 1)}(InplaceDimShuffle{0,x,1,2}.0, Elemwise{Cast{float64}}.0), '\n', 'invalid token "Files" in ldflags_str: "-LC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.3.207\windows\mkl\include"')
How am I able to link the anaconda mkl or the intel mkl correctly to my theano?
回答1:
Yes, theano cannot deal with spaces in the file path...ProgramFiles
(x86)
I tried to find answers everywhere about how to escape the space character, and I was unable to do it. At the end, I found out the symbolic link, which creates some kind of directory that points to another directory.
- Run
cmd
as administrator. - Type the command
mklink /D "C:\LinkToProgramFilesX86" "C:\Program Files (x86)"
(or any other name you want to the link, but make sure you won't add any spaces to that, lol)
This will create the link and you will be able to see this new dir in Windows Explorer as if it were a shortcut, but working as an actual folder.
Then add this to your [blas] configuration:
ldflags = -L"C:\LinkToProgramFilesX86\IntelSWTools\compilers_and_libraries_2016.3.207\windows\mkl\include"
Not sure if it's the right dir, though, but it definitely solves the problem with spaces. In my case, I used:
-L"C:/LinkToProgramFilesX86/IntelSWTools/compilers_and_libraries_2017/windows/mkl/lib/intel64_win" -lmkl_lapack95_lp64 -lmkl_blas95_lp64 -lmkl_rt -lm -lm
...with the double quotes.
Now, because life isn't easy, a new problem appeared: We did not found a dynamic library into the library_dir of the library we use for blas.
I solved that going to the numpy installation directory, and changing the same thing in the file __config__.py
. (Replaced all Program Files (x86)
with the new link LinkToProgramFilesX86
)
The message stopped showing after that :)
来源:https://stackoverflow.com/questions/39020075/receive-assertionerror-while-optimizing-convolution-in-theano