LLNL / inq

This is a mirror. Please check our main website on gitlab.
https://gitlab.com/npneq/inq/
Mozilla Public License 2.0
23 stars 4 forks source link

Issues running examples #2

Closed lllangWV-zz closed 2 years ago

lllangWV-zz commented 2 years ago

Hello INQ team!

I was recently introduced to this code my graduate advisor and was told to try out the code. I have installed the code and it appears it finished without bringing up any errors.

Now, I am new to using c++ code, and I am getting confused on the process to get the code to run. I know you have to compile the code, but do not know which compiler to use. I assumed since we had to install CUDA it is the one they provide, "nvcc". When I run the command "nvcc aluminum.cpp" I get the following error:

aluminum.cpp:21:10: fatal error: inq/inq.hpp: No such file or directory 21 | #include <inq/inq.hpp>

This means it is not finding the directory inq, so would that mean I need to add a path variable to find this? I tried this on "silicon_davidson.cpp", and the compiler is unable to find the system directory as well. I am thinking there was an issue making the code, so here are the following commands I used.

git clone --recurse-submodules git@gitlab.com:npneq/inq.git cd inq mkdir build && cd build ../configure --prefix=/usr/local make -j4 make install.

I also installed the code on the Windows Subsystem for Linux Ubuntu, which I have had success using other DFT code such as Abinit and Quantum Espresso.

If you all could help, It would be greatly appreciated!

Logan

correaa commented 2 years ago

Hi Logan, welcome.

Now, I am new to using c++ code, and I am getting confused on the process to get the code to run. I know you have to compile the code, but do not know which compiler to use. I assumed since we had to install CUDA it is the one they provide, "nvcc". When I run the command "nvcc aluminum.cpp" I get the following error:

aluminum.cpp:21:10: fatal error: inq/inq.hpp: No such file or directory 21 | #include <inq/inq.hpp>

This means it is not finding the directory inq, so would that mean I need to add a path variable to find this? I tried this on "silicon_davidson.cpp", and the compiler is unable to find the system directory as well.

Yes, exactly, this is because nvcc (like any compiler) needs to know were to find the "include" files, this is passed by "-I" option. You will need several of these options (and more) to actually compile a single .cpp or .cu file. You can see the full "nvcc" line in this "CI output" (search for "aluminum.cpp").

For this reason we generate a script called "inq++" that has all the necessary options to compile you "inq" cpp sources. It may not work perfectly; if you find a problem open another issue with detailed error messages, etc.

I am thinking there was an issue making the code, so here are the following commands I used.

git clone --recurse-submodules git@gitlab.com:npneq/inq.git cd inq mkdir build && cd build ../configure --prefix=/usr/local make -j4 make install.

Did that work? This should have generated (and installed I believe) the inq++ script.

(BTW, we would appreciate if you run make test as well, this way we can be sure that the examples you are talking about compile and work in your machine).

Take into account that this way of "compiling" would prepare everything (e.g. inq++) to compile without GPU support. Which could be fine for experimenting a bit at first.

To compile for GPU you need the option --enable-cuda in the configure command. See complete recipes here: https://gitlab.com/npneq/inq/-/blob/master/.gitlab-ci.yml#L560

I also installed the code on the Windows Subsystem for Linux Ubuntu, which I have had success using other DFT code such as Abinit and Quantum Espresso.

I expect the code to compile in WSL, but as far as I know WSL doesn't support running on GPU, does it?

Let us know if this answers your questions.

lllangWV-zz commented 2 years ago

Hey Alfredo, thank you for your response, it has been very insightful! I have tried some of the suggestions and wanted to document some of the updates. Maybe this will be useful to other user!

Updates

Yes, exactly, this is because nvcc (like any compiler) needs to know were to find the "include" files, this is passed by "-I" option. You will need several of these options (and more) to actually compile a single .cpp or .cu file. You can see the full "nvcc" line in this "CI output" (search for "aluminum.cpp").

I tried clicking the CI output, but it return an xml file with ExpriedToken Error

For this reason we generate a script called "inq++" that has all the necessary options to compile you "inq" cpp sources. It may not work perfectly; if you find a problem open another issue with detailed error messages, etc. Did that work? This should have generated (and installed I believe) the inq++ script

I did try the inq++ as well (inc++ a.out) it was able to generate an output file > a.out. But this was unreadable. To access and read the data, do I have to use the inc package to read the outputs. I have included what inc++ references below for documentation as well.

/usr/bin/c++ -std=c++17 -I/home/lllang/inq/external_libs/spglib/src/ -I/home/lllang/inq/external_libs/libxc/src/ -I/home/lllang/inq/build/external_libs/libxc -I/home/lllang/inq/build/external_libs/libxc/gen_funcidx -I/usr/include -I/home/lllang/inq/build/ -I/home/lllang/inq/build/external_libs/pseudopod -I/home/lllang/inq/src/ -I/home/lllang/inq/external_libs/ -I/home/lllang/local/include aluminum.cpp /home/lllang/inq/build/external_libs/spglib/libsymspg.a /home/lllang/inq/build/external_libs/libxc/libxc.a /usr/lib/x86_64-linux-gnu/liblapack.so /usr/lib/x86_64-linux-gnu/libblas.so /usr/lib/x86_64-linux-gnu/libblas.so -L/usr/lib/x86_64-linux-gnu -lboost_serialization -lboost_filesystem -lboost_system -lfftw3 /home/lllang/local/lib/libmpicxx.so /home/lllang/local/lib/libmpi.so

(BTW, we would appreciate if you run make test as well, this way we can be sure that the examples you are talking about compile and work in your machine).

I ran this and here were the results. For the most part, it passed the tests except for the first 2. Is this a problem?

-----------------------------------------------

/usr/bin/ctest --force-new-ctest-process Test project /home/lllang/inq/build Start 1: ctest_build_test_code 1/116 Test #1: ctest_build_test_code .............................***Failed 3.17 sec

Unable to find executable: spglibtest 2/116 Test #2: spglibtest ........................................***Not Run 0.00 sec

98% tests passed, 2 tests failed out of 116

Total Test time (real) = 873.35 sec

The following tests FAILED: 1 - ctest_build_test_code (Failed) 2 - spglibtest (Not Run) Errors while running CTest make: *** [Makefile:121: test] Error 8

-----------------------------------------------

To compile for GPU you need the option --enable-cuda in the configure command. See complete recipes here: https://gitlab.com/npneq/inq/-/blob/master/.gitlab-ci.yml#L560 I expect the code to compile in WSL, but as far as I know WSL doesn't support running on GPU, does it?

I believe WSL does support running on GPU. This was found by a quick google search. Plus I had to download a specific cuda driver for WSL, so I would assume it works.

I tried the recipe from the link, but I hit an error in the configure. To compile with GPU support, do I need to uninstall the current version that I was able to install. If so is there a "make uninstall", so I can do a fresh install of inq?

-----------------------------------------------

nvcc -V mkdir nvcc && cd nvcc sudo CUDACXX=/usr/local/cuda-11.5/bin/nvcc ../configure --prefix=/usr/local --enable-cuda --disable-debug --with-cuda-prefix=/usr/local/cuda-11.5

-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: serialization filesystem system -- Boost actual version found 1.71.0 -- Applying option BOOST_NO_AUTO_PTR to patch for old Boost CMake Error at CMakeLists.txt:173 (add_subdirectory): The source directory

/home/lllang/inq/examples

does not contain a CMakeLists.txt file.

-- Configuring incomplete, errors occurred! See also "/home/lllang/inq/nvcc/CMakeFiles/CMakeOutput.log". See also "/home/lllang/inq/nvcc/CMakeFiles/CMakeError.log".

-----------------------------------------------

Again, I really appreciate the response!

correaa commented 2 years ago

Thank you for the update.

I tried clicking the CI output, but it return an xml file with ExpriedToken Error

sorry, I think the links to the CI output is only temporary. It was to show you the nvcc command in its full glory. The point is that it is hard for humans to put all the options correctly, and that is why either the script or a full "Cmake" method should be used to compile the simulation program.

sample compilation step:

cd /home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/nvcc/examples && /usr/local/cuda/bin/nvcc -forward-unknown-to-host-compiler -DBOOST_ALL_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_SERIALIZATION_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DUSING_Libxc -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/PkgConfig::FFTW -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/external_libs/libxc/src -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/nvcc/external_libs/libxc -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/nvcc/external_libs/libxc/gen_funcidx -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/external_libs/spglib/src -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/Boost::serialization -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/Boost::filesystem -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/Boost::system -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/nvcc -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/nvcc/external_libs/pseudopod -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/examples/. -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/examples/../external_libs -I/home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/examples/../src -isystem=/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -isystem=/usr/lib/x86_64-linux-gnu/openmpi/include --forward-unknown-to-host-linker  -std=c++17 --expt-relaxed-constexpr --extended-lambda --Werror=cross-execution-space-call -Xcudafe "--diag_suppress=implicit_return_from_non_void_function" -O3 -DNDEBUG --generate-code=arch=compute_70,code=[compute_70,sm_70] -DBOOST_NO_AUTO_PTR -Xcompiler -pthread -std=c++17 -x cu -c /home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/examples/aluminum.cpp -o CMakeFiles/aluminum.dir/aluminum.cpp.o

sample linking step:

cd /home/gitlab-runner/builds/3yFerYWw/0/npneq/inq/nvcc/examples && /usr/bin/cmake -E cmake_link_script CMakeFiles/aluminum.dir/dlink.txt --verbose=1
/usr/local/cuda/bin/nvcc -forward-unknown-to-host-compiler  --forward-unknown-to-host-linker  -std=c++17 --expt-relaxed-constexpr --extended-lambda --Werror=cross-execution-space-call -Xcudafe "--diag_suppress=implicit_return_from_non_void_function" -O3 -DNDEBUG --generate-code=arch=compute_70,code=[compute_70,sm_70] -Xcompiler=-fPIC -Wno-deprecated-gpu-targets -shared -dlink CMakeFiles/aluminum.dir/aluminum.cpp.o -o CMakeFiles/aluminum.dir/cmake_device_link.o   -lm ../external_libs/libxc/libxc.a ../external_libs/spglib/libsymspg.a -lcudadevrt -lcudart_static -lrt -lpthread -ldl 

I did try the inq++ as well (inc++ a.out) it was able to generate an output file > a.out. But this was unreadable. To access and read the data, do I have to use the inc package to read the outputs. I have included what inc++ references below for documentation as well.

yes, it is inc++ (not inq++ as I wrote), you run the script on the cpp source (I don't know how you got the .out file, but it is not a source).

So the command is inc++ aluminum.cpp. That creates an executable that you then run.

/usr/bin/c++ -std=c++17 -I/home/lllang/inq/external_libs/spglib/src/ -I/home/lllang/inq/external_libs/libxc/src/ -I/home/lllang/inq/build/external_libs/libxc -I/home/lllang/inq/build/external_libs/libxc/gen_funcidx -I/usr/include -I/home/lllang/inq/build/ -I/home/lllang/inq/build/external_libs/pseudopod -I/home/lllang/inq/src/ -I/home/lllang/inq/external_libs/ -I/home/lllang/local/include aluminum.cpp /home/lllang/inq/build/external_libs/spglib/libsymspg.a /home/lllang/inq/build/external_libs/libxc/libxc.a /usr/lib/x86_64-linux-gnu/liblapack.so /usr/lib/x86_64-linux-gnu/libblas.so /usr/lib/x86_64-linux-gnu/libblas.so -L/usr/lib/x86_64-linux-gnu -lboost_serialization -lboost_filesystem -lboost_system -lfftw3 /home/lllang/local/lib/libmpicxx.so /home/lllang/local/lib/libmpi.so

That is right, since you didn't configure for GPU, the compiler was choosen to be c++ (GNU C++) and you can see all the options. A configuration for GPU will use nvcc and several more settings.

(BTW, we would appreciate if you run make test as well, this way we can be sure that the examples you are talking about compile and work in your machine).

I ran this and here were the results. For the most part, it passed the tests except for the first 2. Is this a problem? #----------------------------------------------- /usr/bin/ctest --force-new-ctest-process Test project /home/lllang/inq/build Start 1: ctest_build_test_code 1/116 Test #1: ctest_build_test_code .............................***Failed 3.17 sec

Unable to find executable: spglibtest 2/116 Test #2: spglibtest ........................................***Not Run 0.00 sec

98% tests passed, 2 tests failed out of 116

Total Test time (real) = 873.35 sec

The following tests FAILED: 1 - ctest_build_test_code (Failed) 2 - spglibtest (Not Run) Errors while running CTest make: *** [Makefile:121: test] Error 8 #-----------------------------------------------

I think the tests should run and pass, including from external libraries. Can you copy/paste all the commands you passed after cloning the repository?

To compile for GPU you need the option --enable-cuda in the configure command. See complete recipes here: https://gitlab.com/npneq/inq/-/blob/master/.gitlab-ci.yml#L560 I expect the code to compile in WSL, but as far as I know WSL doesn't support running on GPU, does it?

I believe WSL does support running on GPU. This was found by a quick google search. Plus I had to download a specific cuda driver for WSL, so I would assume it works.

Ah, ok, my knowledge was outdated. I heard that WSL 2 would support GPUs but I though it was far in the future still.

I tried the recipe from the link, but I hit an error in the configure. To compile with GPU support, do I need to uninstall the current version that I was able to install. If so is there a "make uninstall", so I can do a fresh install of inq? #----------------------------------------------- nvcc -V mkdir nvcc && cd nvcc sudo CUDACXX=/usr/local/cuda-11.5/bin/nvcc ../configure --prefix=/usr/local --enable-cuda --disable-debug --with-cuda-prefix=/usr/local/cuda-11.5

-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: serialization filesystem system -- Boost actual version found 1.71.0 -- Applying option BOOST_NO_AUTO_PTR to patch for old Boost CMake Error at CMakeLists.txt:173 (add_subdirectory): The source directory

/home/lllang/inq/examples

does not contain a CMakeLists.txt file.

-- Configuring incomplete, errors occurred! See also "/home/lllang/inq/nvcc/CMakeFiles/CMakeOutput.log". See also "/home/lllang/inq/nvcc/CMakeFiles/CMakeError.log". #-----------------------------------------------

Again, I really appreciate the response!

I don't understand the console text you tried to paste here. Can you format it for github markdown? (I use three inverted single quotes to stard and the same to end a "code" block).

lllangWV-zz commented 2 years ago

Hey Alfredo,

I wanted to give another update. I have managed to figure out the issues on both my systems. I will summarize what the issues were.

WSL2-ubuntu

Linux-ubuntu

correaa commented 2 years ago

Thanks. the problem with the paths is solved by https://gitlab.com/npneq/inq/-/merge_requests/513