Skip to content

find_cudadevices does not work for CUDA 13 #6702

@xq114

Description

@xq114

Xmake 版本

3.0.1

操作系统版本和架构

Windows 10

描述问题

CUDA 13废弃了一些devicequery的api https://docs.nvidia.com/cuda/archive/12.9.1/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp_1dee14230e417cb3059d697d6804da414 其中一些标为deprecated;调用xmake时报错

warning: failed to find cuda devices: find_cudadevices.cpp
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(118): error C2039: 'clockRate': is not a member of 'cudaDeviceProp'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include\driver_types.h(2467): note: see declaration of 'cudaDeviceProp'   
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(118): error C2672: 'print_property': no matching overloaded function found       
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(93): note: could be 'void print_property(const char *,const T &)'
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(118): note: 'void print_property(const char *,const T &)': expects 2 arguments - 
1 provided
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(124): error C2039: 'deviceOverlap': is not a member of 'cudaDeviceProp'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include\driver_types.h(2467): note: see declaration of 'cudaDeviceProp'   
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(124): error C2672: 'print_property': no matching overloaded function found       
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(93): note: could be 'void print_property(const char *,const T &)'
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(124): note: 'void print_property(const char *,const T &)': expects 2 arguments - 
1 provided
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(126): error C2039: 'kernelExecTimeoutEnabled': is not a member of 'cudaDeviceProp'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include\driver_types.h(2467): note: see declaration of 'cudaDeviceProp'   
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(126): error C2672: 'print_property': no matching overloaded function found       
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(93): note: could be 'void print_property(const char *,const T &)'
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(126): note: 'void print_property(const char *,const T &)': expects 2 arguments - 
1 provided
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(129): error C2039: 'computeMode': is not a member of 'cudaDeviceProp'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include\driver_types.h(2467): note: see declaration of 'cudaDeviceProp'   
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(129): error C2672: 'print_property': no matching overloaded function found       
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(93): note: could be 'void print_property(const char *,const T &)'
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(129): note: 'void print_property(const char *,const T &)': expects 2 arguments - 
1 provided
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(132): error C2039: 'maxTexture1DLinear': is not a member of 'cudaDeviceProp'     
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include\driver_types.h(2467): note: see declaration of 'cudaDeviceProp'   
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(132): error C2672: 'print_property': no matching overloaded function found       
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(93): note: could be 'void print_property(const char *,const T &)'
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(132): note: 'void print_property(const char *,const T &)': expects 2 arguments - 
1 provided
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(159): error C2039: 'memoryClockRate': is not a member of 'cudaDeviceProp'        
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include\driver_types.h(2467): note: see declaration of 'cudaDeviceProp'   
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(159): error C2672: 'print_property': no matching overloaded function found       
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(93): note: could be 'void print_property(const char *,const T &)'
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(159): note: 'void print_property(const char *,const T &)': expects 2 arguments - 
1 provided
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(170): error C2039: 'singleToDoublePrecisionPerfRatio': is not a member of 'cudaDeviceProp'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include\driver_types.h(2467): note: see declaration of 'cudaDeviceProp'   
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(170): error C2672: 'print_property': no matching overloaded function found       
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(93): note: could be 'void print_property(const char *,const T &)'
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(170): note: 'void print_property(const char *,const T &)': expects 2 arguments - 
1 provided
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(180): error C2039: 'cooperativeMultiDeviceLaunch': is not a member of 'cudaDeviceProp'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include\driver_types.h(2467): note: see declaration of 'cudaDeviceProp'   
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(180): error C2672: 'print_property': no matching overloaded function found       
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(93): note: could be 'void print_property(const char *,const T &)'
C:\Users\xq114\xmake\scripts\find_cudadevices.cpp(180): note: 'void print_property(const char *,const T &)': expects 2 arguments - 
1 provided

把上述deprecated查询删除之后还是报错

error: @programdir\core\main.lua:329: @programdir\core\sandbox\modules\import\core\base\task.lua:65: @programdir\modules\lib\detect\find_cudadevices.lua:259: attempt to perform arithmetic on a nil value (field 'clockRate')
stack traceback:
    [@programdir\modules\lib\detect\find_cudadevices.lua:259]: in function '_order_by_flops'
    [@programdir\modules\lib\detect\find_cudadevices.lua:291]:
    [@programdir\rules\cuda\gencodes\xmake.lua:62]: in function 'nf_cugencode'
    [@programdir\rules\cuda\gencodes\xmake.lua:147]: in function 'on_config'
    [...dir\core\sandbox\modules\import\core\project\project.lua:145]: in function '_config_target'
    [...dir\core\sandbox\modules\import\core\project\project.lua:180]: in function '_config_targets'
    [...dir\core\sandbox\modules\import\core\project\project.lua:227]: in function 'load_targets'
    [@programdir\actions\config\main.lua:411]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:246]:
    [@programdir\core\base\task.lua:504]: in function 'run'
    [@programdir\core\sandbox\modules\import\core\base\task.lua:63]: in function 'run'
    [@programdir\actions\build\main.lua:190]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:246]:
    [@programdir\core\base\task.lua:504]: in function 'run'
    [@programdir\core\main.lua:327]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:406]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:1075: in function 'os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:329: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:406: in function <@programdir\core\base\scheduler.lua:399>

因为xmake内部按clockRate排序,但clockRate被移除了。现代GPU都是动态调频,clockRate属性确实也无实际意义,比较cuda thread数量就可以(?)

期待的结果

CUDA 13可以正常使用find_cudadevices

工程配置

/

附加信息和错误日志

/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions