Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError: AbstractConv2d Theano optimization failed #7

Open
nywang2019 opened this issue May 16, 2020 · 8 comments
Open

AssertionError: AbstractConv2d Theano optimization failed #7

nywang2019 opened this issue May 16, 2020 · 8 comments

Comments

@nywang2019
Copy link

Thanks for sharing the good code.

  1. I created a new virtual env and installed all components.
  2. I modified keras.json as recommended.
    but some errors occurred when I ran, any one can help me? @ljsabc :
    ====================================
    Using Theano backend.
    WARNING (theano.configdefaults): g++ not available, if using conda: conda install m2w64-toolchain
    WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python im
    plementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
    ./Arisa\Arisa_005.jpg
    ERROR (theano.gof.opt): Optimization failure due to: local_abstractconv_check
    ERROR (theano.gof.opt): node: AbstractConv2d{convdim=2, border_mode='half', subsample=(1, 1), filter_flip=True, imshp=(None, None, None, None), kshp=(24, 1, 3, 3), f
    ilter_dilation=(1, 1)}(Elemwise{add,no_inplace}.0, convolution2d_1_W)
    ERROR (theano.gof.opt): TRACEBACK:
    ERROR (theano.gof.opt): Traceback (most recent call last):
    File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\gof\opt.py", line 1982, in process_node
    replacements = lopt.transform(node)
    File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\tensor\nnet\opt.py", line 609, in local_abstractconv_check
    raise AssertionError(
    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?

Traceback (most recent call last):
File "test_mse.py", line 85, in
test(sys.argv[1])
File "test_mse.py", line 65, in test
out = model.predict(patch, batch_size=batch_size)
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\keras\engine\training.py", line 1216, in predict
self._make_predict_function()
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\keras\engine\training.py", line 748, in _make_predict_function
self.predict_function = K.function(inputs,
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\keras\backend\theano_backend.py", line 929, in function
return Function(inputs, outputs, updates=updates, **kwargs)
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\keras\backend\theano_backend.py", line 912, in init
self.function = theano.function(inputs, outputs, updates=updates,
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\compile\function.py", line 315, in function
fn = pfunc(params=inputs,
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\compile\pfunc.py", line 483, in pfunc
return orig_function(inputs, cloned_outputs, mode,
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\compile\function_module.py", line 1788, in orig_function
fn = Maker(inputs,
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\compile\function_module.py", line 1474, in init
optimizer_profile = optimizer(fgraph)
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\gof\opt.py", line 98, in call
return self.optimize(fgraph)
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\gof\opt.py", line 87, in optimize
ret = self.apply(fgraph, *args, **kwargs)
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\gof\opt.py", line 235, in apply
sub_prof = optimizer.optimize(fgraph)
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\gof\opt.py", line 87, in optimize
ret = self.apply(fgraph, *args, **kwargs)
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\gof\opt.py", line 2095, in apply
nb += self.process_node(fgraph, node)
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\gof\opt.py", line 1985, in process_node
self.failure_callback(e, self,
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\gof\opt.py", line 1881, in warn_inplace
return NavigatorOptimizer.warn(exc, nav, repl_pairs, local_opt, node)
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\gof\opt.py", line 1867, in warn
raise exc
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\gof\opt.py", line 1982, in process_node
replacements = lopt.transform(node)
File "D:\Anaconda3\envs\MangoLineExtraction\lib\site-packages\theano\tensor\nnet\opt.py", line 609, in local_abstractconv_check
raise AssertionError(
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?

@ljsabc
Copy link
Owner

ljsabc commented May 18, 2020

I guess you need to stick to CuDNN 5. It would be better if you can provide more env-related information.
Also, as Theano and Keras 1.x are not supported, it's highly recommended to migrate the weight to something like tf or pytorch.

@nywang2019
Copy link
Author

thank you@ljsabc. i searched Stackoverflow about this problem and found a solution in which it is suggested to add "optimizer = None" to file .theanorc. i did so, however a new problem occurred. when executing test_mse.py, something like "Arisa_005.jpg" appears on the screen (seems it begin to run), and then it stops there, nothing new happens. i have to stop it. so ,what is the reason? do you have some suggestions?

@ljsabc
Copy link
Owner

ljsabc commented May 18, 2020

The first execution takes time. Please take a look at the CPU usage.

@nywang2019
Copy link
Author

nywang2019 commented May 18, 2020

how long it takes for the first execution? I waited more than 10 minutes, and still, nothing happened. here is a screenshot:
image

the cpu occupation rate is about 10%.

@ljsabc
Copy link
Owner

ljsabc commented May 19, 2020

I don't think you have fully understood the internal mechanism of code optimization.

  1. g++ and nvcc is mandatory for a successful execution
  2. nvcc/g++/other compilations will be run for the first time, taking around 10 mins on my testbed
  3. 10% for all cores, or for a single core? Typically during compilation you will have 1 core fully occupied.
  4. after the code has been compiled, with a decent GPU you can achieve <1s/1Mpixel speed.

@nywang2019
Copy link
Author

  1. you mean i should install something like g++ and nvcc? what should I do? i have installed cuda and cudnn.
  2. there is 4 cores, total occupation rate is 10%
  3. i added the following code into .theanorc file.
    "[global]
    floatX = float32
    device = cpu
    optimizer = None"
    or
    "[global]
    floatX = float32
    device = cuda
    optimizer = None"
    there is no difference, nothing changed. tell me if i am wrong.

@ljsabc
Copy link
Owner

ljsabc commented May 19, 2020

I'm sorry but I think you need to sort it out yourself.

Attached is my keras.json and .theanorc (For Windows)

.theanorc

[global]
floatX = float32
device = gpu
 
[nvcc]
compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
fastmath = True

[compile]
cxxflags = -O3 -ffast-math -ftree-loop-distribution -ftracer
mode = FAST_RUN

[dnn]
enabled = True
include_path=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include
library_path=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64

[lib]
cnmem = 0.7

keras.json

{
    "image_dim_ordering": "th", 
    "epsilon": 1e-07, 
    "floatx": "float32", 
    "backend": "theano"
}

@nywang2019
Copy link
Author

i am still in trouble, but many thanks for your rapid response and help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants