如何选择指定GPU运行CUDA程序? [英] how to choose designated GPU to run CUDA program?

查看:586
本文介绍了如何选择指定GPU运行CUDA程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的电脑(ubuntu 12.04 x86与CUDA 6.0)有2个GPU,我有一些CUDA程序,我有一个用python编写的程序来管理它们。

My PC (ubuntu 12.04 x86 with CUDA 6.0) have 2 GPUs, I have some CUDA programs, and I have a program written in python to manage them.

例如,我想选择一个GPU来运行某些CUDA程序,并选择另一个来运行其他CUDA程序。但是管理进程是在CUDA代码之外,所以我不能在CUDA程序中使用cudaSetDeviceAPI。也就是说,CUDA程序是不可改变的,我只能在它们之外选择GPU。

For example, I want to select one GPU to run some CUDA programs and select the other one to run the other CUDA programs. But the management process is outside the CUDA code, so I can not use "cudaSetDevice" API inside CUDA programs. That is, the CUDA programs are unalterable, I can only select GPU outside them.

是否可以这样做?

推荐答案

在程序环境中使用 CUDA_VISIBLE_DEVICE 限制其看到的设备:

One option is to use the CUDA_VISIBLE_DEVICE in the environment of the program to restrict which devices it sees:

$ deviceQuery |& grep ^Device
Device 0: "Tesla M2090"
Device 1: "Tesla M2090"
$ CUDA_VISIBLE_DEVICES=0 deviceQuery |& grep ^Device
Device 0: "Tesla M2090"
$

查看更多有关 CUDA开发人员专区网站的信息。

See more information on the CUDA developer zone website.

这篇关于如何选择指定GPU运行CUDA程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