Running Unity3D without a graphics card – An odyssey

You probably landed here because you are a Unity3D developer like I am. More or less experienced with the “normal” handling of the Unity Editor. And now you want (or have to) go a step further and make Unity running on your server, e.g. for automatic regular builds with Jenkins or another continuous integration tool.

If the situation sounds familiar to you, go and read on, hopefully my experiences will help you to get your system running more quickly. If you think what the heck the first sentences were all about: Here is some cat content for you!

The Situation

So, let’s see what our concrete situation was like:

Unity3D mobile game

Running Jenkins build server

Windows Standalone build of the game works
(with options -batchmode -nographics -buildWindowsPlayer)

Not bad for a start, the builds ran daily and allowed us to always test the current version of our game. But only a standalone version unfortunately. We wanted more!

The Problem

For a mobile game you want to test the game on a mobile device, of course. And you don’t want to have to build a player manually each time a tester/an artist/a game designer/your mum/… wants to check out the current version of your game.

Not a big problem I thought in the beginning. We had the standalone build already set up and I created a script to build a desired build target from the command line by using the -executeMethod command line parameter. The command which should give us a nice little Android player of the current version each night looked as simple as this:

buildpath and buildtarget are two parameters of the PerformBuild method of my BuildPlayer script so it knows which target to build and where to store the output.

Well, almost nothing works out the first time you run it on the build server, and this build step was no exception. Unity complained that “Building Player from editor scripts requires Unity PRO”. And this is where the odyssey began…

Just activating the license

Not a big problem, I thought. We already purchased a Unity PRO license to enjoy the features which facilitate your professional development life (or which were left out from the free version to make you pay when you get more professional).

Our build server is really a headless one, a Virtual Server from a big hosting company. So no graphics card, that’s why we had to use the -nographics switch to run Unity from the command line. If such a switch exists, it should also be possible to activate Unity PRO without a graphics card, shouldn’t it? Particularly because you can’t start the Unity Editor and use the menu for it, as Unity complains “Fatal Error! Failed to initialize unity graphics.” when you try to start the Editor without a graphics card.

[singlepic id=23 w= h= float= center]

A web search didn’t bring up a solution, so I contacted the Unity support. There is a way to activate the license on a computer which doesn’t have internet access, but you still have to start the editor to activate it. But that’s not possible without a graphics card. I was stuck.

Trying it the other way around

Ok, if Unity needs a graphics card to be activated, maybe graphics acceleration can be enabled on our Virtual Server. This is possible in some virtual machines and I hoped it would take only a toggle check to give graphics acceleration to our system. Unfortunately it was not possible at all and upgrading to a root server with a graphics card was no option (Hey, we are just a small Indie studio!).

The solution

So our Virtual Server doesn’t have graphics acceleration and can’t get it from the server provider. But Unity insists on requiring a graphics card to start the editor to activate the license. Tricky!

The idea with the graphics acceleration for the virtual machine wasn’t far away from the actual solution though. Unity doesn’t need a graphics card, it just has to think there is one! And you can already start the editor and force it to use OpenGL. Plus there are OpenGL drivers which use a software renderer!

Mesa3D to the rescue!

Actually there are just a few in the end and really only one free open source library which seems to be still active: Mesa3D

[singlepic id=25 float=left]

It looks like it is very up-to-date (Last release 10.0.2 from 09.01.2014), so I decided to go for it. Just have to find the correct DLLs to put them on our Windows server. Ah, there it is, “Precompiled Libraries”. But this would be far too easy, wouldn’t it? Of course it would, that’s why the page only tells me “In general, precompiled Mesa libraries are not available.” Maybe the guys from Mesa3D could need a continuous integration system, too?

I won’t tell you all the details that finally got me to the two DLLs I needed (maybe in another post), it was a hard fight with command line compilers and a nasty bug in the current version of Mesa3D. But I’ll give you my well-earned prize for your own headless server:

Run your Android build once from the Editor. You will have to set your Android SDK path which is also not possible from command line.

Enjoy “Building Player from editor scripts” from the command line on your headless server without any graphics card!

Conclusion

It was a long and hard trip to get it running, but in the end it was absolutely worth it. Our build server creates daily versions of our game which we can access directly from our mobile devices, install them and play. I think we haven’t make up the lost time yet, but we will definitively during this project and can concentrate completely on the development instead of building the players.

Here are some ideas for improvements for all the companies I came across during my odyssey:

Mesa3D: Jenkins is a great continuous integration tool and can be set up real quickly. This would also make sure the releases compile on every system, which version 10.0.2 didn’t without a small source code correction.

