OpenNMT / CTranslate2

Fast inference engine for Transformer models

Home Page:https://opennmt.net/CTranslate2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't hide GPUs to get_cuda_device_count()

mattiadg opened this issue · comments

Hi,
thank you for this great project!
I'm running on Windows 11 and ctranslate2 v4.2.1. When running in a machine with gpus, even if I set CUDA_VISIBLE_DEVICES to the empty string, get_cuda_device_count() always returns the number of gpus in the machine.
Is this expected?

CUDA_VISIBLE_DEVICES should affect which GPU will be visible. If you have more than 2 GPUs, try export CUDA_VISIBLE_DEVICES=1 and run a script to see if GPU 1 is used as expected.

I just tested it, if I set CUDA_VISIBLE_DEVICES="" and get number of gpu device with ctranslate2::get_gpu_count() , I got the correct value.

I tested on Linux. Make sure you set correctly the environment variable. You can test directly with CUDA without using ct2 before.