# I build Gromacs from source, I get a message that Could NOT find CUDA (missing: CUDA\_INCLUDE\_DIR)

**URL:** <https://gromacs.bioexcel.eu/t/i-build-gromacs-from-source-i-get-a-message-that-could-not-find-cuda-missing-cuda-include-dir/10134>\
**Category:** User discussions\
**Tags:** installation-error\
**Created:** [September 10, 2024, 3:05am UTC](https://gromacs.bioexcel.eu/t/i-build-gromacs-from-source-i-get-a-message-that-could-not-find-cuda-missing-cuda-include-dir/10134 "2024-09-10T03:05:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andong](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@andong](https://gromacs.bioexcel.eu/u/andong)\
**Post date:** [September 10, 2024, 3:05am UTC](https://gromacs.bioexcel.eu/t/i-build-gromacs-from-source-i-get-a-message-that-could-not-find-cuda-missing-cuda-include-dir/10134/1 "2024-09-10T03:05:53Z")

</div>

GROMACS version:2024.3  
GROMACS modification: no

My cuda-toolkit is installed in the conda environment

```auto
(MD_Gromacs_mpi_plumed)gst@DESKTOP-H4HHN9K:~/groinstall/gromacs-2024.3/build$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Wed_Aug_14_10:10:22_PDT_2024
Cuda compilation tools, release 12.6, V12.6.68
Build cuda_12.6.r12.6/compiler.34714021_0

```

When I compile Gromacs with GPU acceleration from source code, I get a message “missing: $CUDA\_INCLUDE\_DIRS” when running the Cmake command. Here is the specific error message:

```auto
CMake Error at /home/gst/miniconda3/envs/MD_Gromacs_mpi_plumed/share/cmake-3.30/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS) (found suitable version
  "12.6", minimum required is "11.0")
Call Stack (most recent call first):
  /home/gst/miniconda3/envs/MD_Gromacs_mpi_plumed/share/cmake-3.30/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  /home/gst/miniconda3/envs/MD_Gromacs_mpi_plumed/share/cmake-3.30/Modules/FindCUDA.cmake:1294 (find_package_handle_standard_args)
  cmake/gmxManageCuda.cmake:45 (find_package)
  CMakeLists.txt:697 (include)

```

Here is the Cmake command:

```auto
cmake .. -DGMX_BUILD_OWN_FFTW=OFF \
         -DREGRESSIONTEST_DOWNLOAD=ON \
         -DGMX_GPU=CUDA \
         -DGMX_MPI=ON \
         -DCMAKE_C_COMPILER=mpicc \
         -DCMAKE_CXX_COMPILER=mpicxx \
         -DGMX_EXTERNAL_BLAS=OFF \
         -DGMX_EXTERNAL_LAPACK=OFF \
         -DCUDA_TOOLKIT_ROOT_DIR=$CONDA_PREFIX \
         -DGMX_SIMD=AVX2_256 \ 
         -DCMAKE_BUILD_TYPE=Debug \
	 -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX

```

My cmake is also installed in conda

```auto
(MD_Gromacs_mpi_plumed)gst@DESKTOP-H4HHN9K:~/groinstall/gromacs-2024.3/build$ cmake --version
cmake version 3.30.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).

```

I have added the following variables before running the Cmake command, but Cmake still doesn’t work

```auto
export LD_LIBRARY_PATH=:$CONDA_PREFIX/lib
export CUDA_HOME=:$CONDA_PREFIX
export PATH=$PATH:$CONDA_PREFIX/bin
export CUDA_INCLUDE_DIRS=:$CONDA_PREFIX/include
export CUDA_BIN_PATH=$CONDA_PREFIX/bin

```

But I tried to download and install cuda-toolkit from Nvidia official website  
to the default path: `/usr/local/cuda12.6`, and then replace `-DCUDA_TOOLKIT_ROOT_DIR=$CONDA_PREFIX` to `-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda12.6 `,Compilation can run normally.

I would like to ask if I have missed adding some variables, or the Cmake file of Gromacs cannot be compiled with the CUDA-toolkit in conda.What should I do if I want to compile with CUDA-toolkit in conda

---

<div class="post-metadata">

**Author:** ![MagnusL](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/magnusl/32/2380_2.png) [@MagnusL](https://gromacs.bioexcel.eu/u/MagnusL)\
**Post date:** [September 11, 2024, 7:16am UTC](https://gromacs.bioexcel.eu/t/i-build-gromacs-from-source-i-get-a-message-that-could-not-find-cuda-missing-cuda-include-dir/10134/2 "2024-09-11T07:16:11Z")

</div>

I don’t think there has been that much testing compiling GROMACS in a conda environment. The message that it is missing CUDA\_INCLUDE\_DIRS indicates that the development headers are not installed in the conda cuda package, only the cuda library.

---

<div class="post-metadata">

**Author:** ![andong](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@andong](https://gromacs.bioexcel.eu/u/andong)\
**Post date:** [September 11, 2024, 3:32pm UTC](https://gromacs.bioexcel.eu/t/i-build-gromacs-from-source-i-get-a-message-that-could-not-find-cuda-missing-cuda-include-dir/10134/3 "2024-09-11T15:32:08Z")

</div>

Thank you for your reply.  
I compared the directory structure of the cuda-toolkit which installed on NVIDIA’s official website or installed by conda. There are indeed some differences. For example, the `/lib64` directory does not exist in the cuda-toolkit installed by conda, but the corresponding header files such as `cuda.h` are all there. I am not sure whether this is a problem with the cuda-toolkit installed by conda or a problem with the cmake file of Gromacs, because the `nvcc` can be detected. I cannot get sudo permissions so conda is best choice.

---

<div class="post-metadata">

**Author:** ![TuomoK](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@TuomoK](https://gromacs.bioexcel.eu/u/TuomoK)\
**Post date:** [September 20, 2024, 11:28am UTC](https://gromacs.bioexcel.eu/t/i-build-gromacs-from-source-i-get-a-message-that-could-not-find-cuda-missing-cuda-include-dir/10134/4 "2024-09-20T11:28:06Z")

</div>

Just in case somebody else is also struggling with this one still:

I had the exact same problem which was caused by different versions of cuda packages installed by anaconda3. Check via “conda list” that all your CUDA-packages match (for example, anaconda3 had installed different versions of cuda-toolkit and cuda-compiler for me).

I had to explicitly list all those cuda package versions to get the version I wanted to work (12.4):

mamba install -c nvidia cuda=12.4 cuda-toolkit=12.4 cuda-libraries=12.4 cuda-compiler=12.4 cuda-libraries-dev=12.4 cuda-visual-tools=12.4 cuda-cupti-dev=12.4 cuda-libraries-static=12.4 cuda-command-line-tools=12.4 cuda-tools=12.4

---

<div class="post-metadata">

**Author:** ![sizhe\_Li](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sizhe\_Li](https://gromacs.bioexcel.eu/u/sizhe_Li)\
**Post date:** [December 26, 2024, 10:01am UTC](https://gromacs.bioexcel.eu/t/i-build-gromacs-from-source-i-get-a-message-that-could-not-find-cuda-missing-cuda-include-dir/10134/5 "2024-12-26T10:01:58Z")

</div>

The same question. Have you solved this Problem?  
I’m using cudatoolkit=11.8 cuda-nvcc=11.8 now
