cuda 多计算能力支持、指明可见的cuda设备等知识储备

一、cuda 多计算能力支持

对于cuda程序 编译机器和运行机器卡 的卡的类型、计算能力、驱动情况都不尽相同,这就使得其编译时要讲究一下。

一般用比较旧的glibc 免得新机器出现问题。

而且 

CUDA driver version 和 CUDA runtime version 分别指

驱动中支持的CUDA版本和CUDA编译时的版本。

其能运行的条件是 driver version>=runtime version

所以编译时也用稍微低点的cuda toolkit。

同时 指定多个计算能力

-gencode=arch=compute_20,code=sm_20

-gencode=arch=compute_30,code=sm_30

-gencode=arch=compute_35,code=sm_35

-gencode=arch=compute_50,code=sm_50

一、指明可见的cuda 设备

设置环境变量CUDA_VISIBLE_DEVICES,指明可见的cuda设备

方法1:

sudo gedit /etc/profile
#或者 sudo gedit ~/.bashrc    #/etc/profile影响所有用户,~/.bashrc影响当前用户使用的bash shell

#在文件末尾添加以下行:
export CUDA_VISIBLE_DEVICES=0,1 ##仅显卡设备0,1GPU可见。可用的GPU可通过nvidia-smi -L命令查看
source /etc/profile             # 使配置文件生效


方法2:若上述配置无效,可在执行cuda程序时指明参数,如

CUDA_VISIBLE_DEVICES=0,1 ./cuda_executable

另附上一些参考文章: http://stackoverflow.com/questions/39649102/how-do-i-select-which-gpu-to-run-a-job-on

Environment Variable Syntax                               Results

CUDA_VISIBLE_DEVICES=1                Only device 1 will be seen

CUDA_VISIBLE_DEVICES=0,1             Devices 0 and 1 will be visible

CUDA_VISIBLE_DEVICES=”0,1”           Same as above, quotation marks are optional

CUDA_VISIBLE_DEVICES=0,2,3          Devices 0, 2, 3 will be visible; device 1 is masked

转于:https://www.cnblogs.com/reedlau/p/5892376.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值