ncnn vulkan x86_64下的使用

flyfish

当前使用环境是Ubuntu 22.04 (Jammy Jellyfish)
文末提供完整源码下载地址

Ubuntu 22.04 (Jammy Jellyfish)

验证证书的方式

wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list http://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
sudo apt update
sudo apt install vulkan-sdk

如果想不验证 packages.lunarg.com的证书,使用–no-check-certificate
即第一句命令更改为

wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc --no-check-certificate | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc

下面的Ubuntu 20.04 (Focal Fossa)也一样

如果使用Ubuntu 20.04就需要换一下命令
Ubuntu 20.04 (Focal Fossa)

wget -qO - http://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-focal.list http://packages.lunarg.com/vulkan/lunarg-vulkan-focal.list
sudo apt update
sudo apt install vulkan-sdk

还可以多安装点程序

sudo apt install dpkg-dev
sudo apt install libvulkan1-dbgsym vulkan-tools-dbgsym

之后就可以使用vulkan了
ncnn会自动找到vulkan

CMakeLists.txt 中
opencv和ncnn的配置

cmake_minimum_required(VERSION 3.14)
project(example LANGUAGES CXX)


set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


set(ncnn_DIR ${CMAKE_SOURCE_DIR}/ncnn-20230517-ubuntu-2204/lib/cmake/ncnn)
find_package(ncnn REQUIRED)

set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv-mobile-4.6.0-ubuntu-2204/lib/cmake/opencv4)
find_package(OpenCV REQUIRED)
message(STATUS ${OpenCV_INCLUDE_DIRS})

include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(

    ${CMAKE_SOURCE_DIR}/ncnn_gpu/include
    ${CMAKE_SOURCE_DIR}/ncnn_gpu/include/ncnn
)
add_executable(example
    yolov5.cpp
)
target_link_libraries(example  ${OpenCV_LIBS} ncnn
)

源码下载地址

07-15 08:48