obstacle-tower-env icon indicating copy to clipboard operation
obstacle-tower-env copied to clipboard

Is it possible to specify in which GPU I want the environment to run?

Open albertbou92 opened this issue 5 years ago • 11 comments

I have seen that, by default, all instances of the obstacle tower environment I start run in the primary GPU (in my case GPU:0). Is it possible to specify in which GPU I want each instance to run so I can distribute the load?

Thank you

albertbou92 avatar May 07 '20 09:05 albertbou92

Hi @albertbou92

You can pass this as a command line argument when the Unity executable launches: https://docs.unity3d.com/Manual/CommandLineArguments.html

-force-device-index

awjuliani avatar May 07 '20 18:05 awjuliani

Hi Arthur, this command works for linux? It says MacOs only. When using Metal, make the Editor use a particular GPU device by passing it the index of that GPU (macOS only).

On Thu, May 7, 2020 at 8:32 PM Arthur Juliani [email protected] wrote:

Hi @albertbou92 https://github.com/albertbou92

You can pass this as a command line argument when the Unity executable launches: https://docs.unity3d.com/Manual/CommandLineArguments.html

-force-device-index

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Unity-Technologies/obstacle-tower-env/issues/115#issuecomment-625424936, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3KUOTEF3FFLDVMPJ5EA43RQL5D7ANCNFSM4M3E22DQ .

giadefa avatar May 07 '20 20:05 giadefa

It does. There are two sets of command line arguments in that document, one is for the editor, the other is for standalone builds. The instructions for standalone builds states that the argument works on windows, mac, and linux. It looks though that Vulkan is required.

Screen Shot 2020-05-07 at 1 36 45 PM

awjuliani avatar May 07 '20 20:05 awjuliani

Hey folks, I have the same endeavor right now with ml-agents. There seems to be an undocumented flag to switch GPUs according to this here: "There is a Unity command line option -gpu # which lets you select which GPU Unity apps run with UnityApp.exe -gpu 1 editor.exe -gpu 0 I haven't seen this command line argument documented but it let's me test on my integrated and dedicated GPU." https://stackoverflow.com/questions/38256297/how-to-select-gpus-for-rendering-in-unity

JeniaJitsev avatar May 14 '20 13:05 JeniaJitsev

Hi @JeniaJitsev

Does the force-device-index flag not work for you?

awjuliani avatar May 14 '20 16:05 awjuliani

Hey @awjuliani , doesn't seem like. I use -force-vulkan and see also Vulkan debug output, but Unity instances are all put on device index 0 independent of what I specify for force-device-index. (This is for Ubuntu 18.04.)

JeniaJitsev avatar May 20 '20 18:05 JeniaJitsev

Situation is following: machine has 4 RTX GPUs. I would like to have a run setup, where following happens:

GPU 0 : Unity Rendering GPU 1 : CUDA (training) GPU 3 : Unity Rendering GPU 4 : CUDA (training)

I can control CUDA (training part) just fine by setting corresponding CUDA_VISIBLE_DEVICES. However, Unity Rendering always lands at GPU 0, no matter how I assign the force-device-index flag. X sees all 4 GPUs.

JeniaJitsev avatar May 20 '20 20:05 JeniaJitsev

This may be a Unity bug, I would recommend asking about it in the official Unity forums. There is a linux section: https://forum.unity.com/forums/linux.109/?_ga=2.221155870.701444405.1590081452-1673116819.1520720368

awjuliani avatar May 21 '20 17:05 awjuliani

2021 and this option isnt working still

armando-fandango avatar Aug 17 '21 01:08 armando-fandango

2021 and this option isnt working still

still

andrearlotta avatar Jun 28 '22 14:06 andrearlotta

people who are using -force-vulkan on linux for -force-device-index, make sure that you are using the vulkan build while building the standalone binary. If the standalone binary is built using opengl, how can you force it to run vulkan :-)

armando-fandango avatar Jul 05 '22 01:07 armando-fandango