How to enforcing use of GPU

Answered

How can I enforce use of the GPU in my program developments with OpenGL (using JOGL Java binding)?
I know (and have tested) that I can do this by enforcing “High Performance” setting globally on my Windows system. But that is not what I want as this would affect all applications running on the system and is probably draining the battery quickly.

I also know how to enforce GPU use for the IntelliJ IDEA workbench as such. But apparently that doesn't mean that a program launched out of the workbench would get started with the GPU. It's still the Intel CPU being used.
(besides that the workbench doesn't benefit from the GPU very much).

I also tried to set some VM options following some advise I had found somewhere:

-Dsun.java2d.d3d=true
-Dsun.java2d.noddraw=false

That's not helping either.

Further more I have tried to assign “High Performance” setting in the Windows Graphics Setup to the idea86.exe file. Again, no success. Is there some other exe file I need to setup in Windows for GPU use?

What can I do? Any idea?

Specifications:

- ThinkPad P15 Gen 1/ T15g Gen1

- Microsoft Windows 11 Pro, build 10.0.22631

- GPU Nvidea Quadro RTX 3000

0
4 comments

Hello,

You may reference here https://thinglabs.io/how-to-make-minecraft-use-your-gpu but replace the minecraft.exe with the java.exe under the JDK you used to run your program. Try Program Settings under the NVIDIA Control Panel.

0

Thanks for the response, Jacky. But that doesn't help me. I know that I can force any exe file to run with the GPU. The point is: which one? I am running the program out of the Intellij IDE. The IDE starts the actual program execution and it always starts it in such a way, that the Intel GPU on the main CPU chip is used. 

So, how can I make the IntelliJ IDE do this differently? As said: running the work bench itself with NVIDEA GPU is not helping. 

I guess the secret is somewhere around the Java VM used by IntelliJ.

0

Hello,

I've successfully run a simple Java GUI program using NVIDIA GPU, but there is nothing todo with IDEA's GPU card. Please check if the following works for you too:

NVIDIA Settings

 

  1. Open the NVIDIA Control Panel: Right-click on your desktop and select “NVIDIA Control Panel”.
  2. Manage 3D Settings: On the left, click “Manage 3D settings”.
  3. Program Settings: Go to the “Program Settings” tab.
  4. Select Java Click “Add” and find java.exe in its installation folder, select 'open'. You can find the full path of java.exe under the IDEA's Run tool window output, eg: C:\Users\yourname\.jdks\jbrsdk-17.0.9\bin\java.exe).
  5. Choose GPU Under setting number 2, there’s a dropdown. Choose “High-performance NVIDIA processor” and click “Apply”.

In the IDEA's run configuration, add JVM options: -Dsun.java2d.d3d=true -Dsun.java2d.noddraw=false

Here is the simple program I've used to test:

public class Main {

    public static void main(String[] args) throws IOException {

        JFrame frame = new JFrame("TEST NVIDIA");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(300,300);
        frame.setVisible(true);
    }
}

The Run configuration:

The NVIDIA GPU Activity indicates it now runs on GPU(ignore some Unicode):

NVIDIA Settings Pane:

 

0

Thanks, Jacky. That is what I needed. Once I have figured out where the ‘java.exe’ is that I am using, everything worked like a charm as described by you.

Again: Great support. It's a pleasure to work with IntelliJ and Kotlin already. At the rare occasions I need help, I'll get it without much of a fuzz.

0

Please sign in to leave a comment.