I have ripped the web up trying to figure this out. Bumblebee hasn't helped. I want to run Minecraft on the Nvidia GPU in my laptop. As far as I can tell, Ubuntu default runs it with Intel because Minecraft runs inside of Java, which, obviously, is not generally GPU intensive. I'm using Bionic Beaver, and the optirun command is broken. It throws an error that the nvidia-fallback.service is disabled, but trying to enable it reveals that the file doesn't exist. As far as I can tell, this is a Bionic Beaver problem. The primusrun command seems to work, but now I can't make it run Minecraft specifically. I feel like the problem could be fixed with an Nvidia application profile for Java runtime, but I don't understand the documentation on Nvidia's website. If someone can just post a rule key that forces an application to use Nvidia (and actually works; I found one, but it's "not recognized"), that would be great.
specs: Lenovo y520 laptop i5 CPU Intel 620 HD/Nvidia geforce 1050 ti 8 gb ram Ubuntu 18.04
if I missed any specs, please tell me, I'm new to posting questions.
First,
Inside your 'NVIDIA X Server Settings' window, underneath a drop-down menu called something like "GPU 0 (GeForce GTX .....)" there is an option for creating Application Profiles appropriately titled such. Click it.
Creating Application Profiles
Once in this window, you should see two tabs. One called Rules, and the other called Profiles. Click the Profiles tab and then click the green plus button just beneath it to add a new profile.Name this profile what you want (something memorable) and add all listed settings (They're what Minecraft actually needs and avoids redundancies):
Once your list is complete and looks like mine, click the green plus button at the bottom of the window to save the current profile.
Select the setting from the drop-down menu under the "Source File" entry and click the green plus button to add it to the list.
Source File should be left alone. This is the location where these profile settings are saved. Ubuntu generates this location for you by default. DO NOT edit this.
Adding New Profiles
Next,
We need to add rules to this profile such as, which process ID's can utilize it's power and if this rule applies to all programs that use the GPU.
Click the rules tab and add a new rule using the green plus button. In a section of this window called Rule Pattern there's a drop-down menu and a text entry. In the drop-down menu select Always Applies and in the text entry field type Java.
In a section called Rule Profile there should be a drop-down menu. Click on that and select the Profile you just created. A list of all the NVIDIA GL settings you added should appear in the list space below. If this is true for you click the green plus button at the bottom of the window to save.
Adding New Rules
Then,
If you have followed all these steps correctly your NVIDIA x Server Settings Application Profiles window on Rules tab should look something like this:
Completed Application Profile Example
Lastly,
Save the new configuration you just created by clicking the disk icon with the green down arrow.
You may now close the NVIDIA Server Settings window, start Minecraft and Enjoy. If you have any questions pertaining to this thread or my post, or if you have any issues with this configuration please let me know. Use my profile link.
EXTRAS
In the rules tab, you can create a new rule with the Always Applies feature to the process ID of a running instance of Minecraft. Use the terminal and type
locate a process called Java. Looks like this:
Copy the PID number (in my case: 4307) and use that in the text entry labeled "Matches this String". Save and exit.
NOTE: This doesn't work all the time and has to be updated frequently because the PID changes.
I've done it! I've found it! I found a hack that works!
Make a script at any desired location. Save the file path for later. I personally put mine at
~/.minecraft/launch.sh
. Copy and paste the following:Your
java
orprime-run
executables may be found somewhere else. To find them, simply type these into your terminalprime-run
is used by Nvidia to launch any program using the GPU. I installedprime-run
by installing the proprietary Nvidia drivers. See instructions by your Linux distro on how to install them.The
$@
variable contains all the arguments passed to the script.Don't forget to make the script executable!
Open up the Minecraft launcher, and go to the
Installations
tab. You'll have to do this with each installation, which is fine for me since I usually play on the latest Fabric release.Once you've hit
Edit
, you'll want to hit theMORE OPTIONS
submenu at the bottom, and change the Java executable path.Find the script from above, and set it as the new "executable." Load up the game, join a world, press F3 and double check that it's using your Nvidia GPU!
Without the GPU: With the GPU: (To notice the differences, look at the top right for the hardware list.)
This is more of a hack than anything, but it works and now I can play modded and stream without my laptop dying on me. I hope this helps everyone well.
EDIT: Don't place the script in the
~/.minecraft/launcher/launch.sh
directory. Whenever the launcher updates, it'll be removed. Placing it outside the directory, over in~/.minecraft/launch.sh
works fine.EDIT 2: If you ever get stuck on the "Finalizing" stage when launching, it's because the
launch.sh
script isn't executable! Make sure to add the executable bit onto the file.EDIT 3: Make sure the Bash arguments are quoted! If they aren't quoted, then this means that not all arguments will be respected, which could lead to lower or higher ram usage than specified.
Download and install the Minecraft launcher. The official site has a
.deb
package, so all you need is to download it, go to its directory and executesudo apt install ./Minecraft.deb
.Install Nvidia's driver. You can use
nvidia-detect
to find out which one you should install. It will probably be simplysudo apt install nvidia-driver
.Reboot (perhaps not needed).
Run Minecraft with
As described in https://starbeamrainbowlabs.com/blog/article.php?article=posts%2F436-running-application-on-nvidia.html.
prime-run is deprecated. The answer which worked for me was
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia minecraft-launcher
I entered this in terminal and it launched with 60 fps:
/bin/TLauncher-2.75.jar
is my location for Java launcher.install
nvidia-prime
and run the launcher withprime-run java -jar ./launchersname.jar