ginkgo-project / ginkgo

Numerical linear algebra software package
https://ginkgo-project.github.io/
BSD 3-Clause "New" or "Revised" License
400 stars 89 forks source link

My Project cannot access ginkgo library #596

Closed nghiakvnvsd closed 4 years ago

nghiakvnvsd commented 4 years ago

Hello everyone!!! I am a newbie using ginkgo library. I have run the examples but I have some problem when I create a new program. Web tutorials only focus on code but not the steps to create a program. I try creating a cpp file and running the code (https://github.com/ginkgo-project/ginkgo/wiki/Tutorial-2:-Implement:-Matrices) but it did not work. It supported: fatal error: ginkgo/ginkgo.hpp: No such file or directory #include <ginkgo/ginkgo.hpp> . Thank you!!!

upsj commented 4 years ago

Unfortunately, our tutorials skip over some important steps to set up the build environment, most importantly

  1. If you have Ginkgo installed (make install) on your system, you need to specify the include/ path of your installation prefix (-Ipath/include) that you potentially set using -DCMAKE_INSTALL_PREFIX=path (the default value is /usr/local on Linux). If Ginkgo is not installed, you need to specify the both the path to ginkgo/include and ginkgo/build/include or which ever folder you called cmake from.
  2. You need to link to the Ginkgo libraries. For this, you need to set the library path -Lpath/lib again based on the installation prefix, and explicitly link to the libraries like -lginkgo -lginkgo_reference ... for all executors that you compiled. If Ginkgo is not installed, you need to manually copy the library files (libginkgo*.so*) to a common directory and reference this directory both as a linking path with -L as well as an -rpath if you built Ginkgo with shared libraries (which is the default).

You can see how this works in the build.sh files in examples/

Either way, I cannot recommend using CMake enough, as it takes care of almost all issues for you. But still, we will update the tutorials to reflect the build setup in more detail.

nghiakvnvsd commented 4 years ago

I am sorry to bother you but I do not understand that way. I have ubuntu 18.04. I installed ginkgo on your system. I can access ginkgo in terminal: cd ginkgo. I have run all examples in build/examples and all is ok. for example: my name program: "test" belongs to desktop. I access my program in terminal: cd Desktop/test. In directory test, I have the file: main.cpp. I try running main.cpp something like: "g++ main.cpp -o main" and it has error because it understands ginkgo library. So how can I fix the link to the ginkgo libraries?

upsj commented 4 years ago

By installed, do you mean you executed sudo make install successfully? Is ginkgo.hpp present in /usr/local/include/ginkgo/? At the very least, you have to link to the Ginkgo shared libraries. g++ main.cpp -o main -lginkgo -lginkgo_reference -lginkgo_omp -lginkgo_cuda -lginkgo_hip

nghiakvnvsd commented 4 years ago

When I execute: "sudo make install", it reported: "make: *** No rule to make target 'install'. Stop." ... And ginkgo directory does not exist in /usr/local/include

upsj commented 4 years ago

Are you executing sudo make install in the build directory in ginkgo? Did you successfully follow the steps from the first tutorial to configure and compile Ginkgo?

nghiakvnvsd commented 4 years ago

Yes, I do all. I also run all the examples. Do you have teamviewer? you can access my computer and try it. Thank you about this!

upsj commented 4 years ago

Sorry, I cannot do 1:1 support right now - we will need to untangle a few other issues first. On my first question:

nghiakvnvsd commented 4 years ago
  1. I executed in build directory.
  2. do you mean: run main.cpp by make something like: make main.cpp ?
  3. Yes
upsj commented 4 years ago
  1. No, I mean just executing make without any parameters
nghiakvnvsd commented 4 years ago

the output: [ 0%] Built target ginkgo_hip_device [ 1%] Built target ginkgo_hip [ 1%] Built target ginkgo_cuda_device [ 9%] Built target ginkgo_cuda [ 9%] Built target ginkgo_omp_device [ 15%] Built target ginkgo_omp [ 15%] Built target ginkgo_reference_device [ 21%] Built target ginkgo_reference [ 29%] Built target ginkgo [ 29%] Built target cuda_test_base_exception_helpers [ 30%] Built target cuda_test_base_math [ 31%] Built target cuda_test_base_cuda_executor [ 31%] Built target cuda_test_components_merging_kernels [ 31%] Built target cuda_test_components_sorting_kernels [ 31%] Built target cuda_test_components_prefix_sum [ 32%] Built target cuda_test_components_precision_conversion [ 33%] Built target cuda_test_components_cooperative_groups_kernels [ 34%] Built target cuda_test_components_searching_kernels [ 34%] Built target cuda_test_components_fill_array [ 35%] Built target cuda_test_factorization_par_ilut_kernels [ 35%] Built target cuda_test_factorization_par_ict_kernels [ 36%] Built target cuda_test_factorization_ilu_kernels [ 36%] Built target cuda_test_factorization_par_ilu_kernels [ 37%] Built target cuda_test_matrix_csr_kernels [ 38%] Built target cuda_test_matrix_hybrid_kernels [ 38%] Built target cuda_test_matrix_coo_kernels [ 38%] Built target cuda_test_matrix_dense_kernels [ 38%] Built target cuda_test_matrix_ell_kernels [ 38%] Built target cuda_test_matrix_sellp_kernels [ 39%] Built target cuda_test_preconditioner_isai_kernels [ 39%] Built target cuda_test_preconditioner_jacobi_kernels [ 39%] Built target cuda_test_solver_cg_kernels [ 39%] Built target cuda_test_solver_bicg_kernels [ 39%] Built target cuda_test_solver_cgs_kernels [ 39%] Built target cuda_test_solver_gmres_kernels [ 40%] Built target cuda_test_solver_ir_kernels [ 40%] Built target cuda_test_solver_lower_trs_kernels [ 40%] Built target cuda_test_solver_upper_trs_kernels [ 41%] Built target cuda_test_solver_fcg_kernels [ 42%] Built target cuda_test_solver_bicgstab_kernels [ 42%] Built target cuda_test_stop_residual_norm_kernels [ 43%] Built target cuda_test_stop_criterion_kernels [ 43%] Built target cuda_test_utils_assertions_test [ 43%] Built target core_test_base_types [ 44%] Built target core_test_base_sanitizers [ 45%] Built target core_test_base_utils [ 45%] Built target core_test_base_range [ 46%] Built target core_test_base_polymorphic_object [ 46%] Built target core_test_base_allocator [ 47%] Built target core_test_base_combination [ 48%] Built target core_test_base_dim [ 48%] Built target core_test_base_array [ 48%] Built target core_test_base_extended_float [ 48%] Built target core_test_base_perturbation [ 48%] Built target core_test_base_exception [ 48%] Built target core_test_base_version [ 48%] Built target core_test_base_exception_helpers [ 49%] Built target core_test_base_abstract_factory [ 50%] Built target core_test_base_executor [ 50%] Built target core_test_base_iterator_factory [ 50%] Built target core_test_base_composition [ 51%] Built target core_test_base_lin_op [ 51%] Built target core_test_base_math [ 51%] Built target core_test_base_range_accessors [ 52%] Built target core_test_base_matrix_data [ 52%] Built target core_test_base_mtx_io [ 53%] Built target core_test_factorization_par_ilut [ 53%] Built target core_test_factorization_par_ilu [ 53%] Built target core_test_log_logger [ 53%] Built target core_test_log_stream [ 53%] Built target core_test_log_convergence [ 54%] Built target core_test_log_record [ 54%] Built target core_test_matrix_hybrid [ 54%] Built target core_test_matrix_dense [ 54%] Built target core_test_matrix_identity [ 55%] Built target core_test_matrix_coo [ 56%] Built target core_test_matrix_permutation [ 57%] Built target core_test_matrix_ell [ 57%] Built target core_test_matrix_coo_builder [ 57%] Built target core_test_matrix_sparsity_csr [ 57%] Built target core_test_matrix_sellp [ 57%] Built target core_test_matrix_csr [ 58%] Built target core_test_matrix_csr_builder [ 58%] Built target core_test_preconditioner_isai [ 59%] Built target core_test_preconditioner_ilu [ 60%] Built target core_test_preconditioner_jacobi [ 61%] Built target core_test_solver_cg [ 61%] Built target core_test_solver_cgs [ 62%] Built target core_test_solver_gmres [ 62%] Built target core_test_solver_ir [ 62%] Built target core_test_solver_bicgstab [ 63%] Built target core_test_solver_lower_trs [ 63%] Built target core_test_solver_upper_trs [ 63%] Built target core_test_solver_fcg [ 63%] Built target core_test_solver_bicg [ 64%] Built target core_test_stop_iteration [ 64%] Built target core_test_stop_combined [ 64%] Built target core_test_stop_time [ 64%] Built target core_test_stop_stopping_status [ 65%] Built target core_test_utils_assertions_test [ 65%] Built target core_test_utils_matrix_generator_test [ 65%] Built target reference_test_base_composition [ 65%] Built target reference_test_base_combination [ 66%] Built target reference_test_base_perturbation [ 66%] Built target reference_test_components_precision_conversion [ 66%] Built target reference_test_components_fill_array [ 67%] Built target reference_test_components_prefix_sum [ 68%] Built target reference_test_factorization_par_ilu_kernels [ 68%] Built target reference_test_factorization_par_ict_kernels [ 68%] Built target reference_test_factorization_par_ilut_kernels [ 68%] Built target reference_test_log_convergence [ 68%] Built target reference_test_matrix_hybrid_kernels [ 69%] Built target reference_test_matrix_ell_kernels [ 69%] Built target reference_test_matrix_permutation [ 70%] Built target reference_test_matrix_identity [ 71%] Built target reference_test_matrix_coo_kernels [ 71%] Built target reference_test_matrix_csr_kernels [ 71%] Built target reference_test_matrix_dense_kernels [ 71%] Built target reference_test_matrix_sparsity_csr_kernels [ 71%] Built target reference_test_matrix_sellp_kernels [ 72%] Built target reference_test_matrix_sparsity_csr [ 73%] Built target reference_test_preconditioner_isai_kernels [ 73%] Built target reference_test_preconditioner_ilu [ 73%] Built target reference_test_preconditioner_jacobi [ 74%] Built target reference_test_preconditioner_jacobi_kernels [ 75%] Built target reference_test_solver_gmres_kernels [ 76%] Built target reference_test_solver_lower_trs [ 76%] Built target reference_test_solver_cgs_kernels [ 77%] Built target reference_test_solver_cg_kernels [ 77%] Built target reference_test_solver_bicg_kernels [ 77%] Built target reference_test_solver_fcg_kernels [ 77%] Built target reference_test_solver_bicgstab_kernels [ 77%] Built target reference_test_solver_lower_trs_kernels [ 77%] Built target reference_test_solver_upper_trs [ 78%] Built target reference_test_solver_upper_trs_kernels [ 78%] Built target reference_test_solver_ir_kernels [ 79%] Built target reference_test_stop_criterion_kernels [ 79%] Built target reference_test_stop_combined [ 79%] Built target reference_test_stop_iteration [ 79%] Built target reference_test_stop_residual_norm_kernels [ 80%] Built target reference_test_stop_time [ 80%] Built target reference_test_utils_assertions_test [ 80%] Built target omp_test_components_precision_conversion [ 80%] Built target omp_test_components_prefix_sum [ 81%] Built target omp_test_components_fill_array [ 81%] Built target omp_test_factorization_par_ilu_kernels [ 82%] Built target omp_test_factorization_par_ict_kernels [ 82%] Built target omp_test_factorization_par_ilut_kernels [ 82%] Built target omp_test_matrix_sparsity_csr_kernels [ 82%] Built target omp_test_matrix_csr_kernels [ 82%] Built target omp_test_matrix_ell_kernels [ 83%] Built target omp_test_matrix_coo_kernels [ 84%] Built target omp_test_matrix_dense_kernels [ 84%] Built target omp_test_matrix_hybrid_kernels [ 85%] Built target omp_test_matrix_sellp_kernels [ 85%] Built target omp_test_preconditioner_isai_kernels [ 86%] Built target omp_test_preconditioner_jacobi_kernels [ 86%] Built target omp_test_solver_gmres_kernels [ 86%] Built target omp_test_solver_cgs_kernels [ 86%] Built target omp_test_solver_cg_kernels [ 86%] Built target omp_test_solver_ir_kernels [ 87%] Built target omp_test_solver_fcg_kernels [ 87%] Built target omp_test_solver_bicg_kernels [ 88%] Built target omp_test_solver_bicgstab_kernels [ 88%] Built target omp_test_solver_upper_trs_kernels [ 89%] Built target omp_test_solver_lower_trs_kernels [ 89%] Built target omp_test_stop_residual_norm_kernels [ 90%] Built target omp_test_stop_criterion_kernels [ 91%] Built target custom-logger [ 92%] Built target custom-matrix-format [ 92%] Built target custom-stopping-criterion [ 92%] Built target adaptiveprecision-blockjacobi [ 92%] Built target ginkgo-overhead [ 92%] Built target ginkgo-ranges [ 92%] Built target ilu-preconditioned-solver [ 93%] Built target ir-ilu-preconditioned-solver [ 93%] Built target inverse-iteration [ 93%] Built target iterative-refinement [ 93%] Built target minimal-cuda-solver [ 94%] Built target mixed-precision-ir [ 94%] Built target nine-pt-stencil-solver [ 94%] Built target performance-debugging [ 95%] Built target poisson-solver [ 95%] Built target preconditioned-solver [ 95%] Built target simple-solver [ 96%] Built target simple-solver-logging [ 96%] Built target three-pt-stencil-solver [ 97%] Built target twentyseven-pt-stencil-solver [ 97%] Built target make_run_all_benchmarks [ 97%] Built target conversions [ 98%] Built target matrix_generator [ 98%] Built target matrix_statistics [ 99%] Built target preconditioner [ 99%] Built target solver [100%] Built target spmv

upsj commented 4 years ago

To be honest, I have no idea why sudo make install would not work, since CMake always provides an install target for the Makefile. Can you try again and if it doesn't work, post the contents of your CMakeCache.txt file in here?

nghiakvnvsd commented 4 years ago

WWOWW. "sudo make install" do work. So need I do it to link my program to the library?

upsj commented 4 years ago

Yes, you need to add all of the -l... flags I mentioned before to your g++ call.

nghiakvnvsd commented 4 years ago

the output when I run: This is Ginkgo 1.2.0 (develop) running with core module 1.2.0 (develop) the reference module is 1.2.0 (develop) the OpenMP module is 1.2.0 (develop) the CUDA module is 1.2.0 (develop) the HIP module is not compiled terminate called after throwing an instance of 'gko::StreamError' what(): /home/ubuntu/ginkgo/core/base/mtx_io.cpp:695: read_description_line: error when reading the header line Aborted (core dumped)

upsj commented 4 years ago

It sounds like you are trying to open a matrix file that either doesn't exist or that doesn't have the correct file format (MatrixMarket format)

nghiakvnvsd commented 4 years ago

I have fixed. Thank you very muchhhhh!!! I try doing it 2 weeks but I don't know how to link to the library. Thank you for supporting!

upsj commented 4 years ago

You're welcome, and have fun with Ginkgo :) I'll close the issue for now.