# Building with cuda: nvtx not found

**URL:** <https://dev-discuss.pytorch.org/t/building-with-cuda-nvtx-not-found/2457>\
**Category:** Uncategorized\
**Created:** [September 12, 2024, 2:49pm UTC](https://dev-discuss.pytorch.org/t/building-with-cuda-nvtx-not-found/2457 "2024-09-12T14:49:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elsampsa](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/elsampsa/32/2275_2.png) [@elsampsa](https://dev-discuss.pytorch.org/u/elsampsa)\
**Post date:** [September 12, 2024, 2:49pm UTC](https://dev-discuss.pytorch.org/t/building-with-cuda-nvtx-not-found/2457/1 "2024-09-12T14:49:07Z")

</div>

Before spamming github issues, I wanted to try my luck in here. If there is a more adequate forum for this, please give a pointer.

I am trying to compile pytorch with cuda in a conda environment, but the cmake process gets stuck because of “nvtx” libraries.

- Base OS: ubuntu 22.04
- Conda environment with python 3.12
- Cuda toolkit installed into the conda env
- git checkout: release/2.4

```bash
conda install cuda-toolkit=12.2

```

→ cuda headers and libs end up in here:

```bash
$CONDA_PREFIX/targets/x86_64-linux/include/cuda*.h
$CONDA_PREFIX/targets/x86_64-linux/lib/libcudart.so
$CONDA_PREFIX/nsight-compute-2023.2.2/host/target-linux-x64/nvtx/include/nvtx3/

```

I have set

```bash
export CUDACXX=$CONDA_PREFIX/bin/nvcc
export CUDA_BIN_PATH=$CONDA_PREFIX/bin
export CMAKE_CUDA_COMPILER=$CONDA_PREFIX/bin/nvcc
export CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES=$CONDA_PREFIX/include
export CUDAHOSTCXX=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-c++
export CUDA_HOME=$CONDA_PREFIX

```

CMake preparations crash in here:

```bash
-- Found CUDA: /home/sampsa/anaconda3/envs/torch_nvidia/targets/x86_64-linux (found version "12.2") 
-- The CUDA compiler identification is NVIDIA 12.2.140
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /home/sampsa/anaconda3/envs/torch_nvidia/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Found CUDAToolkit: /home/sampsa/anaconda3/envs/torch_nvidia/targets/x86_64-linux/include (found version "12.2.140") 
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
CMake Error at cmake/public/cuda.cmake:70 (message):
  Failed to find nvToolsExt
Call Stack (most recent call first):
  cmake/Dependencies.cmake:43 (include)
  CMakeLists.txt:853 (include)

```

Not sure if it’s missing nvtx or nvtx3. At least the latter is here:

```bash
/home/sampsa/anaconda3/envs/torch_nvidia/nsight-compute-2023.2.2/host/target-linux-x64/nvtx/include/nvtx3

```

I copied - just in case - the `nvtx3` directory as-is into

```bash
/home/sampsa/anaconda3/envs/torch_nvidia/targets/x86_64-linux/include/

```

And also the contents (files) of `nvtx3` into

```bash
/home/sampsa/anaconda3/envs/torch_nvidia/targets/x86_64-linux/include/

```

To no avail.

[FindCUdaToolkit.cmake](https://github.com/pytorch/pytorch/blob/main/cmake/Modules/FindCUDAToolkit.cmake#L365) is resposible for finding nvtx. In that line it is said that “This is a shared library only” - although version 3 seems to be header-only.

What version should I use?

[This](https://github.com/pytorch/pytorch/blob/main/cmake/Modules/FindCUDAToolkit.cmake#L1049) is the part that searches for nvtx. No idea how can I pass parameters to the build system as env parameters for this case.

Why do we need an _automated_ (and obscure) cmake “finder” script for the cuda directories anyway?

Wouldn’t it just be better to explicitly define all these paths by the user? - I mean, if someone is building pytorch h@m/rself (s)he probably needs to now what (s)he’s doing and where the directories are?

In this context, a template with some default path values could be provided…

---

<div class="post-metadata">

**Author:** ![malfet](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/malfet/32/129_2.png) [@malfet](https://dev-discuss.pytorch.org/u/malfet)\
**Post date:** [September 17, 2024, 4:24am UTC](https://dev-discuss.pytorch.org/t/building-with-cuda-nvtx-not-found/2457/2 "2024-09-17T04:24:55Z")

</div>

Consider installing CUDA toolkit from [CUDA Toolkit - Free Tools and Training | NVIDIA Developer](https://developer.nvidia.com/cuda-toolkit) and more libraries (including PyTorch) should be able to find all the components they need.

---

<div class="post-metadata">

**Author:** ![cyyever](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/cyyever/32/2294_2.png) [@cyyever](https://dev-discuss.pytorch.org/u/cyyever)\
**Post date:** [September 19, 2024, 10:24am UTC](https://dev-discuss.pytorch.org/t/building-with-cuda-nvtx-not-found/2457/3 "2024-09-19T10:24:53Z")

</div>

We have a third-party lib for NVTX3, make sure that you pull the complete code, including all third-parties.
