VMware Communities
COREstorm
Contributor
Contributor

Workstation 9 - No 3D Acceleration to Guest - Ubuntu 12.04 Host - Nvidia Card

Ok, I've been going at this for some time.

Current Installation: Fresh install of Ubuntu 12.04

Video card: Nvidia Optimus GT540M

VMware: Workstation 9. (Unbuntu 12.04 is the HOST)

(Brief history: tried to get 3D support working under Workstation 8, using numerous nvidia drivers (every step you can find online), upgraded to Workstation 9 and retried all the steps. Reinstalled Ubuntu.);

Current status: Currently using Bumblebee. 3D WORKS on Ubuntu. I have glxinfo returning YES for 3D support and glxspheres working.

Since No nvidia drivers are installed, Vmware Workstation WILL NOT recognize the video card, and thus will not enable 3D support for the Windows 7 VM. - This is the problem we need to solve.

I have tried to uninstall Bumblebee and install Nvidia drivers and suffered from the 640x480 issue, with the Nvidia Settings not detecting a proper x configuration.

So the issue is currently: VMware will not recognize the video card properly since Bumblebee is installed. The 3D support will ONLY (so far) work using Bumblebee.

Let the delimma begin. This is currently a Vmware issue, although could quickly become another Ubuntu 12.04 issue if I have to go down the path of many drivers.

(Yes, I spent 9 hours trying to install every version of the Nvidia drivers everyone "suggested" with zero luck and many issues.)

112 Replies
cmillersp
Contributor
Contributor

Ok, here's the guide to get vmware workstation working with nvidia acceleration.

ASSUMING: vmware workstation 9.0.1 or 8.0.5, ubuntu 12.10, optimus, working bumblebee config, x86_64 os.

If you don't have bumblebee set up yet, there are numerous tutorials to help you. Follow them.

1.  sudo apt-add-repository ppa:zhurikhin/primus

2. sudo apt-get update; sudo apt-get install primus primus-libs primus-libs:i386

3. Check that primus works. Try primusrun glxspheres.

4. If you don't have vmware installed, install it now.

5. sudo chmod a+s /usr/lib/x86_64-linux-gnu/primus/libGL.so.1

6. sudo ln -s /usr/lib/nvidia-current/tls/libnvidia-tls.so.304.43 /usr/lib/x86_64-linux-gnu/

sudo ln -s /usr/lib/nvidia-current/libnvidia-glcore.so.304.43 /usr/lib/x86_64-linux-gnu/
sudo ldconfig

7. sudo /etc/init.d/vmware stop

sudo mv /usr/lib/vmware/bin/vmware-vmx /usr/lib/vmware/bin/vmware-vmx.real

8. sudo gedit /usr/lib/vmware/bin/vmware-vmx
(paste in the following)

#!/bin/bash

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/primus/libGL.so.1 exec primusrun /usr/lib/vmware/bin/vmware-vmx.real "$@"
9. sudo chmod u+s,a+x /usr/lib/vmware/bin/vmware-vmx
sudo /etc/init.d/vmware start
10. Run vmware, AS ROOT (sudo vmware)
11. Enjoy 3d acceleration.
So far, no crashes, decent performance.  Of course it's nowhere near an ideal solution, but it's the best I've been able to come up with at this point, and I'm really, really happy to have hardware acceleration.
Reply
0 Kudos
goomba000
Contributor
Contributor

Works for me too, well done!

Any idea why we need to run vmware as root?  I did set /usr/lib/x86_64-linux-gnu/primus/libGL.so.1 setuid root but it still doesn't load when I run vmware as a user and I don't have any relevant output on the terminal.

Reply
0 Kudos
cmillersp
Contributor
Contributor

With primusrun and setuid binaries this is always the case, as far as I can tell.  I'm not sure that setuid'ing the libGL library makes a difference. I have to play with it more. However, this does give the benefit of letting one use the intel card when wanted by not running vmware as root.

I think this may be as good as we'll get, but I'm still thrilled to be able to use hardware acceleration with VMs at all.  I'll try to look into a non-root solution, but I don't think the outcome looks too great, as any fix would likely involve lots of hacky stuff.

Reply
0 Kudos
goomba000
Contributor
Contributor

cmillersp wrote:

With primusrun and setuid binaries this is always the case, as far as I can tell.  I'm not sure that setuid'ing the libGL library makes a difference. I have to play with it more. However, this does give the benefit of letting one use the intel card when wanted by not running vmware as root.

I think this may be as good as we'll get, but I'm still thrilled to be able to use hardware acceleration with VMs at all.  I'll try to look into a non-root solution, but I don't think the outcome looks too great, as any fix would likely involve lots of hacky stuff.

Indeed, I just spoke to amonakov.  primusrun relies on LD_LIBRARY_PATH and setuid root executables don't have access to it (for security reasons).  One possible workaround suggested by amonakov would have been to simply make /usr/lib/x86_64-linux-gnu/primus/libGL.so.1 the "system-wide" libGL.so.1 by putting it in ld.so.conf (and removing the others or putting them lower priority), but then you have to use it for everything, and after testing it, VMWare complains that a bunch of glx functions are not present (vmware needs a whole bunch which are not implemented in primus), so LD_LIBRARY_PATH is required to have fallback libGL.so.1's (nvidia's or mesa's).

So in short this is as good as it gets for now.

Cheers

Reply
0 Kudos
rashm2k
Contributor
Contributor

Excelent cmillersp!

primusrun works perfectly well for me!!!!! At least I get some 3D goodness offloaded to the GFX, windows is then usable.

I'm using openSUSE 12.2, I installed primusrun from openSUSE repo and then needed to tweak the run script to add this:

LD_PRELOAD=/usr/lib64/nvidia/tls/libnvidia-tls.so.310.19:/usr/lib64/primus/libGL.so.1:/usr/lib64/nvidia/libnvidia-glcore.so.310.19 exec primusrun /usr/lib/vmware/bin/vmware-vmx.real "$@"

because the locations are not same as ubuntu.

Reply
0 Kudos
LinuxReCon
Contributor
Contributor

Well, this does not work for me here, I get the following output, when I'm trying to start a Virtual Machine:

sudo vmware
Logging to /tmp/vmware-root/vmware-modconfig-8130.log
filename:       /lib/modules/3.5.0-19-generic/misc/vmmon.ko
supported:      external
license:        GPL v2
description:    VMware Virtual Machine Monitor.
author:         VMware, Inc.
srcversion:     9342145FB4C112347AF67BE
depends:       
vermagic:       3.5.0-19-generic SMP mod_unload modversions
»/desktop/gnome/interface/menus_have_tearoff« wurde kein Wert zugewiesen
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 9: reading configurations from ~/.fonts.conf is deprecated.
primus: fatal: failed to load any of the libraries: /usr/lib/nvidia-current/libGL.so.1:/usr/lib32/nvidia-current/libGL.so.1
libnvidia-tls.so.304.64: cannot open shared object file: No such file or directory
/usr/lib32/nvidia-current/libGL.so.1: wrong ELF class: ELFCLASS32

Also, at the "sudo ldconfig" step, the symbolic links which are created before (ln -s) are gone. What's wrong here?

Reply
0 Kudos
rashm2k
Contributor
Contributor

LinuxReCon the problem is that you are linking to the 32 bit libs but you have the 64 bit vmware.

my /usr/lib/vmware/bin/vmware-vmx file looks like this:

#!/bin/bash


LD_PRELOAD=/usr/lib64/nvidia/tls/libnvidia-tls.so.310.19:/usr/lib64/primus/libGL.so.1:/usr/lib64/nvidia/libnvidia-glcore.so.310.19 exec primusrun /usr/lib/vmware/bin/vmware-vmx.real "$@"

and then I have a script to start vmware which looks like this:

#!/bin/bash

export PRIMUS_libGLa='/usr/lib64/nvidia/libGL.so.1'
export LD_LIBRARY_PATH=/usr/lib64/nvidia:/usr/lib/nvidia:/usr/lib64/nvidia/tls:/usr/lib/nvidia/tls

#this is to get sudo to work properly with vmware
export XAUTHORITY=/home/USERNAME/.Xauthority
XAUTHORITY=/home/USERNAME/.Xauthority sudo -E primusrun vmware

don't forget to replace username.

Reply
0 Kudos
LinuxReCon
Contributor
Contributor

@rashm2k: Thanks for your answear, but it was much easier ... the reason why this whole thing didn't worked for me was just the fact, that I didn't replaced the version number which is included at the symbolic link command at the tutorial from cmillersp. So cmillersp posted to create the links with the following commands:

sudo ln -s /usr/lib/nvidia-current/tls/libnvidia-tls.so.304.43 /usr/lib/x86_64-linux-gnu/

sudo ln -s /usr/lib/nvidia-current/libnvidia-glcore.so.304.43 /usr/lib/x86_64-linux-gnu/
but for myself I've got another version of the nvidia driver (304.64), so I had have to do the following commands:

sudo ln -s /usr/lib/nvidia-current/tls/libnvidia-tls.so.304.64 /usr/lib/x86_64-linux-gnu/

sudo ln -s /usr/lib/nvidia-current/libnvidia-glcore.so.304.64 /usr/lib/x86_64-linux-gnu/
... just logical Smiley Happy
So, after every update of the nvidia driver you'll have to set the symbolic links again ... matching to your version of the installed nvidia driver Smiley Wink
Overall, it's working now. I'm more interested in the 3D features, so I tried Torchlight 2 on a Windows 7 VM. Just amazing. Even on high details, I get 40 FPS at all. The only thing which a little bit annoys me is, that I have to start the VM with sudo / root rights. Is there no "workaround" for that?
Reply
0 Kudos
LinuxReCon
Contributor
Contributor

By the way, is it possible to find out that the nvidia card is used? Actually I just can say, that "it looks like" that it is gonna used, but a console output or something like that which ensures that would be awesome.

Reply
0 Kudos
goomba000
Contributor
Contributor

LinuxReCon wrote:

By the way, is it possible to find out that the nvidia card is used? Actually I just can say, that "it looks like" that it is gonna used, but a console output or something like that which ensures that would be awesome.

See one of my previous posts.  Just look in vmware.log for OpenGL lines.

Reply
0 Kudos
cmillersp
Contributor
Contributor

You can also check the temperature of the nvidia gpu from the nvidia-settings utility (optirun nvidia-settings -c :8)

When you use something like 3dmark, you'll notice the temperature goes up.

With regards to the root issue, there is currently no decent workaround.  It's very annoying, but it's still far better than nothing.

Reply
0 Kudos
docsmooth
Enthusiast
Enthusiast

These instructions worked great for my new Lenovoa T430 running Kubuntu 12.10, Thank you!

I thought I could add a bit as well: since I'm kind of a battery runtime nut, I want to be able to only run VMware under the Nvidia driver sometimes, so I scripted it with intelligence.  Full writeup, and the script, are here: http://www.totalnetsolutions.net/2012/12/08/bumblebee-primus-and-vmware-workstation-nvidia-optimus-g...

I'm hoping to add in the SuSE notes from this thread, perhaps tomorrow morning, and am actively interested in feedback, to make it maybe the first useful thing I've added to this community I've so far taken so much from.

Thanks again, cmillersp!

Rob A Deployments PM: www.likewise.com Co-Owner: www.totalnetsolutions.net
Reply
0 Kudos
cmillersp
Contributor
Contributor

That's a very useful implementation.  Hopefully people involved with VMWare will be so kind as to come up with a better solution for Optimus users at some point.

I'm very interested to know how the 3d performance for people with various set-ups is.  For example, if you have the optimus in a thinkbook t-series, I believe you can select discrete graphics in the BIOS.  I wonder if there is much of a difference in a 3d benchmark with proper nvidia driver with discrete only graphics VS my primus hack.  The reason I'm interested is that in the near future I'll want to get a new laptop, and ideally not dual boot, but I would need better 3d performance in a virtual machine to be really happy with it.

Reply
0 Kudos
docsmooth
Enthusiast
Enthusiast

I'd really like to know that, too, except that my company's IT dep. locked that setting in my bios.  At least they didn't lock it to the discrete graphics option.

I can tell you that primusrun works much faster and more responsive than optirun.  Enough that I'm not ever going to try optirun again for vmware.

Rob A Deployments PM: www.likewise.com Co-Owner: www.totalnetsolutions.net
Reply
0 Kudos
cmillersp
Contributor
Contributor

http://www.phoronix.com/scan.php?page=news_item&px=MTI1MDQ

I wonder if anyone wants to try this.  Perhaps vmware will play nicely with it?  Has nothing to do with nvidia, but might help the intel only folk.

Unfortunately, I don't have the time to set everything up.  Hoping someone wouldn't mind getting it running and trying it out, though!

Reply
0 Kudos
james33
Contributor
Contributor

I followed step by step the guide and everything seems fine (MY OS IS LINUX MINT 14 mate 64-bit)

but

I got this output when I ran VMware as sudoer as said

~ $ sudo vmware
[sudo] password for alex:
Logging to /tmp/vmware-root/vmware-modconfig-20395.log
filename:       /lib/modules/3.5.0-17-generic/misc/vmmon.ko
supported:      external
license:        GPL v2
description:    VMware Virtual Machine Monitor.
author:         VMware, Inc.
srcversion:     9342145FB4C112347AF67BE
depends:       
vermagic:       3.5.0-17-generic SMP mod_unload modversions
Xlib:  extension "NV-GLX" missing on display ":0.0".
Xlib:  extension "NV-GLX" missing on display "unix:0.0".
Xlib:  extension "NV-GLX" missing on display ":0.0".
Xlib:  extension "NV-GLX" missing on display ":0.0".
Xlib:  extension "NV-GLX" missing on display ":0.0".
Xlib:  extension "NV-GLX" missing on display ":0.0".

Reply
0 Kudos
cmillersp
Contributor
Contributor

Don't worry. That's normal. I think it has to do with primus.

Reply
0 Kudos
Emulez
Contributor
Contributor

Try using gksudo or kdesudo. Many X applications don't work when run by only 'sudo', IIRC because it doesn't preserve some environment variables.

Reply
0 Kudos
james33
Contributor
Contributor

If I run gksudo  i get the same output BUT when I quit the application

Anyway I totally agree with Linus Torvalds, if you know what I mean

here is the output


~ $ gksudo vmware
filename:       /lib/modules/3.5.0-17-generic/misc/vmmon.ko
supported:      external
license:        GPL v2
description:    VMware Virtual Machine Monitor.
author:         VMware, Inc.
srcversion:     9342145FB4C112347AF67BE
depends:       
vermagic:       3.5.0-17-generic SMP mod_unload modversions
Xlib:  extension "NV-GLX" missing on display ":0".
Xlib:  extension "NV-GLX" missing on display "unix:0.0".
Xlib:  extension "NV-GLX" missing on display ":0".
Xlib:  extension "NV-GLX" missing on display ":0".
Xlib:  extension "NV-GLX" missing on display ":0".
Xlib:  extension "NV-GLX" missing on display ":0".

Reply
0 Kudos
james33
Contributor
Contributor

I don't think that 3D acceleration works  I did some test running glxgears inside the VM machine with and without running it as sudoer and I got the same fps

take a look

Running with gksudo I got no errors about 3D acceleration that seems correctly enabled in VMware Workstation prefences.

1.jpeg

When I close the VMware Workstation program I got this error screen in the CLI ↓

5.jpeg



RUNNING IT WITHOUT GKSUDO OR SUDO THEN WITHOUT 3D ACCELARATION THAT IS DISABLE AUTOMATICALLY BY THE VMware Workstation  

2.jpeg

3.jpeg

And here you can see i got the same frame rate   check below↓

4.jpeg

Reply
0 Kudos