CRFasRNNLayer icon indicating copy to clipboard operation
CRFasRNNLayer copied to clipboard

error: explicitly instantiated more than once

Open XYZ-916 opened this issue 5 years ago • 8 comments

When I ran "sh build.sh", I got errors as follows:

CRFasRNNLayer/permutohedral_lattice/src/LatticeFilterKernel.cu(114): error: function "LatticeFilter<GPUDevice, T, pd, vd>::compute_position_vectors [with T=float, pd=6, vd=4]" explicitly instantiated more than once

CRFasRNNLayer/permutohedral_lattice/src/LatticeFilterKernel.cu(114): error: function "LatticeFilter<GPUDevice, T, pd, vd>::filter [with T=float, pd=6, vd=4]" explicitly instantiated more than once

CRFasRNNLayer/permutohedral_lattice/src/LatticeFilterKernel.cu(114): error: function "LatticeFilter<GPUDevice, T, pd, vd>::operator() [with T=float, pd=6, vd=4]" explicitly instantiated more than once

CRFasRNNLayer/permutohedral_lattice/src/LatticeFilterKernel.cu(115): error: function "LatticeFilter<GPUDevice, T, pd, vd>::LatticeFilter(tensorflow::OpKernelContext *, int, int, int, int, int *, const T *, const T *, __nv_bool) [with T=double, pd=6, vd=4]" explicitly instantiated more than once

CRFasRNNLayer/permutohedral_lattice/src/LatticeFilterKernel.cu(115): error: function "LatticeFilter<GPUDevice, T, pd, vd>::compute_position_vectors [with T=double, pd=6, vd=4]" explicitly instantiated more than once

CRFasRNNLayer/permutohedral_lattice/src/LatticeFilterKernel.cu(115): error: function "LatticeFilter<GPUDevice, T, pd, vd>::filter [with T=double, pd=6, vd=4]" explicitly instantiated more than once

CRFasRNNLayer/permutohedral_lattice/src/LatticeFilterKernel.cu(115): error: function "LatticeFilter<GPUDevice, T, pd, vd>::operator() [with T=double, pd=6, vd=4]" explicitly instantiated more than once

CRFasRNNLayer/permutohedral_lattice/src/LatticeFilterKernel.cu(69): error: type name is not allowed

CRFasRNNLayer/permutohedral_lattice/src/LatticeFilterKernel.cu(69): error: nonstandard form for taking the address of a member function

CRFasRNNLayer/permutohedral_lattice/src/LatticeFilterKernel.cu(69): error: expected an expression

CRFasRNNLayer/permutohedral_lattice/src/LatticeFilterKernel.cu(76): warning: parsing restarts here after previous syntax error

11 errors detected in the compilation of "/tmp/tmpxft_0000064d_00000000-6_LatticeFilterKernel.cpp1.ii". CMakeFiles/lattice_filter.dir/build.make:75: recipe for target 'CMakeFiles/lattice_filter.dir/src/LatticeFilterKernel.cu.o' failed make[2]: *** [CMakeFiles/lattice_filter.dir/src/LatticeFilterKernel.cu.o] Error 1 CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/lattice_filter.dir/all' failed make[1]: *** [CMakeFiles/lattice_filter.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2

And ideas about the problem? Thank you !

XYZ-916 avatar Jan 08 '19 08:01 XYZ-916

Are you just using the compilation script as is or did you make any changes?

MiguelMonteiro avatar Jan 08 '19 10:01 MiguelMonteiro

I made small changes in the script, which is as follows:

mkdir build_dir cd build_dir

CUDA_COMPILER=/usr/local/cuda/bin/nvcc CXX_COMPILER=/usr/bin/g++-4.9

SPATIAL_DIMS=3 INPUT_CHANNELS=1 REFERENCE_CHANNELS=3 MAKE_TESTS=False

cmake -DCMAKE_BUILD_TYPE=Debug -D CMAKE_CUDA_COMPILER=${CUDA_COMPILER}
-D CMAKE_CXX_COMPILER=${CXX_COMPILER}
-D CMAKE_CUDA_HOST_COMPILER=${CXX_COMPILER}
-D SPATIAL_DIMS=${SPATIAL_DIMS}
-D INPUT_CHANNELS=${INPUT_CHANNELS}
-D REFERENCE_CHANNELS=${REFERENCE_CHANNELS}
-D MAKE_TESTS=${MAKE_TESTS}
-G "CodeBlocks - Unix Makefiles" ../

make

XYZ-916 avatar Jan 09 '19 06:01 XYZ-916

Can you pull the latest code for both the CRFasRNN module and the permutohedral_lattice module. I changed the scripts a bit yesterday just to make them cleaner and compatible with python 3. I had no problems compiling.

MiguelMonteiro avatar Jan 09 '19 09:01 MiguelMonteiro

I have solved the problem of build error by pulling the latest code. Thank you very much! And when I train my 3D_UNet after adding the CRF_RNN_layer behind my sigmoid layer, I got error as follow:

crfasrnnLayer = CRF_RNN_Layer(image_dims=(input_shape[1],input_shape[2],input_shape[3]),num_classes = n_labels,theta_alpha=160.,theta_beta=3.0,theta_gamma=3.0,num_iterations=10,name='crfrnn')[output_layer,inputs] TypeError: 'CRF_RNN_Layer' object is not subscriptable

input_shape[0]:width, input_shape[1]:height, input_shape[2]: depth n_labels = 1

Partial of my model struct code: `output_layer = None for level_number in reversed(range(n_segmentation_levels)): segmentation_layer = segmentation_layers[level_number] if output_layer is None: output_layer = segmentation_layer else: output_layer = Add()([output_layer, segmentation_layer])

    if level_number > 0:
        output_layer = UpSampling3D(size=(2, 2, 2))(output_layer)

crfasrnnLayer = CRF_RNN_Layer(image_dims=(input_shape[1],input_shape[2],input_shape[3]),num_classes = n_labels,theta_alpha=160.,
                              theta_beta=3.0,theta_gamma=3.0,num_iterations=10,name='crfrnn')[output_layer,inputs]

activation_block = Activation(activation_name)(crfasrnnLayer)

model = Model(inputs=inputs, outputs=activation_block)
model.compile(optimizer=optimizer(lr=initial_learning_rate), loss=loss_function)
return model`

Any ideas ? Thank you !

XYZ-916 avatar Jan 09 '19 13:01 XYZ-916

Are you using Keras? I haven't used Keras in a while. It is just a matter of fixing up the Keras code.

MiguelMonteiro avatar Jan 09 '19 14:01 MiguelMonteiro

Yes. I'm using Keras. I saw there is a file named "crf_as_rnn_keras_layer.py" int your project and I used it as a layer in my model. And do you know how to fix the Keras code? Thank you!

XYZ-916 avatar Jan 10 '19 11:01 XYZ-916

I don't use Keras but it was working before. Maybe I changed something, I will have a look and let you know.

MiguelMonteiro avatar Jan 10 '19 11:01 MiguelMonteiro

Thank you very much and looking forward to your reply!

XYZ-916 avatar Jan 10 '19 11:01 XYZ-916