• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Possible to force my Java app to use discrete video adapter?

Joined
Jan 13, 2015
Messages
135 (0.04/day)
Hey guys,

I have a java app (with animation). It runs best on a PC with a discrete GPU. The problem I'm having is that I have a PC with both an integrated and discrete video adapter. It uses the integrated GPU by default. Unfortunately, this is the case when running my java app. So it runs much slower. My other PC has a single discrete video adapter and runs the same app, faster, by about a factor of 10.

Any ideas on how to force the app to use the discrete GPU?

TIA,

grecinos
 
Joined
Dec 6, 2005
Messages
10,881 (1.63/day)
Location
Manchester, NH
System Name Senile
Processor I7-4790K@4.8 GHz 24/7
Motherboard MSI Z97-G45 Gaming
Cooling Be Quiet Pure Rock Air
Memory 16GB 4x4 G.Skill CAS9 2133 Sniper
Video Card(s) GIGABYTE Vega 64
Storage Samsung EVO 500GB / 8 Different WDs / QNAP TS-253 8GB NAS with 2x10Tb WD Blue
Display(s) 34" LG 34CB88-P 21:9 Curved UltraWide QHD (3440*1440) *FREE_SYNC*
Case Rosewill
Audio Device(s) Onboard + HD HDMI
Power Supply Corsair HX750
Mouse Logitech G5
Keyboard Corsair Strafe RGB & G610 Orion Red
Software Win 10
Joined
Jan 13, 2015
Messages
135 (0.04/day)
Joined
Dec 6, 2005
Messages
10,881 (1.63/day)
Location
Manchester, NH
System Name Senile
Processor I7-4790K@4.8 GHz 24/7
Motherboard MSI Z97-G45 Gaming
Cooling Be Quiet Pure Rock Air
Memory 16GB 4x4 G.Skill CAS9 2133 Sniper
Video Card(s) GIGABYTE Vega 64
Storage Samsung EVO 500GB / 8 Different WDs / QNAP TS-253 8GB NAS with 2x10Tb WD Blue
Display(s) 34" LG 34CB88-P 21:9 Curved UltraWide QHD (3440*1440) *FREE_SYNC*
Case Rosewill
Audio Device(s) Onboard + HD HDMI
Power Supply Corsair HX750
Mouse Logitech G5
Keyboard Corsair Strafe RGB & G610 Orion Red
Software Win 10
Thanks for the quick response. That looks close, but at first glance it appears to be for android devices. I'm running my Java app on a PC. I'm using Netbeans as my IDE. Off the top of my head, I was thinking either a special compiler directive. Or, to create an executable from the Jar and force that to use the Nvidia GPU.

Any thoughts?

Yeah, duh didn't even see android in the link.

Sorry, not here. You could be right, it might be set in the compiler.
 
Joined
Jan 13, 2015
Messages
135 (0.04/day)
A quick update:

I was unsuccessful to force Windows 10 to use my Nvidia GPU for my Java app.

Fortunately, Java is a cross-platform programming language. In such, I figured I'd try running the app on Ubuntu Linux. I created a dual boot system out of one of my laptops. After installing all necessary software, I ran my Java app. To my amazement, it worked! Apparently, Ubuntu favors the discrete GPU over the integrated counterpart. My app went from performing 250K calculations per second to over 7 Million calculations per second. That's the difference between using an integrated vs discrete GPU.

Now, if only Microsoft would allow its users to select a preferred GPU. Shame on you!
 
Joined
Nov 18, 2010
Messages
7,106 (1.46/day)
Location
Rīga, Latvia
System Name HELLSTAR
Processor AMD RYZEN 9 5950X
Motherboard ASUS Strix X570-E
Cooling 2x 360 + 280 rads. 3x Gentle Typhoons, 3x Phanteks T30, 2x TT T140 . EK-Quantum Momentum Monoblock.
Memory 4x8GB G.SKILL Trident Z RGB F4-4133C19D-16GTZR 14-16-12-30-44
Video Card(s) Sapphire Pulse RX 7900XTX + under waterblock.
Storage Optane 900P[W11] + WD BLACK SN850X 4TB + 750 EVO 500GB + 1TB 980PRO[FEDORA]
Display(s) Philips PHL BDM3270 + Acer XV242Y
Case Lian Li O11 Dynamic EVO
Audio Device(s) Sound Blaster ZxR
Power Supply Fractal Design Newton R3 1000W
Mouse Razer Basilisk
Keyboard Razer BlackWidow V3 - Yellow Switch
Software FEDORA 39 / Windows 11 insider
A quick update:

