Zhonghui

每个不曾起舞的日子,都是对生命的辜负

User Tools

Site Tools


程序:cuda:设备属性

设备属性


查询设备属性

参照cuda_samples


(来源:《GPU高性能编程CUDA实战》,比较旧的资料了,上图仅供参考)

选择符合条件的设备

cudaChooseDevice
cudaSetDevice

AI总结

// Generated by AI
 
// 1:设备枚举与属性查询
 
// 获取系统中 CUDA 设备的总数
cudaGetDeviceCount(int* count);
 
// 获取当前线程正在使用的 CUDA 设备编号
cudaGetDevice(int *device);
 
// 设置当前线程使用的 CUDA 设备
cudaSetDevice(int device);
 
// 获取指定设备的属性信息
cudaGetDeviceProperties(cudaDeviceProp* prop, int device);
 
// 获取指定设备的单项属性
cudaDeviceGetAttribute(int* value, cudaDeviceAttr attr, int device);
 
// 根据 PCI 总线 ID 获取设备编号
cudaDeviceGetByPCIBusId(int* device, const char* pciBusId);
 
// 获取设备的 PCI 总线 ID 字符串
cudaDeviceGetPCIBusId(char* pciBusId, int len, int device);
 
// 查询两设备之间 P2P 通信能力
cudaDeviceGetP2PAttribute(int* value, cudaDeviceP2PAttr attr, int srcDevice, int dstDevice);
 
 
// 2:运行时资源限制与配置
 
// 获取设备资源限制(如堆栈、共享内存等)
cudaDeviceGetLimit(size_t* pValue, cudaLimit limit);
 
// 获取设备 L1/L2 缓存配置
cudaDeviceGetCacheConfig(cudaFuncCache* pCacheConfig);
 
// 获取设备默认内存池对象
cudaDeviceGetDefaultMemPool(cudaMemPool_t* memPool, int device);
 
// 获取设备指定内存池对象
cudaDeviceGetMemPool(cudaMemPool_t* memPool, int device);
 
// 获取设备的流优先级范围
cudaDeviceGetStreamPriorityRange(int* leastPriority, int* greatestPriority);
 
// 获取设备的 NvSciSync 属性(用于跨进程同步)
cudaDeviceGetNvSciSyncAttributes(void* attrList, int device, int flags);
 
 
// 3:内存状态与属性查询
 
// 获取当前上下文的显存占用情况(剩余和总量)
cudaMemGetInfo(size_t* free, size_t* total);
 
// 查询指针属性(属于哪种内存、设备等信息)
cudaPointerGetAttributes(cudaPointerAttributes* attributes, const void* ptr);
 
// 查询 cudaArray 对象信息
cudaArrayGetInfo(...);
 
// 查询 cudaArray 的内存需求(分配策略相关)
cudaArrayGetMemoryRequirements(...);
/var/www/DokuWikiStick/dokuwiki/data/pages/程序/cuda/设备属性.txt · Last modified: 2025/07/14 08:35 by zhonghui