Nonetheless I am thankful for all those companies who provide great software and hardware for no or little money and allow even small studios to work professionally!

Hope this post will save you some time! If you have any questions just post a reply, I will try to answer each of them.

Last but not least: If you have an answer to the question how one can build a Unity Android player without administrator rights, please send me a mail 🙂 This was an odyssey on its own but had no happy ending so far…

25 thoughts on “Running Unity3D without a graphics card – An odyssey”

Cool, thanks Graham 🙂 By the way: Support team was super helpful and did some investigations if there is any way to activate the license without starting the Unity editor, but unfortunately there’s none yet.

Anyways (without promising anything on delivery date etc :)), we have command-line activation of Unity in 5.0 and have used this internally for a few months now on our build farm. So if other experience this issue, please have some patience (or just use alpha build to activate, if you are an Unity alpha-list member)

Thanks for the info! That’s great news! 🙂 When I searched for a way to activate Unity my first thought was that there has to be a way to activate it via command line, after all it’s already possible to build from command line. Nice to hear that this feature will make its way into 5.0!

I haven’t experienced any issues with the -nographics argument, yet. We are building a Windows standalone and an Android version right now on our build server. As there were no problems about it, I haven’t tried to build without it, it may work or not. I think I’ll give it a shot next week.

I tried to not use the -nographics option and instead used the -force-opengl one (otherwise Unity will try to load DirectX which fails due to the missing graphics card). It worked and build a working version.

There was also one graphic issue which was fixed by the change, so I guess we shouldn’t use the -nographics option at all. Thanks again for your comment!

I was facing the same problem last year. We are also developing Unity Standalone Player Games for Windows which are continously integrated on a server of us.
Our solution was to really put a PCI graphics card in the server (glad to have our own) to be able to activate Unity pro.
Bad luck for us, you have not got your solution then, it would have saved us some time.

Anyways have you experienced asset import problems when only using the server builds?
We use a own Subversion (no asset server for us) repository and a continous integration server running cc.net and Windows Server 2003 (bad luck again – old system).
After some time it happened that textures stopped showing or other graphical bugs appeared and I was only able to solve these by opening Unity on the server and reimporting all assets – after this the build worked without problems…
Maybe you are facing some similar problems.

We are using the -nographics argument for our standalone windows build and the game is always showing nice graphics – if the assets are there correctly 😉

This post has been a life saver for me, I’m currently in Mexico taking care of some family and my Laptop unfortunately came with the ATI Radeon Mobility 7500 graphics chip which Unity would not start. On windows 7 it doesn’t even recognize the shader model at all (says the GPU only supports shader model 0.0) and on windows xp I forget the exact error message but said something about the editor needing 4 textures and mine only supported 3.

I’m not developing a 3D game, its only 2D for mobile and web player (which web player on this laptop works perfect) so I don’t need all the 3D features of the editor only the ability to add textures and gui skins.

I’ve been having to use either TeamViwer or Remote Desktop to connect to my computer back home to develop, which is ok but hard to work with any local resources or do anything if I’m not online.

it doesn’t run at the speed I’m used to on my home computer (AMD A4 dual core 6GB ram and 1GB vid ram) but at least it does work.

so once again I can’t thank you enough I’ve been trying to figure out how to do this for a couple weeks now.

Nice workaround. If it helps you in the future, you don’t need your final step 4 (“Run your Android build once from the Editor. You will have to set your Android SDK path which is also not possible from command line.”) It is possible to set it from the command line (more or less). To set the Android SDK in headless mode (since you’re already using -executeMethod), you can create an auto-build class that calls the PerformBuild method, but add this in first:

Cool, thanks a lot for the information! As it’s just a one time step I didn’t investigate too much how to set it via command line 😉 But it’s definitively helpful, so the build can be managed completely via command line.

I’m able to run the Unity 5.1.1 editor with full GUI over Remote Desktop in an Azure VM (4 core, 7.5 gig, Windows Server 2012, it will likely run in a smaller VM as well, that’s just what I happened to be running it on). Startup is quite slow (a minute? before the importing assets progress bar appeared) and the frame rate is also slow but it looks very promising for use as a build server.

Hi Don,
Great to hear that it works for you! It’s not really meant to use the editor on the build server, just to activate the license 🙂 Guess the editor is a bit too graphic heavy to perform good without a graphics card.

The article describes a way to build with Unity3D on a PC without a graphics card. This is useful for example if you have a build server which doesn’t have a graphics card. You need to install Unity3D on the server and put some DLLs into the Unity3D folder, so you need full access to it.