I was unsuccessful to force Windows 10 to use my Nvidia GPU for my Java app.

Fortunately, Java is a cross-platform programming language. In such, I figured I'd try running the app on Ubuntu Linux. I created a dual boot system out of one of my laptops. After installing all necessary software, I ran my Java app. To my amazement, it worked! Apparently, Ubuntu favors the discrete GPU over the integrated counterpart. My app went from performing 250K calculations per second to over 7 Million calculations per second. That's the difference between using an integrated vs discrete GPU.

Now, if only Microsoft would allow its users to select a preferred GPU. Shame on you!

It usually does via right click and select preffered GPU.

Blame your maker of the board, not M$.
 
Joined
Jan 13, 2015
Messages
135 (0.04/day)
It usually does via right click and select preffered GPU.

Blame your maker of the board, not M$.

Well, I have two laptops (by Asus and Sager), both with a dual GPU configuration. Neither has the option to select a preferred GPU, including the BIOS. I've tried creating an EXE out of my Java app and selecting the preferred GPU that way, but no dice. Is that what you were referring to?
 
Joined
Nov 18, 2010
Messages
7,106 (1.46/day)
Location
Rīga, Latvia
System Name HELLSTAR
Processor AMD RYZEN 9 5950X
Motherboard ASUS Strix X570-E
Cooling 2x 360 + 280 rads. 3x Gentle Typhoons, 3x Phanteks T30, 2x TT T140 . EK-Quantum Momentum Monoblock.
Memory 4x8GB G.SKILL Trident Z RGB F4-4133C19D-16GTZR 14-16-12-30-44
Video Card(s) Sapphire Pulse RX 7900XTX + under waterblock.
Storage Optane 900P[W11] + WD BLACK SN850X 4TB + 750 EVO 500GB + 1TB 980PRO[FEDORA]
Display(s) Philips PHL BDM3270 + Acer XV242Y
Case Lian Li O11 Dynamic EVO
Audio Device(s) Sound Blaster ZxR
Power Supply Fractal Design Newton R3 1000W
Mouse Razer Basilisk
Keyboard Razer BlackWidow V3 - Yellow Switch
Software FEDORA 39 / Windows 11 insider
Well, I have two laptops (by Asus and Sager), both with a dual GPU configuration. Neither has the option to select a preferred GPU, including the BIOS. I've tried creating an EXE out of my Java app and selecting the preferred GPU that way, but no dice. Is that what you were referring to?

It usually looks like that.

 
Joined
Jan 13, 2015
Messages
135 (0.04/day)
It usually looks like that.



Yep. I tried that. When I called Asus tech support, he ran me through some steps. That was one of them. The other was to change the Physics Configuration and Mange 3D Settings in the Nvidia Control Panel. None of them worked. He eventually gave up and said that it just wasn't possible. It appears to be very picky which app is allowed the use of discrete GPU. =/
 
Joined
Nov 18, 2010
Messages
7,106 (1.46/day)
Location
Rīga, Latvia
System Name HELLSTAR
Processor AMD RYZEN 9 5950X
Motherboard ASUS Strix X570-E
Cooling 2x 360 + 280 rads. 3x Gentle Typhoons, 3x Phanteks T30, 2x TT T140 . EK-Quantum Momentum Monoblock.
Memory 4x8GB G.SKILL Trident Z RGB F4-4133C19D-16GTZR 14-16-12-30-44
Video Card(s) Sapphire Pulse RX 7900XTX + under waterblock.
Storage Optane 900P[W11] + WD BLACK SN850X 4TB + 750 EVO 500GB + 1TB 980PRO[FEDORA]
Display(s) Philips PHL BDM3270 + Acer XV242Y
Case Lian Li O11 Dynamic EVO
Audio Device(s) Sound Blaster ZxR
Power Supply Fractal Design Newton R3 1000W
Mouse Razer Basilisk
Keyboard Razer BlackWidow V3 - Yellow Switch
Software FEDORA 39 / Windows 11 insider
So you have the option?

