Linux 上的 CMake 找不到 CUDA

问题描述 投票:0回答:1

我使用的是 Fedora 40,并使用以下命令安装了 CUDA 工具包:

sudo dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/fedora39/x86_64/cuda-fedora39.repo
sudo dnf clean all
sudo dnf module disable nvidia-driver
sudo dnf -y install cuda

一切似乎都很好:

It was installed seemingly correct

我创建了一个简单的测试 CMake 项目,甚至明确指定了根目录:

cmake_minimum_required(VERSION 3.20 FATAL_ERROR)

set(CUDAToolkit_ROOT "/usr/local/cuda")

# Set the project name and enable CUDA
project(biNRC LANGUAGES CXX CUDA)

# Add the executable
add_executable(${PROJECT_NAME} main.cu)

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20 cuda_std_20)

# Set the properties for the CUDA target
set_target_properties(${PROJECT_NAME} PROPERTIES
    CUDA_SEPARABLE_COMPILATION ON
    CUDA_STANDARD_REQUIRED ON
    CXX_STANDARD_REQUIRED ON
    CXX_EXTENSIONS OFF
)

我仍然收到这个我完全不明白的错误:

[main] Configuring project: binrc 
[proc] Executing command: /usr/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -S/home/julcs/Documents/binrc -B/home/julcs/Documents/binrc/build
[cmake] CMake Error at /usr/share/cmake-3.30/Modules/Internal/CMakeCUDAFindToolkit.cmake:37 (message):
[cmake]   Could not find nvcc executable in path specified by
[cmake]   CUDAToolkit_ROOT=/usr/local/cuda-12.6
[cmake] Call Stack (most recent call first):
[cmake]   /usr/share/cmake-3.30/Modules/CMakeDetermineCUDACompiler.cmake:85 (cmake_cuda_find_toolkit)
[cmake]   CMakeLists.txt:6 (project)
[cmake] 
[cmake] 
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Configuring incomplete, errors occurred!
[proc] The command: /usr/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -S/home/julcs/Documents/binrc -B/home/julcs/Documents/binrc/build exited with code: 1

这怎么可能 CUDA 显然位于 bin/ 中 nvcc 的正确位置。如有任何帮助,请提前致谢。

linux cmake cuda fedora
1个回答
0
投票

哦,我有 VSCode 的 flatpak 版本,这就是错误

© www.soinside.com 2019 - 2024. All rights reserved.