Skip to content

Build for Android NDK with Vulkan fails #14984

@Ipsedo

Description

@Ipsedo

🐛 Describe the bug

Hello,

First of all thanks a lot for this package that really helps me !

I face a problem when I try to build ExecuTorch (branch viable/strict) with Vulkan for Android NDK version 27.3.13750724 (at make step, after running cmake) :
ninja: error: '_deps/executorch/backends/vulkan/runtime/graph/ops/glsl/*', needed by 'vulkan_compute_shaders/spv.cpp', missing and no known rule to make it

Without set(EXECUTORCH_BUILD_VULKAN ON CACHE BOOL "") it builds perfectly. Here is my CMakeLists.txt section to build Executorch :

FetchContent_Declare(
        executorch
        GIT_REPOSITORY https://github.com/pytorch/executorch.git
        GIT_TAG        "viable/strict"
        GIT_PROGRESS   TRUE
        GIT_SUBMODULES_RECURSE TRUE
        SOURCE_DIR     "${CMAKE_CURRENT_BINARY_DIR}/_deps/executorch"
)

set(ET_VENV "${CMAKE_CURRENT_BINARY_DIR}/.venv_et")
execute_process(
        COMMAND bash -lc
        "/usr/bin/python3.12 -m venv \"${ET_VENV}\" \
        && ${ET_VENV}/bin/pip install --upgrade pip pyyaml \
        && ${ET_VENV}/bin/pip install torch --index-url https://download.pytorch.org/whl/cpu"
        COMMAND_ECHO STDOUT
        RESULT_VARIABLE _venv_rc
)
if(NOT _venv_rc EQUAL 0)
    message(FATAL_ERROR "Error when creating ExecuTorch python venv")
endif()

set(PYTHON_EXECUTABLE "${ET_VENV}/bin/python" CACHE FILEPATH "")

set(EXECUTORCH_ENABLE_LOGGING ON CACHE BOOL "")
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON CACHE BOOL "")
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON CACHE BOOL "")
set(EXECUTORCH_BUILD_TESTS OFF CACHE BOOL "")
set(EXECUTORCH_BUILD_EXTENSION_MODULE ON CACHE BOOL "")
set(EXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP ON CACHE BOOL "")
set(EXECUTORCH_BUILD_PYBIND OFF CACHE BOOL "")
set(EXECUTORCH_BUILD_PYTHON OFF CACHE BOOL "")
set(EXECUTORCH_ENABLE_PYTHON_API OFF CACHE BOOL "")
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON CACHE BOOL "")
set(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON CACHE BOOL "")
set(EXECUTORCH_BUILD_XNNPACK ON CACHE BOOL "")
set(EXECUTORCH_BUILD_VULKAN ON CACHE BOOL "")

FetchContent_MakeAvailable(executorch)

I've tried to execute https://github.com/pytorch/executorch/blob/main/backends/vulkan/runtime/gen_vulkan_spv.py with GLSLC from NDK and I have the same issue that is mentioned in : #14507

With the GLSLC from my computer, the gen_vulkan_spv.py is running well.
So like suggested in the issue 14507, I have downloaded a recent version of Vulkan like this :

execute_process(
        COMMAND bash -lc
        "mkdir -p \"${CMAKE_CURRENT_BINARY_DIR}/vulkan\" \
         && cd \"${CMAKE_CURRENT_BINARY_DIR}/vulkan\" \
         && curl -O https://sdk.lunarg.com/sdk/download/1.4.321.1/linux/vulkansdk-linux-x86_64-1.4.321.1.tar.xz \
         && tar xf vulkansdk-linux-x86_64-1.4.321.1.tar.xz"
        COMMAND_ECHO STDOUT
        RESULT_VARIABLE _dl_vulkan_rt
)

if(NOT _dl_vulkan_rt EQUAL 0)
    message(FATAL_ERROR "Failed to download and extract Vulkan")
endif ()

set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}/vulkan/1.4.321.1/x86_64/bin:$ENV{PATH}")
# tried also with set(GLSLC_PATH ""${CMAKE_CURRENT_BINARY_DIR}/vulkan/1.4.321.1/x86_64/bin/glslc")

but I face the same issue when pointing to this glslc executable.