If you activate nvidia GPU activity bar, does it show other apps that use the GPU?
 
Joined
Jan 8, 2017
Messages
8,860 (3.36/day)
System Name Good enough
Processor AMD Ryzen R9 7900 - Alphacool Eisblock XPX Aurora Edge
Motherboard ASRock B650 Pro RS
Cooling 2x 360mm NexXxoS ST30 X-Flow, 1x 360mm NexXxoS ST30, 1x 240mm NexXxoS ST30
Memory 32GB - FURY Beast RGB 5600 Mhz
Video Card(s) Sapphire RX 7900 XT - Alphacool Eisblock Aurora
Storage 1x Kingston KC3000 1TB 1x Kingston A2000 1TB, 1x Samsung 850 EVO 250GB , 1x Samsung 860 EVO 500GB
Display(s) LG UltraGear 32GN650-B + 4K Samsung TV
Case Phanteks NV7
Power Supply GPS-750C
Can't you just disable the integrated GPU in device manager ?
 
Joined
Nov 18, 2010
Messages
7,106 (1.46/day)
Location
Rīga, Latvia
System Name HELLSTAR
Processor AMD RYZEN 9 5950X
Motherboard ASUS Strix X570-E
Cooling 2x 360 + 280 rads. 3x Gentle Typhoons, 3x Phanteks T30, 2x TT T140 . EK-Quantum Momentum Monoblock.
Memory 4x8GB G.SKILL Trident Z RGB F4-4133C19D-16GTZR 14-16-12-30-44
Video Card(s) Sapphire Pulse RX 7900XTX + under waterblock.
Storage Optane 900P[W11] + WD BLACK SN850X 4TB + 750 EVO 500GB + 1TB 980PRO[FEDORA]
Display(s) Philips PHL BDM3270 + Acer XV242Y
Case Lian Li O11 Dynamic EVO
Audio Device(s) Sound Blaster ZxR
Power Supply Fractal Design Newton R3 1000W
Mouse Razer Basilisk
Keyboard Razer BlackWidow V3 - Yellow Switch
Software FEDORA 39 / Windows 11 insider
Joined
Jan 13, 2015
Messages
135 (0.04/day)
Vya, I tried disabling the integrated GPU, but Windows didn't hand over control to the discrete GPU :(

W1zzard, I'm not sure how to dllexport in Java, either.

Ferrum, some how Java has to allow permission to use the discrete GPU. Perhaps a compiler directive. Maybe a special program that converts a Java app to an executable for the sole purpose of using the discrete GPU.

So frustrating...
 
Joined
Jan 8, 2017
Messages
8,860 (3.36/day)
System Name Good enough
Processor AMD Ryzen R9 7900 - Alphacool Eisblock XPX Aurora Edge
Motherboard ASRock B650 Pro RS
Cooling 2x 360mm NexXxoS ST30 X-Flow, 1x 360mm NexXxoS ST30, 1x 240mm NexXxoS ST30
Memory 32GB - FURY Beast RGB 5600 Mhz
Video Card(s) Sapphire RX 7900 XT - Alphacool Eisblock Aurora
Storage 1x Kingston KC3000 1TB 1x Kingston A2000 1TB, 1x Samsung 850 EVO 250GB , 1x Samsung 860 EVO 500GB
Display(s) LG UltraGear 32GN650-B + 4K Samsung TV
Case Phanteks NV7
Power Supply GPS-750C
Vya, I tried disabling the integrated GPU, but Windows didn't hand over control to the discrete GPU :(

W1zzard, I'm not sure how to dllexport in Java, either.

Ferrum, some how Java has to allow permission to use the discrete GPU. Perhaps a compiler directive. Maybe a special program that converts a Java app to an executable for the sole purpose of using the discrete GPU.

So frustrating...

Thats really strange that even disabled it still runs on the integrated GPU.

To be honest Java is not fit for whatever computations you want to achive on the GPU in the first place.
 
Joined
Jan 13, 2015
Messages
135 (0.04/day)
Thats really strange that even disabled it still runs on the integrated GPU.

To be honest Java is not fit for whatever computations you want to achive on the GPU in the first place.


