CEA-LIST / N2D2

N2D2 is an open source CAD framework for Deep Neural Network simulation and full DNN-based applications building.
Other
146 stars 35 forks source link

Test the CPP_cuDNN exported network error #25

Closed Changyiyu closed 3 years ago

Changyiyu commented 5 years ago

Hello:

I want to test the exported network, but i have problem. How to solve this problem?

qwdr7777@ubuntu:~/N2D2-master/build/bin/export_CPP_cuDNN_float0$ sudo make ./n2d2_cudnn_test [sudo] password for qwdr7777: g++ -I./include/ -I./include/dnn/ -I./include/utils/ -std=c++0x n2d2_cudnn_test.cpp -o n2d2_cudnn_test In file included from ./include/cpp_utils.hpp:22:0, from ./include/n2d2_cudnn_inference.hpp:25, from n2d2_cudnn_test.cpp:32: ./include/typedefs.h:88:21: fatal error: ap_cint.h: No such file or directory

include

                 ^

compilation terminated. make: *** [n2d2_cudnn_test] Error 1

davidbriand-cea commented 5 years ago

Hello Changyuyu,

I think your exported network has been generated for a precision of 0 bits (which is impossible).

Only 32 floating point precision is actually supported by the cuDNN export. When you run your export command add the numerical precision argument: "-export CPP_cuDNN -nbbits -32" -32 is for 32 bits Floating Point precision, -16 is for 16 bits Floating Point precision, 8 is for 8 bits Integer precision etc... This indicates to the code generator to export weights and bias under 32 bits floating precision format.

Changyiyu commented 5 years ago

Hello:

Thank you for your reply. I export network again and have a new problem. How to solve this problem?

qwdr7777@ubuntu:~/N2D2-master/build/bin/export_CPP_cuDNN_float32$ sudo make ./n2d2_cudnn_test g++ -I./include/ -I./include/dnn/ -I./include/utils/ -std=c++0x n2d2_cudnn_test.cpp -o n2d2_cudnn_test n2d2_cudnn_test.cpp: In function ‘int main(int, char*)’: n2d2_cudnn_test.cpp:116:69: warning: non-constant array size in new, unable to verify length of initializer-list [enabled by default] confusion[t] = new unsigned int[outTarget[t]outTarget[t]]{0}; ^ n2d2_cudnn_test.cpp:187:55: warning: non-constant array size in new, unable to verify length of initializer-list [enabled by default] double success = new double[outDimZ.size()]{0}; ^ /tmp/ccxpO4yT.o: In function main': n2d2_cudnn_test.cpp:(.text+0x435): undefined reference ton2d2_cudnn_inference::n2d2_cudnn_inference(unsigned int, unsigned int, bool)' n2d2_cudnn_test.cpp:(.text+0x460): undefined reference to n2d2_cudnn_inference::inputDimX()' n2d2_cudnn_test.cpp:(.text+0x471): undefined reference ton2d2_cudnn_inference::inputDimY()' n2d2_cudnn_test.cpp:(.text+0x483): undefined reference to n2d2_cudnn_inference::inputDimZ()' n2d2_cudnn_test.cpp:(.text+0x4f3): undefined reference ton2d2_cudnn_inference::outputDimX()' n2d2_cudnn_test.cpp:(.text+0x50c): undefined reference to n2d2_cudnn_inference::outputDimY()' n2d2_cudnn_test.cpp:(.text+0x522): undefined reference ton2d2_cudnn_inference::outputDimZ()' n2d2_cudnn_test.cpp:(.text+0x538): undefined reference to n2d2_cudnn_inference::outputTarget()' n2d2_cudnn_test.cpp:(.text+0x58d): undefined reference ton2d2_cudnn_inference::inputDimX()' n2d2_cudnn_test.cpp:(.text+0x5a2): undefined reference to n2d2_cudnn_inference::inputDimY()' n2d2_cudnn_test.cpp:(.text+0x843): undefined reference ton2d2_cudnn_inference::inputDimX()' n2d2_cudnn_test.cpp:(.text+0x854): undefined reference to n2d2_cudnn_inference::inputDimY()' n2d2_cudnn_test.cpp:(.text+0x885): undefined reference toenvRead(std::string const&, unsigned int, unsigned int, unsigned int, float, unsigned int, int)' n2d2_cudnn_test.cpp:(.text+0x89e): undefined reference to `n2d2_cudnn_inference::execute(float)' n2d2_cudnn_test.cpp:(.text+0x8e0): undefined reference to n2d2_cudnn_inference::estimated(unsigned int*, unsigned int)' n2d2_cudnn_test.cpp:(.text+0x92f): undefined reference ton2d2_cudnn_inference::inputDimY()' n2d2_cudnn_test.cpp:(.text+0x98e): undefined reference to n2d2_cudnn_inference::inputDimX()' n2d2_cudnn_test.cpp:(.text+0xe3f): undefined reference toconfusion_print(unsigned int, unsigned int)' n2d2_cudnn_test.cpp:(.text+0xeee): undefined reference to getFilesList(std::string, std::vector<std::string, std::allocator<std::string> >&)' n2d2_cudnn_test.cpp:(.text+0x10eb): undefined reference ton2d2_cudnn_inference::inputDimX()' n2d2_cudnn_test.cpp:(.text+0x10fc): undefined reference to n2d2_cudnn_inference::inputDimY()' n2d2_cudnn_test.cpp:(.text+0x111f): undefined reference toenvRead(std::string const&, unsigned int, unsigned int, unsigned int, float, unsigned int, int)' n2d2_cudnn_test.cpp:(.text+0x1164): undefined reference to `n2d2_cudnn_inference::execute(float)' n2d2_cudnn_test.cpp:(.text+0x11a3): undefined reference to n2d2_cudnn_inference::estimated(unsigned int*, unsigned int)' n2d2_cudnn_test.cpp:(.text+0x12bf): undefined reference ton2d2_cudnn_inference::inputDimY()' n2d2_cudnn_test.cpp:(.text+0x131e): undefined reference to n2d2_cudnn_inference::inputDimX()' n2d2_cudnn_test.cpp:(.text+0x1a0e): undefined reference toconfusion_print(unsigned int, unsigned int*)' n2d2_cudnn_test.cpp:(.text+0x1a48): undefined reference to n2d2_cudnn_inference::getProfiling(unsigned int)' /tmp/ccxpO4yT.o: In functionn2d2_cudnn_inference::~n2d2_cudnn_inference()': n2d2_cudnn_test.cpp:(.text._ZN20n2d2_cudnn_inferenceD2Ev[_ZN20n2d2_cudnn_inferenceD5Ev]+0xd): undefined reference to `free_memory()' collect2: error: ld returned 1 exit status make: *** [n2d2_cudnn_test] Error 1

davidbriand-cea commented 5 years ago

There is no rules for make ./n2d2_cudnn_test Try with this command if you want automatically compile and run binary: sudo make && ./bin/n2d2_cudnn_test

Changyiyu commented 5 years ago

I try to export it again and it has problem.

qwdr7777@ubuntu:~/N2D2-master/models$ sudo ./n2d2 "mnist24_16c4s2_24c5s2_150_10.ini" -export CPP_cuDNN -nbbits -32 Option -export: generate an export and exit [CPP_cuDNN] Option -nbbits: number of bits per weight for exports [-32] Loading network configuration file mnist24_16c4s2_24c5s2_150_10.ini Warning: to use Frame_CUDA models, N2D2 must be compiled with CUDA enabled. Using Frame model instead. Layer: conv1 [Conv(Frame)] Notice: Could not open configuration file: conv1.cfg

Shared synapses: 256

Virtual synapses: 30976

Inputs dims: 24 24 1

Outputs dims: 11 11 16

Warning: No monitor could be added to Cell: conv1 Layer: conv2 [Conv(Frame)] Notice: Could not open configuration file: conv2.cfg

Shared synapses: 2250

Virtual synapses: 36000

Inputs dims: 11 11 16

Outputs dims: 4 4 24

Warning: No monitor could be added to Cell: conv2 Layer: fc1 [Fc(Frame)] Notice: Could not open configuration file: fc1.cfg

Synapses: 57600

Inputs dims: 4 4 24

Outputs dims: 1 1 150

Warning: No monitor could be added to Cell: fc1 Layer: fc1.drop [Dropout(Frame)] Notice: Could not open configuration file: fc1.drop.cfg

Inputs dims: 1 1 150

Outputs dims: 1 1 150

Warning: No monitor could be added to Cell: fc1.drop Layer: fc2 [Fc(Frame)] Notice: Could not open configuration file: fc2.cfg

Synapses: 1500

Inputs dims: 1 1 150

Outputs dims: 1 1 10

Warning: No monitor could be added to Cell: fc2 Layer: softmax [Softmax(Frame)] Notice: Could not open configuration file: softmax.cfg

Inputs dims: 1 1 10

Outputs dims: 1 1 10

Target: softmax (target value: 1 / default value: 0 / top-n value: 1) Warning: No monitor could be added to Cell: softmax Total number of neurons: 2640 Total number of nodes: 2640 Total number of synapses: 61606 Total number of virtual synapses: 126076 Total number of connections: 126076 Notice: Unused section softmax.Target in INI file Learning database size: 48000 images Validation database size: 12000 images Testing database size: 10000 images Database::logROIsStats(): no ROI Database::logROIsStats(): no ROI Exporting Test dataset to "export_CPP_cuDNN_float32/stimuli"Notice: stimuli depth is 8U (according to database first stimulus) .................... Generating CPP_cuDNN export to "export_CPP_cuDNN_float32": -> Generating cell conv1 -> Generating cell conv2 -> Generating cell fc1 Error: "Dropout" cell type is not exportable for "CPP_cuDNN" export (if not used for inference, consider removing it before export) -> Generating cell fc2 -> Generating cell softmax -> Generating network Invalid registrar key "Dropout" Time elapsed: 4.04768 s Error: bad_function_call

Changyiyu commented 5 years ago

So i try to test the exported network have problem.