I'm sure that I missed something to build it correctly with Vulkan. Can you help me or give some advices to debug it ? I will continue to investigate it on my side but I'm quite lost to understand this issue. As I understand, the ShaderLibrary.cmake isn't producing the built shaders.

If needed, my code is avalaible at https://github.com/Ipsedo/PhyVR/tree/develop

Thank you in advance for your time.

Versions

$ python collect_env.py # My computer, not the android device
Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: Arch Linux (x86_64)
GCC version: (GCC) 15.2.1 20250813
Clang version: 20.1.8
CMake version: version 4.1.2
Libc version: glibc-2.42

Python version: 3.13.7 (main, Aug 15 2025, 12:34:02) [GCC 15.2.1 20250813] (64-bit runtime)
Python platform: Linux-6.17.1-arch1-1-x86_64-with-glibc2.42
Is CUDA available: N/A
CUDA runtime version: 13.0.88
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3060 Laptop GPU
Nvidia driver version: 580.95.05
cuDNN version: Probably one of the following:
/usr/lib/libcudnn.so.9.12.0
/usr/lib/libcudnn_adv.so.9.12.0
/usr/lib/libcudnn_cnn.so.9.12.0
/usr/lib/libcudnn_engines_precompiled.so.9.12.0
/usr/lib/libcudnn_engines_runtime_compiled.so.9.12.0
/usr/lib/libcudnn_graph.so.9.12.0
/usr/lib/libcudnn_heuristic.so.9.12.0
/usr/lib/libcudnn_ops.so.9.12.0
Is XPU available: N/A
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

CPU:
Architecture :                            x86_64
Mode(s) opératoire(s) des processeurs :   32-bit, 64-bit
Tailles des adresses:                     48 bits physical, 48 bits virtual
Boutisme :                                Little Endian
Processeur(s) :                           16
Liste de processeur(s) en ligne :         0-15
Identifiant constructeur :                AuthenticAMD
Nom de modèle :                           AMD Ryzen 7 5800H with Radeon Graphics
Famille de processeur :                   25
Modèle :                                  80
Thread(s) par cœur :                      2
Cœur(s) par socket :                      8
Socket(s) :                               1
Révision :                                0
Accroissement de fréquence :              activé
multiplication des MHz du/des CPU(s) :    42%
Vitesse maximale du processeur en MHz :   4465,2612
Vitesse minimale du processeur en MHz :   403,4880
BogoMIPS :                                6387,76
Drapeaux :                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm debug_swap
Virtualisation :                          AMD-V
Cache L1d :                               256 KiB (8 instances)
Cache L1i :                               256 KiB (8 instances)
Cache L2 :                                4 MiB (8 instances)
Cache L3 :                                16 MiB (1 instance)
Nœud(s) NUMA :                            1
Nœud NUMA 0 de processeur(s) :            0-15
Vulnérabilité Gather data sampling :      Not affected
Vulnérabilité Ghostwrite :                Not affected
Vulnérabilité Indirect target selection : Not affected
Vulnérabilité Itlb multihit :             Not affected
Vulnérabilité L1tf :                      Not affected
Vulnérabilité Mds :                       Not affected
Vulnérabilité Meltdown :                  Not affected
Vulnérabilité Mmio stale data :           Not affected
Vulnérabilité Old microcode :             Not affected
Vulnérabilité Reg file data sampling :    Not affected
Vulnérabilité Retbleed :                  Not affected
Vulnérabilité Spec rstack overflow :      Vulnerable: Safe RET, no microcode
Vulnérabilité Spec store bypass :         Mitigation; Speculative Store Bypass disabled via prctl
Vulnérabilité Spectre v1 :                Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnérabilité Spectre v2 :                Mitigation; Retpolines; IBPB conditional; IBRS_FW; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnérabilité Srbds :                     Not affected
Vulnérabilité Tsa :                       Vulnerable: No microcode
Vulnérabilité Tsx async abort :           Not affected
Vulnérabilité Vmscape :                   Mitigation; IBPB before exit to userspace

Versions of relevant libraries:
[pip3] numpy==2.3.3
[conda] Could not collect

cc @SS-JIA @manuelcandales @digantdesai @cbilgin

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: vulkanIssues related to the Vulkan delegate and code under backends/vulkan/

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions