Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
albertbou92 opened this issue May 7, 2020 · 11 comments
Open

Comments

@albertbou92
Copy link

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

@awjuliani
Copy link
Contributor

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

@giadefa
Copy link

giadefa commented May 7, 2020 via email

@awjuliani
Copy link
Contributor

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

@JeniaJitsev
Copy link

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

@awjuliani
Copy link
Contributor

Hi @JeniaJitsev

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

@JeniaJitsev
Copy link

JeniaJitsev commented May 20, 2020

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
Copy link

JeniaJitsev commented May 20, 2020

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.

@awjuliani
Copy link
Contributor

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

@armando-fandango
Copy link

2021 and this option isnt working still

@andrearlotta
Copy link

2021 and this option isnt working still

still

@armando-fandango
Copy link

armando-fandango commented Jul 5, 2022

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 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants