Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by graciela_unity · Jul 12, 2018 at 03:05 PM · unity 5linuxvirtualsetupmachine

Is it possible to run a game built in Unity (executable for linux) in a Ubuntu 16.04 VM on Google Cloud Platform?

I'm trying to run a simulator built in Unity in a Ubuntu instance in Google Cloud Platform. Is it possible? If so, could you give some pointers on what to try?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by GabLeRoux · Jul 12, 2018 at 04:28 PM

It really depends on what's running on the remote server. There are a few options:


Running VNC Server on the remote server

Here's a tutorial for running vnc on Google Cloud Engine


Running using ssh -X (will probably not work)

Sometimes, it's possible to bring a UI from a server to another if it supports X-Server, example using ssh -x, as shown in the manual:

 -X      Enables X11 forwarding.  This can also be specified on a per-host basis in a configuration file.

But I don't think it's possible to run a unity game under X11 ;)

Running the game using xvfb

If for some reason, you don't need the built executable to display anything (Ex: a game server built under Unity), invoking it from the command line could work, but usually, Unity builds need a connected display. You can start the application by specifying a virtual display on the remote server when, ex; when connected over ssh:

 xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
 path/to/your/unity-game

You can get the xvfb-run command by installing xvfb package on Ubuntu:

 sudo apt install -y xvfb

Have a look to xvfb-run man pages for more details.

The error you may get if you try executing it directly on a remote server

I just tried with the following sample unity game built for StandaloneLinux64:

 wget https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/jobs/80079334/artifacts/download -O build-StandaloneLinux64.zip
 unzip build-StandaloneLinux64.zip

And here's what happens when running it:

 ./Builds/StandaloneLinux64/ExampleProjectName

Output:

 Set current directory to /root/Builds/StandaloneLinux64
 Found path: /root/Builds/StandaloneLinux64/ExampleProjectName
 Mono path[0] = '/root/Builds/StandaloneLinux64/ExampleProjectName_Data/Managed'
 Mono config path = '/root/Builds/StandaloneLinux64/ExampleProjectName_Data/Mono/etc'
 Unable to preload the following plugins:
     ScreenSelector.so
 Player data archive not found at `/root/Builds/StandaloneLinux64/ExampleProjectName_Data/data.unity3d`, using local filesystem
 PlayerPrefs - Creating folder: /root/.config/unity3d/DefaultCompany
 PlayerPrefs - Creating folder: /root/.config/unity3d/DefaultCompany/ThirdPersonControlOrbitCam
 Logging to /root/.config/unity3d/DefaultCompany/ThirdPersonControlOrbitCam/Player.log
 Stacktrace:


 Native stacktrace:

     /root/Builds/StandaloneLinux64/ExampleProjectName_Data/Mono/x86_64/libmono.so(+0x92456) [0x7f39fa7da456]
     /lib/x86_64-linux-gnu/libpthread.so.0(+0x1166f) [0x7f39fdde966f]
     /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x9f) [0x7f39fcf9677f]
     /lib/x86_64-linux-gnu/libc.so.6(abort+0x169) [0x7f39fcf98379]
     ./ExampleProjectName() [0xa32f2b]
     /root/Builds/StandaloneLinux64/ExampleProjectName_Data/Mono/x86_64/libmono.so(+0xd1582) [0x7f39fa819582]
     /root/Builds/StandaloneLinux64/ExampleProjectName_Data/Mono/x86_64/libmono.so(+0x3510d) [0x7f39fa77d10d]
     /lib/x86_64-linux-gnu/libpthread.so.0(+0x1166f) [0x7f39fdde966f]
     ./ExampleProjectName(SDL_GL_GetAttribute_REAL+0x1e3) [0x14a5a23]
     ./ExampleProjectName() [0x133dd5e]
     ./ExampleProjectName() [0x133c51b]
     ./ExampleProjectName() [0x133c5e7]
     ./ExampleProjectName() [0x130e3eb]
     ./ExampleProjectName() [0x45a989]
     /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f39fcf813f0]
     ./ExampleProjectName() [0x466828]

 Debug info from gdb:


 =================================================================
 Got a SIGABRT while executing native code. This usually indicates
 a fatal error in the mono runtime or one of the native libraries
 used by your application.
 =================================================================

 [1]    5329 abort (core dumped)  ./ExampleProjectName

