如何启用/禁用特定图形卡? [英] How to enable/disable a specific graphic card?

查看:528
本文介绍了如何启用/禁用特定图形卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用fujitsu机器。它安装了2个GPU:Quadro 2000和Tesla C2075。 Quadro GPU有1 GB RAM,而Tesla GPU有5GB。 (我使用nvidia-smi -q的输出检查)。当我运行nvidia-smi时,输出显示2个GPU,但特斯拉显示器显示为off。
我运行一个内存密集型程序,并希望使用5 GB的RAM可用,但每当我运行一个程序,似乎使用Quadro GPU。
有没有办法在程序中使用特定的GPU?

I'm working on a "fujitsu" machine. It has 2 GPUs installed: Quadro 2000 and Tesla C2075. The Quadro GPU has 1 GB RAM and Tesla GPU has 5GB of it. (I checked using the output of nvidia-smi -q). When I run nvidia-smi, the output shows 2 GPUs, but the Tesla ones display is shown as off. I'm running a memory intensive program and would like to use 5 GB of RAM available, but whenever I run a program, it seems to be using the Quadro GPU. Is there some way to use a particular GPU out of the 2 in a program? Does the Tesla GPU being "disabled" means it's drivers are not installed?

推荐答案

您可以控制对CUDA GPU的访问,环境或程序化。

You can control access to CUDA GPUs either using the environment or programmatically.

您可以使用环境变量 CUDA_VISIBLE_DEVICES 指定1个或多个GPU的列表,对任何应用程序可见,以及它们的可见性顺序。例如,如果nvidia-smi报告您的Tesla GPU为GPU 1(而您的Quadro为GPU 0),则可以设置 CUDA_VISIBLE_DEVICES = 1 ,以仅启用Tesla通过CUDA代码。

You can use the environment variable CUDA_VISIBLE_DEVICES to specify a list of 1 or more GPUs that will be visible to any application, as well as their order of visibility. For example if nvidia-smi reports your Tesla GPU as GPU 1 (and your Quadro as GPU 0), then you can set CUDA_VISIBLE_DEVICES=1 to enable only the Tesla to be used by CUDA code.

查看我的博客

要控制应用程序以编程方式使用的GPU,应使用 CUDA的设备管理API 。使用 cudaGetDeviceCount 查询设备的数量,然后您可以 cudaSetDevice 到每个设备,使用<$ c $查询其属性c> cudaGetDeviceProperties ,然后选择适合您的应用程序条件的设备。您还可以使用 cudaChooseDevice 选择与您指定的设备属性最匹配的设备。

To control what GPU your application uses programmatically, you should use the device management API of CUDA. Query the number of devices using cudaGetDeviceCount, then you can cudaSetDevice to each device, query its properties using cudaGetDeviceProperties, and then select the device that fits your application criteria. You can also use cudaChooseDevice to select the device that most closely matches the device properties you specify.

这篇关于如何启用/禁用特定图形卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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