amrex-tutorials
amrex-tutorials copied to clipboard
AMReX tutorials cmake fails
I built AMReX successfully with CUDA support on Ubuntu 20 with gcc 9.3 , however when I use cmake to build the tutorials
I get the following cmake errors CMake Error at /home/ram/Documents/Software/amrex/installdir/Tools/CMake/AMReX_SetupCUDA.cmake:36 (get_filename_component): get_filename_component called with incorrect number of arguments Call Stack (most recent call first): /home/ram/Documents/Software/amrex/installdir/lib/cmake/AMReX/AMReXConfig.cmake:235 (include) CMakeLists.txt:65 (find_package)
CMake Error at /home/ram/Documents/Software/amrex/installdir/Tools/CMake/AMReX_SetupCUDA.cmake:37 (get_filename_component): get_filename_component called with incorrect number of arguments Call Stack (most recent call first): /home/ram/Documents/Software/amrex/installdir/lib/cmake/AMReX/AMReXConfig.cmake:235 (include) CMakeLists.txt:65 (find_package)
The CUDA compiler identification is NVIDIA 11.2.152 Check for working CUDA compiler: /usr/local/cuda-11.2/bin/nvcc Check for working CUDA compiler: /usr/local/cuda-11.2/bin/nvcc -- works Detecting CUDA compiler ABI info Detecting CUDA compiler ABI info - done Base Name: Base Name: Advection_AmrCore Executable name: Advection_AmrCore CMake Error at cmake/SetupTutorials.cmake:61 (setup_target_for_cuda_compilation): Unknown CMake command "setup_target_for_cuda_compilation". Call Stack (most recent call first): Amr/Advection_AmrCore/CMakeLists.txt:16 (setup_tutorial)
- would be great if someone could guide through this.
Thank you Ram.
Hey Ram, sorry for the slow response. I need to fix my notifications for messages posted here.
As you may have noticed the tutorials are split into GuidedTutorials
and ExampleCodes
. With CMake GuidedTutorials
can be compiled individually. The ExampleCodes
are compiled all together.
To compile the example codes with CMake ( Since it looks like you're after Advection_AmrCore) do the following:
- Navigate to the folder
amrex-tutorials/ExampleCodes
. - Make a
build
directory and enter it. (i.e.amrex_tutorials/ExampleCodes/build
) - Type
cmake ..
, to tell cmake to configure the build according to theCMakeLists.txt
in the parent directory. - After that finishes, type
cmake --build . -j8
(-j8 tells it 8 parallel jobs, adjust to your application) . This will build several of the examples, including building Advection_AmrCore. - You will then be able to run, by going to
amrex_tutorials/ExampleCodes/build/Amr/Advection_AmrCore
and calling the executable with and inputs file:./Advection_AmrCore inputs
.
If you want to enable Cuda GPU, everything is the same except for the CMake configure step. On that step type,
cmake .. -DAMReX_GPU_BACKEND=CUDA
instead of just cmake ..
.
If the GPU runs properly you'll see a short message before AMReX finalized
the describes the GPU memory usage during the run.
Again, sorry for the slow response. Thanks for your interest!
Erik