问题描述
demo指路:https://github.com/EdVince/Stable-Diffusion-NCNN
在Linux端使用
cmake
编译文件时,
cd x86/linux
mkdir-p build &&cd build
cmake ..make -j$(nproc)
执行
cmake ..
命令,报错:
CMake Error at CMakeLists.txt:14 (FIND_PACKAGE):
By not providing "Findncnn.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "ncnn", but
CMake did not find one.
Could not find a package configuration file provided by "ncnn" with any of
the following names:
ncnnConfig.cmake
ncnn-config.cmake
Add the installation prefix of "ncnn" to CMAKE_PREFIX_PATH or set
"ncnn_DIR" to a directory containing one of the above files. If "ncnn"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/home/gaoyi/ldm-ncnn/Stable-Diffusion-NCNN/x86/linux/CMakeFiles/CMakeOutput.log".
问题原因
拉取
ncnn
的代码库(包括submodule)后没有
build and Install
,所以
cmake
时找不到对应的包,只需要让它找到对应的包即可,分为2步:
- 生成对应的cmake文件(
ncnnConfig.cmake
、ncnn-config.cmake
) - 设置环境变量(
CMAKE_PREFIX_PATH
或者ncnn_DIR
)
解决方法
build and Install
ncnn
需要执行以下命令:
cd ncnn
mkdir-p build
cd build
cmake ..
cmake
之后继续在build目录下,执行:
makeinstall
发现弹出的信息中有:
这其中的
ncnnConfig.cmake、ncnn.cmake
就是我们需要找的包,找到上一级目录,右键复制路径
- 设置环境变量
exportncnn_DIR=/home/gaoyi/ldm-ncnn/Stable-Diffusion-NCNN/ncnn/build/install/lib/cmake/ncnn
这个环境变量就是上一步复制的路径
- 重新运行
cmake
cmake ..
看到:
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gaoyi/ldm-ncnn/Stable-Diffusion-NCNN/x86/linux
成功!
版权归原作者 masteryi-0018 所有, 如有侵权,请联系我们删除。