qwdr7777@ubuntu:~/N2D2-master/models/export_CPP_cuDNN_float32$ sudo make && ./bin/n2d2_cudnn_test make -C dnn make[1]: Entering directory `/home/qwdr7777/N2D2-master/models/export_CPP_cuDNN_float32/dnn' g++ -c -o bin_dnn.obj/src/network.o src/network.cpp -I./include/ -isystem /usr/local/cuda/include -std=c++0x -fPIC -fsigned-char src/network.cpp:13:24: fatal error: fc1_drop.hpp: No such file or directory

include "fc1_drop.hpp"

                    ^

compilation terminated. make[1]: [bin_dnn.obj/src/network.o] Error 1 make[1]: Leaving directory `/home/qwdr7777/N2D2-master/models/export_CPP_cuDNN_float32/dnn' make: [dnnlib] Error 2

davidbriand-cea commented 5 years ago

Code generator doesn't support Dropout layer, this layer is only use for the learning phase. You have to comment or delete the fc1.drop layer in the mnist24_16c4s2_24c5s2_150_10.ini file and replace fc2 Input like that : [fc2] Input=fc1 Type=Fc ...

Changyiyu commented 5 years ago

Thank you for your help. It solve export problem. But have new problem when I test the exported network:

qwdr7777@ubuntu:~/N2D2-master/models/export_CPP_cuDNN_float32$ sudo make && ./bin/n2d2_cudnn_test make -C dnn make[1]: Entering directory /home/qwdr7777/N2D2-master/models/export_CPP_cuDNN_float32/dnn' make[1]:bin_dnn/libnetworktCUDNN.so' is up to date. make[1]: Leaving directory /home/qwdr7777/N2D2-master/models/export_CPP_cuDNN_float32/dnn' g++ -c -o bin.obj/src/cpp_utils.o src/cpp_utils.cpp -I./include/ -I./include/dnn/ -I./include/utils/ -std=c++0x g++ -c -o bin.obj/src/n2d2_cudnn_inference.o src/n2d2_cudnn_inference.cpp -I./include/ -I./include/dnn/ -I./include/utils/ -std=c++0x g++ -c -o bin.obj/n2d2_cudnn_test.o n2d2_cudnn_test.cpp -I./include/ -I./include/dnn/ -I./include/utils/ -std=c++0x n2d2_cudnn_test.cpp: In function ‘int main(int, char**)’: n2d2_cudnn_test.cpp:116:69: warning: non-constant array size in new, unable to verify length of initializer-list [enabled by default] confusion[t] = new unsigned int[outTarget[t]*outTarget[t]]{0}; ^ n2d2_cudnn_test.cpp:187:55: warning: non-constant array size in new, unable to verify length of initializer-list [enabled by default] double* success = new double[outDimZ.size()]{0}; ^ g++ -o bin/n2d2_cudnn_test bin.obj/src/cpp_utils.o bin.obj/src/n2d2_cudnn_inference.o bin.obj/n2d2_cudnn_test.o -std=c++0x -L./dnn/bin_dnn/ -lnetworktCUDNN "-Wl,-rpath,dnn/bin_dnn/" /usr/bin/ld: warning: libcudart.so.7.5, needed by ./dnn/bin_dnn//libnetworktCUDNN.so, not found (try using -rpath or -rpath-link) /usr/bin/ld: warning: libcublas.so.7.5, needed by ./dnn/bin_dnn//libnetworktCUDNN.so, not found (try using -rpath or -rpath-link) ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference tocudaFree' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference to cublasCreate_v2' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference to__cudaRegisterFunction' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference to cudaSetupArgument' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference tocudaConfigureCall' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference to __cudaUnregisterFatBinary' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference tocudaGetErrorString' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference to cudaLaunch' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference tocudaGetDeviceProperties' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference to __cudaInitModule' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference tocudaSetDevice' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference to __cudaRegisterFatBinary' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference tocublasSgemm_v2' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference to cudaDeviceReset' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference tocudaDeviceSynchronize' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference to cudaMemcpy' ./dnn/bin_dnn//libnetworktCUDNN.so: undefined reference tocudaMalloc' collect2: error: ld returned 1 exit status make: *** [bin/n2d2_cudnn_test] Error 1

davidbriand-cea commented 5 years ago

Did you install CUDA and CUDNN library on your computer ?

Changyiyu commented 5 years ago

Sorry, I have not responded for such a long time. Yes, I install the CUDA and CUDNN library on my computer that according to the N2D2 manual. As the following commands:

• wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repoubuntu1404_7.5-18_amd64.deb • dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb • wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1404/x86_64/ nvidia-machine-learning-repo-ubuntu1404_4.0-2_amd64.deb • dpkg -i nvidia-machine-learning-repo-ubuntu1404_4.0-2_amd64.deb • apt-get install cuda-core-7-5 cuda-cudart-dev-7-5 cuda-cublas-dev-7-5 cuda-curand-dev-7-5 libcudnn5-dev

olivierbichler-cea commented 3 years ago

Closing this issue, which has been inactive for a long time. The undefined reference issue seems related to the user's setup.