tldr; you need a screen.

Running with xvfb works:
 xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
 ./Builds/StandaloneLinux64/ExampleProjectName

Output:

 Set current directory to /
 Found path: /Builds/StandaloneLinux64/ExampleProjectName
 Mono path[0] = '/Builds/StandaloneLinux64/ExampleProjectName_Data/Managed'
 Mono config path = '/Builds/StandaloneLinux64/ExampleProjectName_Data/Mono/etc'
 Preloaded 'ScreenSelector.so'
 Player data archive not found at `/Builds/StandaloneLinux64/ExampleProjectName_Data/data.unity3d`, using local filesystem
 Logging to /root/.config/unity3d/DefaultCompany/ThirdPersonControlOrbitCam/Player.log

And it keeps running!


Running a unity3d game inside docker

Note: I actually tested this, here's a minimal Dockerfile:

 FROM ubuntu:16.04

 RUN apt-get update -qq; \
   apt-get install -qq -y \
   xvfb \
   wget \
   zip \
   && apt-get clean \
   && rm -rf /var/lib/apt/lists/*

Here are the commands that confirms you can run a Unity3d game:

 docker build . -name gableroux/unity3d-game-example
 docker run --rm -it gableroux/unity3d-game-example bash
 # once iside the docker image:
 wget https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/jobs/80079334/artifacts/download -O build-StandaloneLinux64.zip
 xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
     ./Builds/StandaloneLinux64/ExampleProjectName

So in the end, yes, I'm sure it's possible, you could even bake a docker image with the game inside and deploy it somewhere in the cloud. Good luck and have fun! :)


If that helped you and you're curious about the game used in the example, have a look to this neat project which lets you build and test Unity games in the cloud using a CI:

  • https://gitlab.com/gableroux/unity3d-gitlab-ci-example

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sgrein · Dec 10, 2018 at 04:02 AM 0
Share

@GabLeRoux this is great.

avatar image
1

Answer by graciela_unity · Jul 12, 2018 at 05:44 PM

Thank you for your answer @GabLeRoux ! I just realized that my question is incomplete, what I wanted to ask: Is it possibles it possible to run a game built in Unity in a Ubuntu 16.04 VM with only CPU on Google Cloud Platform? .

I can put whatever is necessary on the VM to make it work.

I already have implemented this but when I run it I get Segmentation fault (core dumped)

Thank you in advance for your help!

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image GabLeRoux · Jul 12, 2018 at 06:28 PM 1
Share

The docker example in my answer doesn't use GPU at all and can be deployed in the cloud (ex; Google Cloud Engine). I just tried it on heroku (was faster to test for me) and I was able to launch the game on the server. I'm not 100% sure it's running exactly how it should, but it really looks like it's working fine.

$$anonymous$$aybe in your case, there's something different. You should paste your stacktrace here, maybe it has interesting details.

For my experiment, here's what I did:

 $ wget https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/jobs/80079334/artifacts/download -O build-StandaloneLinux64.zip
 $ cat Dockerfile

 FRO$$anonymous$$ ubuntu:16.04
 RUN apt-get update -qq; \
   apt-get install -qq -y \
   xvfb \
   wget \
   zip \
   && apt-get clean \
   && rm -rf /var/lib/apt/lists/*
 COPY build-StandaloneLinux64.zip ./
 RUN unzip build-StandaloneLinux64.zip

 $ cat docker-compose.yml
 version: '2'
 services:
   unity-game:
     build: .

 $ heroku create

 Creating app... done, ⬢ calm-dusk-24780
 https://calm-dusk-24780.herokuapp.com/ | https://git.heroku.com/calm-dusk-24780.git

 $ docker login --username=_ --password=$(heroku auth:token) registry.heroku.com
 $ heroku container:push unity-game -a calm-dusk-24780
 $ heroku container:release unity-game -a calm-dusk-24780
 $ heroku container:run -a calm-dusk-24780 unity-game bash

 # now I'm inside the remote docker

 $ xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' ./Builds/StandaloneLinux64/ExampleProjectName

Output

 Set current directory to /
 Found path: /Builds/StandaloneLinux64/ExampleProjectName
 $$anonymous$$ono path[0] = '/Builds/StandaloneLinux64/ExampleProjectName_Data/$$anonymous$$anaged'
 $$anonymous$$ono config path = '/Builds/StandaloneLinux64/ExampleProjectName_Data/$$anonymous$$ono/etc'
 Unable to preload the following plugins:
     ScreenSelector.so
 Player data archive not found at `/Builds/StandaloneLinux64/ExampleProjectName_Data/data.unity3d`, using local filesystem
 PlayerPrefs - Creating folder: /.config/unity3d/DefaultCompany
 CreateDirectory '/.config' failed:  (current dir: /Builds/StandaloneLinux64/ExampleProjectName_Data)
 PlayerPrefs - Creating folder: /.config/unity3d/DefaultCompany/ThirdPersonControlOrbitCam
 CreateDirectory '/.config' failed:  (current dir: /Builds/StandaloneLinux64/ExampleProjectName_Data)
 Logging to /.config/unity3d/DefaultCompany/ThirdPersonControlOrbitCam/Player.log

Above log has a few errors (ie; heroku doesn't allow you to write files on its filesystem), but that really depends on the hosting platform. It doesn't crash with a Segmentation fault here. So really, I'm quite sure you can do this on google cloud engine too ;)

avatar image graciela_unity GabLeRoux · Jul 12, 2018 at 06:57 PM 0
Share

@GabLeRoux I just built your docker container and ran your ExampleProjectName game. I got the same output like you, so that's done :D! However, I just tried to run my game and it is requesting a lot of libraries (libxcursor1 and libXrandr.so.2 so far), I'll install them in the dockerfile and I'll let you know.

Other thing (newbie here), if I want to be able to see the game, how can I do it?

Thank you!

avatar image graciela_unity graciela_unity · Jul 12, 2018 at 07:18 PM 0
Share

Update: After installing those two libraries, looks like it is running now. This the traceback:

 xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' ./term2_sim.x86_
 64
 Set current directory to /term2_sim_linux
 Found path: /term2_sim_linux/term2_sim.x86_64
 $$anonymous$$ono path[0] = '/term2_sim_linux/term2_sim_Data/$$anonymous$$anaged'
 $$anonymous$$ono path[1] = '/term2_sim_linux/term2_sim_Data/$$anonymous$$ono'
 $$anonymous$$ono config path = '/term2_sim_linux/term2_sim_Data/$$anonymous$$ono/etc'
 displaymanager : xrandr version warning. 1.5
 displaymanager : trying .X11-unix
 client :99 has 1 screens
 displaymanager screen (0): 640 x 480
 Using libudev for joystick management
 Importing game controller configs

So now should I start a remote server? like in here to see the simulator?

avatar image
0

Answer by daohu527 · Nov 20, 2019 at 08:57 AM

If I want to run Unity exe in docker. I just need to run a ubuntu docker and put the exe file in it. Then another question is, do I also need nvidia docker?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

185 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

No sound in Unity on Linux, but sound works in built game 1 Answer

Virtual Reality Toolkit 1 Answer

Unity on Windows, Xcode on VMware? 0 Answers

Unity at fedora linux,Unity at fedora. 0 Answers

Unity Native VR doesn't work!! 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges