To compile and run CUDA code, you need a CUDA-enabled GPU, appropriate drivers, the CUDA toolkit, and the nvcc compiler. Unlike other libraries, you need special hardware and compiler to enable CUDA. Because the hardware is always evolving, older GPUs do not support all the capabilities of newer ones. In order to use CUDA with deal.II, you will need your GPU to have compute capability 3.5 or higher. Independently from the GPU itself, you also need a version of CUDA recent enough. deal.II supports CUDA 8.0 and higher. Finally to be able to configure deal.II, you will need CMake 3.9 or higher.
To configure deal.II with CUDA use the following option:
-DDEAL_II_WITH_CUDA=ONDepending on you system, this may be enough to get CUDA to work. If you are using CUDA 8 with gcc 5.4, you will need to turn off support for C++14:
-DDEAL_II_WITH_CXX14=OFFIf you are using CUDA 9 or CUDA 10, you will need to turn off support for C++17 similarly. By default, we assume that your GPU has compute capability 3.5 but you can easily set your own CUDA flags:
-DDEAL_II_CUDA_FLAGS_RELEASEare also available if you want a finer control on the CUDA flags. The CUDA compiler and the CUDA toolkit root directory can be set using
-DDEAL_II_CUDA_TOOLKIT_ROOT_DIR. Finally, the CUDA host compiler is the same as the C++ compiler by default, but can be changed using CUDA flags as well.