I agree. I think Windows should have an option to select which GPU to use by default.

For the moment, java suits my needs just fine. It's sufficiently fast and an easy programming language to use. The fact that it's a cross-platform language is also a bonus. Although, I've always wondered if there was such a thing as a library that allows for accessing the GPU directly. I guess, something like DirectX for Java would be neat.
 
Joined
Nov 18, 2010
Messages
7,106 (1.46/day)
Location
Rīga, Latvia
System Name HELLSTAR
Processor AMD RYZEN 9 5950X
Motherboard ASUS Strix X570-E
Cooling 2x 360 + 280 rads. 3x Gentle Typhoons, 3x Phanteks T30, 2x TT T140 . EK-Quantum Momentum Monoblock.
Memory 4x8GB G.SKILL Trident Z RGB F4-4133C19D-16GTZR 14-16-12-30-44
Video Card(s) Sapphire Pulse RX 7900XTX + under waterblock.
Storage Optane 900P[W11] + WD BLACK SN850X 4TB + 750 EVO 500GB + 1TB 980PRO[FEDORA]
Display(s) Philips PHL BDM3270 + Acer XV242Y
Case Lian Li O11 Dynamic EVO
Audio Device(s) Sound Blaster ZxR
Power Supply Fractal Design Newton R3 1000W
Mouse Razer Basilisk
Keyboard Razer BlackWidow V3 - Yellow Switch
Software FEDORA 39 / Windows 11 insider
If javapsp exist there is.

Also there should be a really good reason why it acts so really.
 
Joined
Jan 8, 2017
Messages
8,860 (3.36/day)
System Name Good enough
Processor AMD Ryzen R9 7900 - Alphacool Eisblock XPX Aurora Edge
Motherboard ASRock B650 Pro RS
Cooling 2x 360mm NexXxoS ST30 X-Flow, 1x 360mm NexXxoS ST30, 1x 240mm NexXxoS ST30
Memory 32GB - FURY Beast RGB 5600 Mhz
Video Card(s) Sapphire RX 7900 XT - Alphacool Eisblock Aurora
Storage 1x Kingston KC3000 1TB 1x Kingston A2000 1TB, 1x Samsung 850 EVO 250GB , 1x Samsung 860 EVO 500GB
Display(s) LG UltraGear 32GN650-B + 4K Samsung TV
Case Phanteks NV7
Power Supply GPS-750C
I am still baffled to why you can't disable your Integrated GPU , I am convinced that's the cause of your issue , your application is most likely fine. You should look more into that.
 
Joined
Jan 13, 2015
Messages
135 (0.04/day)
I am still baffled to why you can't disable your Integrated GPU , I am convinced that's the cause of your issue , your application is most likely fine. You should look more into that.

I stand corrected. After disabling the Integrating the GPU, the Discrete took control. I'm not sure why it didn't work before... Nevertheless, my app runs nearly as fast compared to running it in Linux. Approximately 5,500,000 calculations per second vs Linux's 7,000,000. The only drawback is that when the Integrated GPU is disabled, I can't access the Nvidia Control Panel. Not a big deal, as I will only need to put my computer in this state in rare situations like this. It appears to be stuck at the highest resolution, 3840x2160 on the Sager and 1080p on the Asus. On the bright side. My app was intended to run at maximum resolution. Not the most elegant solution, but hey it works!
 
Joined
Jan 8, 2017
Messages
8,860 (3.36/day)
System Name Good enough
Processor AMD Ryzen R9 7900 - Alphacool Eisblock XPX Aurora Edge
Motherboard ASRock B650 Pro RS
Cooling 2x 360mm NexXxoS ST30 X-Flow, 1x 360mm NexXxoS ST30, 1x 240mm NexXxoS ST30
Memory 32GB - FURY Beast RGB 5600 Mhz
Video Card(s) Sapphire RX 7900 XT - Alphacool Eisblock Aurora
Storage 1x Kingston KC3000 1TB 1x Kingston A2000 1TB, 1x Samsung 850 EVO 250GB , 1x Samsung 860 EVO 500GB
Display(s) LG UltraGear 32GN650-B + 4K Samsung TV
Case Phanteks NV7
Power Supply GPS-750C
Glad you at least fund a way to make it work.
 
Top