I can't compile libtorch

I’m trying to do the a simple tutorial to display the tensor of libtorch. I can’t compile. Please help me.
I get an error saying The CUDA compiler identification is unknown.
I added the path to nvcc, but it didn’t work.

Errror

CMake Error at /home/rkudo/.pyenv-gpu/versions/miniconda3-4.7.12/envs/torch/share/cmake-3.22/Modules/CMakeTestCUDACompiler.cmake:56 (message):
  The CUDA compiler

    "/usr/local/cuda-11.6/bin/nvcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/rkudo/libtorch_test/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/bin/gmake -f Makefile cmTC_e78a6/fast && /bin/gmake  -f CMakeFiles/cmTC_e78a6.dir/build.make CMakeFiles/cmTC_e78a6.dir/build
    gmake[1]: Entering directory `/home/rkudo/libtorch_test/build/CMakeFiles/CMakeTmp'
    Building CUDA object CMakeFiles/cmTC_e78a6.dir/main.cu.o
    /usr/local/cuda-11.6/bin/nvcc      -c /home/rkudo/libtorch_test/build/CMakeFiles/CMakeTmp/main.cu -o CMakeFiles/cmTC_e78a6.dir/main.cu.o
    Linking CUDA executable cmTC_e78a6
    /home/rkudo/.pyenv-gpu/versions/miniconda3-4.7.12/envs/torch/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e78a6.dir/link.txt --verbose=1
    "" CMakeFiles/cmTC_e78a6.dir/main.cu.o -o cmTC_e78a6 
    Error running link command: No such file or directory
    gmake[1]: *** [cmTC_e78a6] Error 2
    gmake[1]: Leaving directory `/home/rkudo/libtorch_test/build/CMakeFiles/CMakeTmp'
    gmake: *** [cmTC_e78a6/fast] Error 2
    
   
  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:7 (project)

CMakeLists.txt

set(CMAKE_CUDA_COMPILER /usr/local/cuda-11.6/bin/nvcc)
set(CMAKE_CUDA_COMPILER_VERSION "11.6")
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)

# set(CMAKE_C_COMPILER "/opt/gcc/8.5.0/bin/gcc")
# set(CMAKE_CXX_COMPILER "/opt/gcc/8.5.0/bin/g++")
project(example-app LANGUAGES C CXX CUDA)

find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")

add_executable(example-app example-app.cpp)
target_link_libraries(example-app "${TORCH_LIBRARIES}")
set_property(TARGET example-app PROPERTY CXX_STANDARD 14)

# The following code block is suggested to be used on Windows.
# According to https://github.com/pytorch/pytorch/issues/25457,
# the DLLs need to be copied to avoid memory errors.
if (MSVC)
  file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll")
  add_custom_command(TARGET example-app
                     POST_BUILD
                     COMMAND ${CMAKE_COMMAND} -E copy_if_different
                     ${TORCH_DLLS}
                     $<TARGET_FILE_DIR:example-app>)
endif (MSVC)