Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker GPU Support? #102

Open
Mannilie opened this issue Mar 1, 2021 · 13 comments
Open

Docker GPU Support? #102

Mannilie opened this issue Mar 1, 2021 · 13 comments
Labels
enhancement New feature or request

Comments

@Mannilie
Copy link

Mannilie commented Mar 1, 2021

I'm trying to perform unit tests on GPU shaders and I've gone through setting up my docker (in my self-hosted runner) to use my nvidia GPU (RTX 2080) but I still keep getting errors to do with Compute Shaders in Unity not compiling through docker.

Is there some setting in the Unity Test Runner GitHub Action that could be overwriting this value?

@webbertakken
Copy link
Member

Are you using the latest (v2 alpha) version of test runner?

Could you also indicate which unity version you're using?

@Mannilie
Copy link
Author

Mannilie commented Mar 1, 2021

Here's the latest version I am using.

Also note that I tried using custom parameters with: -force-opengl and --default-runtime=nvidia but I think I'm using it wrong :/

  
name: Build project
on:
  pull_request: {}
  push: { branches: [Release-DLL] }
env:
  UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
  
jobs:
  testAllModes:
    name: ${{ matrix.unityVersion }} ${{ matrix.testMode }} ${{ matrix.targetPlatform }}
    runs-on: self-hosted
    strategy:
      fail-fast: false
      matrix:
        projectPath:
          - ./
        unityVersion:
          - 2019.4.11f1
          #- 2020.2.0f1
        targetPlatform:
          #- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
          #- StandaloneWindows # Build a Windows standalone.
          #- StandaloneWindows64 # Build a Windows 64-bit standalone.
          - StandaloneLinux64 # Build a Linux 64-bit standalone.
        testMode:
          - playmode
          #- editmode
    steps:
      - uses: actions/[email protected]
        with:
          fetch-depth: 0
          lfs: true
      - uses: actions/[email protected]
        with:
          path: ${{ matrix.projectPath }}/Library
          key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
          restore-keys: |
            Library-${{ matrix.projectPath }}-
            Library-
      - uses: game-ci/[email protected]
        id: tests
        with:
          projectPath: ${{ matrix.projectPath }}
          unityVersion: ${{ matrix.unityVersion }}
          testMode: ${{ matrix.testMode }}
          artifactsPath: ${{ matrix.testMode }}-artifacts
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          checkName: true
          customParameters: -force-opengl
      - uses: actions/upload-artifact@v2
        with:
          name: Test results for ${{ matrix.testMode }}
          path: ${{ steps.tests.outputs.artifactsPath }}

@webbertakken
Copy link
Member

Test runner will pass custom parameters directly into the editor.

You can use all the Unity command line parameters from the documentation (scroll down a bit to Options).

Note that you shouldn't pass arguments that the action already passes by default, as duplicate parameters will fail your build.

As for how to solve the problem; no idea. Hopefully someone else has any ideas.

@Mannilie
Copy link
Author

Mannilie commented Mar 1, 2021

After a heap of research into this, I've found that it must be related to the fact that the test runner is running as a headless editor. Hense, the Compute Shaders aren't being run.

Is there any way around this perhaps? I was going to test it without batchmode but I don't think you can change it in the GitHub Action.

@webbertakken
Copy link
Member

Currently no, but you could fork the action, change some things and try it out. If you manage to run it without headless flag we could introduce a parameter that enables testing shaders.

Note that you may have to use the customImage flag as well and install additional packages to the editor image.

@Mannilie
Copy link
Author

Mannilie commented Mar 8, 2021

Hey just a quick question,
Is there anywhere in this repo that is forcing the renderer to be set to llvmpipe?
I'm trying to expose the NVIDIA driver to docker and I've tried everything. It works on other docker images just not "unityci/editor:...." ones.

image

@Mannilie
Copy link
Author

Mannilie commented Mar 8, 2021

Gosh, I'm having the worst time trying to change the graphics card renderer with Unity.
It says on the host machine that the NVIDIA graphics card is exposed to Docker... just Unity isn't using it at all... it keeps defaulting back to this renderer (llvmpipe)

@Mannilie
Copy link
Author

Okay, I know this must be annoying but I made some headway with this issue and I'm writing this for anyone who experiences this issue.

I'm directing the issue over to Unity because it appears that Docker and everything else seems to be accepting the graphics card within the container but Unity is the only app that doesn't detect GPUs in the context of a 'virtual' environment.

@webbertakken
Copy link
Member

Did you end up trying without the -batchmode flag (which is hardcoded in our images)?

@Mannilie
Copy link
Author

I can confirm that -batchmode was the reason it wasn't picking up the GPU... is there a way that you can make a variable for that somewhere?

@webbertakken
Copy link
Member

You can run the editor without the alias that we are providing, which will omit the flag. You could also extend the image and create your own alias.

Inside the action you can use the customImage parameter. To also change the command that the action issues, you could fork the action and change it.

If you're able to get the action to work without -batchmode, we're open to accept a PR both on docker and on this action (as well as on the builder action). The PR on docker will automatically be tested against all the latest unity versions.

@webbertakken webbertakken reopened this Mar 15, 2021
@Mannilie
Copy link
Author

Hey @webbertakken ,

It just occurred to me that I left this open. I actually managed to solve the issue!

It's such a damn setup though and I had to make my own fork to do it. I'll make a pull request with what I changed so you can see the settings I had to put in.

No custom image required.

Thanks for all your help!

@webbertakken
Copy link
Member

Related: #113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants