| TheComputerscomputer you use to runrunning TUFLOW may have multiple GPUs. Thesecanmay be multiple NVIDIA GPUs with CUDA-capabilities,which you may want to useused to acceleraterunningsimulationyour modelsruns.OrAlternatively, they can be additionalGPUs used for otherpurposeslikesuch as rendering the interactive desktopfororusers of the computer, orhandling other computational tasks. A common occurrence on modern motherboards is the availability of an integrated GPU.
   Generally, weitrecommendisusingrecommended to use a GPUyouthatdon'tisusenot used for TUFLOW modelling asyourthe primary GPU for rendering the desktop, if needed. Ifyoutheredon'tishave anno additional GPU available, you can useone of the NVIDIA GPUs,can beweused,wouldinthenwhichrecommendcaseusingittheismostrecommendedcapabletocard asuse theprimarymost capable card for running your models,and thesecondarylesscardcapableas the primary GPUone for rendering the desktop.   TUFLOW allows youselectionto selectof a specific GPU forits compute,computation using command -line optionslikesuch as<code>-pu0</code>for the first GPU,<code>-pu1</code>for the second,etcand so on. (seeSee [[HPC Running and Converting Models]].)   However, you may find thatwhat TUFLOW considers the first or second GPUdoesmay not matchyourtheexpectations based on what youorderseeshown in toolslikesuchtheas Windows Device Manager, Task Manager, or the outputfromof <code>nvidia-smi</code> on the command line. Another common problem is that the needed GPUs you want to useare not actually#0inandthe expected#1order and youmayhavecausetroubledifficulty selectingthe cards you prefer,GPUs in the preferred order you prefer them in.   To this end, you can setan environment variable called <code>CUDA_VISIBLE_DEVICES</code>, whichlimits the devices that will be visible to CUDA-capable applications like TUFLOW, as well as specifying the order they will appear in. Therestremainder of this articlewill explainoutlines how togoconfigureaboutthatthatsetting. As an example, we'll usea Windows computer is used that has 2 NVIDIA GPUs, and an on-board AMD GPU. In Windows,youallcanavailablelistGPUsallcanthebeavailable GPUslisted using aPowershellPowerShell command like this: <syntaxhighlight lang="powershell"> Get-CimInstance -Namespace root\cimv2 -ClassName Win32_VideoController | Select-Object DeviceID, Name </syntaxhighlight> (youPowerShell commands canrunbePowerShell commandsrun by opening PowerShell from the Windows Start Menu and pasting a command there)   The output for the example computer looksislikeasthisfollows (note that evenvirtual adapters,likesuch as a Remote Desktop adapter, willshowalso appear): <pre> DeviceID         Name VideoController4 NVIDIA GeForce RTX 4090 </pre> In this case, weonly need'VideoController3' and 'VideoController4' need to be visible to CUDA-enabled applications like TUFLOW.We can get moreMore details on those can be obtained by running the following command (from either PowerShell, Command Prompt, or a Linux shell): <syntaxhighlight lang="batch"> nvidia-smi --query-gpu=name,uuid --format=csv,noheader,nounits </syntaxhighlight> And the output looksislikeasthisfollows: <pre> NVIDIA GeForce RTX 4090, GPU-5060f556-4eb4-7155-4020-abadcb2fd735 NVIDIA GeForce RTX 4090, GPU-f3825978-37f8-b933-5327-583196d560cd </pre> The tool won'tdoes not list the AMD card, but up to and including version 2025.1 of TUFLOW, that card may still interfere withyourthe GPU selection order. Also, from this readout, it is not at all clear which card is which and the order here may not match the order you expect from tools like Task Manager ('GPU 0', 'GPU 1', etc.).   This isissuewhat wecanwillbesolveresolved by setting the environment variable <code>CUDA_VISIBLE_DEVICES</code>. There are two possible formats. It can either have a value like <code=>0,1</code> or a more explicit value like <code>GPU-5060f556-4eb4-7155-4020-abadcb2fd735,GPU-f3825978-37f8-b933-5327-583196d560cd</code> using the identifiers from the <code>nvidia-smi</code> output.   The short format just affects the default order. If you findusing <code>-pu0</code> with TUFLOW selects the GPUyou'd considerconsidered #1 and vice versa,you could setsetting <code>CUDA_VISIBLE_DEVICES</code> to <code>1,0</code>, toreversereverses the default order. However, this order may change as you installnew hardwareorisreinstallinstalled, or existing hardware,soreinstalled.theThe recommendation is to use the explicit values in the long format.   You can either set theThe value of the environment variable can either be set at the start of scriptsyou useused to run yourmodels, like batch files, PowerShell scripts, or Linux shell scripts, or you can set itglobally so that it automatically applies to all running applications.
   In a batch file or from the Command Prompt use this (note there are no quotes around the values, replace the values with the identifiers for yourdetected GPUs): <syntaxhighlight lang="dos"> SET CUDA_VISIBLE_DEVICES=GPU-5060f556-4eb4-7155-4020-abadcb2fd735,GPU-f3825978-37f8-b933-5327-583196d560cd </syntaxhighlight> In a PowerShell script or from the PowerShell prompt use this (note the quotes around the values, replace the values with the identifiers for yourdetected GPUs): <syntaxhighlight lang="powershell"> $env:CUDA_VISIBLE_DEVICES = "GPU-5060f556-4eb4-7155-4020-abadcb2fd735,GPU-f3825978-37f8-b933-5327-583196d560cd" </syntaxhighlight>   If youaprefer toglobally set thevaluegloballyis preferred,youit can either be set itfor a single user account by finding "Edit environment variables ''for your account''" in the Windows Start menu and entering the values without quotes, oryouit cansetbeitset for all users on the machine by finding "Edit the ''system'' environment variables" in the Windows Start menu and doing the same in the 'System Variables' section. Note thatyouadministratorneedrightstoareberequiredan administrator(elevation) to be able to do the latter.   '''Warning:''' setting the value globally affects all CUDA-capable applications, not just TUFLOW. Please ensure that no other applications need the CUDA-capabilities of the GPUsyou'rethatleavingare left out or use a local value in yourscripts or batch files instead. |