adamrehn / pixel-streaming-linux

Issue tracker repository for Pixel Streaming for Linux
https://adamrehn.com/articles/pixel-streaming-in-linux-containers/
22 stars 7 forks source link

Help needed in Pixel Streaming #8

Closed plushpluto closed 4 years ago

plushpluto commented 4 years ago

I am trying to stream a community project for a local montessori school nearby. It is compiled using UE4-4.23.1. I tried using ue4-docker (your source). It won't help, since the docker was preprogrammed for 4.20.1. As per your suggestion in the documentation, I am trying https://adamrehn.com/articles/pixel-streaming-in-linux-containers/. I am stuck here as well. In short, I am trying to recreate your youtube demo, but the content is for the kids here.

Status:

Took the 4.23.1 source from your repo. Used my content. Compiled it. I am stuck here. Should I follow the multi-stage build? I am just a new bee for all these things. Any help!!!

plushpluto commented 4 years ago

FROM adamrehn/ue4-full:4.23.1-pixelstreaming AS builder COPY --chown=ue4:ue4 . /tmp/project WORKDIR /tmp/project RUN ue4 package FROM adamrehn/ue4-runtime:latest COPY --from=builder --chown=ue4:ue4 /tmp/project/dist/LinuxNoEditor /home/ue4/project ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES},video RUN ln -s /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1 /home/ue4/project/PixelStreamingUE4-Test2/Binaries/Linux/libnvidia-encode.so.1

The above ran with no errors.

What should I do after this step? How to run it? It is not clear.

adamrehn commented 4 years ago

Running Pixel Streaming applications built with Unreal Engine 4.23 involves the following components:

Ideally, each of these three components should be packaged into separate container images and run as three separate containers. Because the three containers need to communicate with each other via localhost, they will need to be run either with host networking mode or with a shared networking namespace (e.g. as a Kubernetes pod or through Docker Compose.)

You have already built the container image for the packaged project itself (although you'll still need to add an ENTRYPOINT directive to specify the project's startup script as the command that gets run when the container starts.) I would recommend using either a plain Ubuntu base image with a non-root user added (or simply one of the variants of the ue4-runtime base image) for the WebRTCProxy container image and a Node.js base image for the signalling server container image.

The Dockerfile for the WebRTCProxy container image might look something like this:

FROM adamrehn/ue4-full:4.23.1-pixelstreaming as builder
FROM adamrehn/ue4-runtime:latest

# Copy the WebRTCProxy application from the Pixel Streaming builder image
COPY --from=builder --chown=ue4:ue4 /home/ue4/UnrealEngine/Engine/Source/Programs/PixelStreaming/WebRTCProxy/bin/WebRTCProxy /bin/WebRTCProxy

# Set the WebRTCProxy application as the container's entrypoint
ENTRYPOINT ["/bin/WebRTCProxy"]

The Dockerfile for the signalling server container image might look something like this:

FROM adamrehn/ue4-full:4.23.1-pixelstreaming as builder
FROM node:10

# Copy the signalling server from the Pixel Streaming builder image
COPY --from=builder home/ue4/UnrealEngine/Engine/Source/Programs/PixelStreaming/WebServers/SignallingWebServer /opt/SignallingWebServer

# Install the dependencies for the signalling server
WORKDIR /opt/SignallingWebServer
RUN npm install .

# Expose TCP port 80 so external applications can access the web server
EXPOSE 80

# Set the signalling server as the container's entrypoint
ENTRYPOINT ["/usr/local/bin/node", "/opt/SignallingWebServer/cirrus.js"]
plushpluto commented 4 years ago

Ah! I was playing around with docker run -it. Didn't reach anywhere. Thanks. I shall try and come back. Would love to learn Kubernetes. Have been hearing about it a lot these days.

plushpluto commented 4 years ago

Dockerfile: ENTRYPOINT [ "/bin/bash", "/home/ue4/project/PixelStreamingUE4-Test2.sh -game -AudioMixer -windowed -ResX=640 -ResY=360" ]

Got this. web_1 | sh: 1: xdg-user-dir: not found web_1 | error: XDG_RUNTIME_DIR not set in the environment. web_1 | Signal 11 caught. web_1 | Malloc Size=65538 LargeMemoryPoolOffset=65554 web_1 | Malloc Size=65535 LargeMemoryPoolOffset=131119 web_1 | Malloc Size=52256 LargeMemoryPoolOffset=183392 web_1 | Failed to find symbol file, expected location: web_1 | "/home/ue4/project/PixelStreamingUE42/Binaries/Linux/PixelStreamingUE42-Test2-Linux-Shipping.sym" web_1 | 4.23.1-8386587+++UE4+Release-4.23 517 0 web_1 | Disabling core dumps. web_1 | CommonUnixCrashHandler: Signal=11 web_1 | Engine crash handling finished; re-raising signal 11 for the default handler. Good bye. web_1 | Segmentation fault (core dumped)

Looks like I have screwed up something here. Hate core dumps!!!

plushpluto commented 4 years ago

And oh! btw, SignallingServer as a docker container works fine with docker-compose. Thanks for that. WebRTC is still having issues. I am going to try the janus way, which seems to work with your ue4-docker (4.20) example.

adamrehn commented 4 years ago

It's quite likely that your packaged game crashed because you were running it in a container without GPU acceleration. Unfortunately Docker Compose isn't currently compatible with the latest version of the NVIDIA Container Toolkit, so you'll need to use the older NVIDIA Docker 2.x runtime if you want to use Docker Compose to run the packaged Unreal project.

I've now created a set of example Dockerfiles for use with Pixel Streaming for Linux to help new users get started, and also edited the Dockerfile code in my comment above to match the new example code. I've tested the example Dockerfiles to ensure they work when running containers directly with the docker run command, but I've not tried them with Kubernetes or Docker Compose yet.

plushpluto commented 4 years ago

Awesome! Thanks man. Will try these.

plushpluto commented 4 years ago

npm ERR! network timeout at: https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz

shows up in building https://github.com/adamrehn/ue4-example-dockerfiles/tree/master/pixel-streaming/4.23/server

yarn seems to work for me.

plushpluto commented 4 years ago

Does the container adamrehn/ue4-full:4.24.3 has PixelStreaming plugin in it?

adamrehn commented 4 years ago

The npm install . RUN directive in the Dockerfile for the signalling server works fine for me, I'd suggest checking your network connection and trying again.

No, the container image adamrehn/ue4-full:4.24.3 is the standard ue4-full image for Unreal Engine 4.24.3. Pixel Streaming for Linux does not support 4.24 yet, although my colleagues and I are currently working on a 4.24 version based on updating our existing 4.23 release.

plushpluto commented 4 years ago

Ok. Network issues might be there. I'll check it out.

It would be nice to have Pixel Streaming for ue4-4.24 in Linux. Not sure if it works with Windows though. All my systems are either Linux or Mac based.

adamrehn commented 4 years ago

Windows is the platform that Epic officially supports for Pixel Streaming, so it most definitely works under Windows. It's not possible to containerise it under Windows though, since the experimental GPU acceleration support in Windows containers only supports DirectX and not the video encoding APIs (NVENC, AMF, etc.) that are required for Pixel Streaming.

plushpluto commented 4 years ago

Ok. Network issues might be there. I'll check it out.

It would be nice to have Pixel Streaming for ue4-4.24 in Linux. Not sure if it works with Windows though. All my systems are either Linux or Mac based.

Recently I bought a static IP for which I had to create a NAT to secure my local services. I had to expose a few ports to enable the NPM inside docker services. It works now.

plushpluto commented 4 years ago

"It's quite likely that your packaged game crashed because you were running it in a container without GPU acceleration. Unfortunately Docker Compose isn't currently compatible with the latest version of the NVIDIA Container Toolkit, so you'll need to use the older NVIDIA Docker 2.x runtime if you want to use Docker Compose to run the packaged Unreal project."

Still getting the same error. Screenshot from 2020-04-24 10-32-40

Damn!!! Losing the cool man!!

plushpluto commented 4 years ago

Hey, I tried some other GUI based run inside docker and it works. Should I have to rebuild the 4.23.1 container using nvidia-docker?

This is how I try to run it at the moment.

!/bin/bash

setfacl -m user:1000:r ${HOME}/.Xauthority docker build --tag dummy . exec docker run \ --gpus all \ -it \ -e DISPLAY \ -v ${HOME}/.Xauthority:/home/user/.Xauthority \ dummy:latest \ "$@"

adamrehn commented 4 years ago

@plushpluto that's not actually an error, if the packaged Unreal project failed to initialise rendering then it would terminate immediately. That output followed by the container continuing to run silently is exactly what you see when a Shipping project is running successfully with offscreen rendering. (Only a project built in one of the other build configurations such as Development will have full log output in the packaged version.) Once that's running alongside the proxy and the signalling server you should be able to open up a web browser and navigate to 127.0.0.1 to see the Pixel Streaming page and interact with the application.

plushpluto commented 4 years ago

:relieved: Thanks man. It works now. I am working on deploying it in kubernetes at the moment. Will share how it goes. One last question before I close this. The game opened well in 127.0.0.1. But it was lagging. Is it 'coz of my system specs or docker?

adamrehn commented 4 years ago

The one area where Docker can sometimes introduce overhead is in the networking stack. You can check this by running the containers with host networking mode using the --network=host flag. If the lag improves when running in host networking mode then you'll know that it was the Docker networking stack at fault rather than your hardware specs.

plushpluto commented 4 years ago

In this hard time of people being forced to sit inside, I am trying my best to host a service where a local school teacher can use to teach the kids. But I realize that I need to host it in a cloud. I checked with Google/AWS/Azure. All these seem to incur a lot of cost when it comes to hosting gaming solutions. Also, they all would require a company to be started for me to get those free cloud credits. Can you suggest any other cloud platform that you are aware of?

adamrehn commented 4 years ago

Unfortunately cloud VMs with GPUs attached are relatively expensive across all public cloud providers, so there's no silver bullet. (It's even worse when using the official Windows version of Pixel Streaming, since Windows Server licensing costs make Windows VMs even more expensive.) I'm afraid there isn't really anything I can do to help there.

plushpluto commented 4 years ago

Ah! It's ok. I understand.

But hey @adamrehn. You have been great help to me on this. Thanks man. I am closing this issue here.

jindov commented 4 years ago

As I read follow this article https://adamrehn.com/articles/pixel-streaming-in-linux-containers/ pixel streaming is support linux container already, no?I'm going to deploy pixel streaming with k8s, is there any exp or note can you please share me @plushpluto Thank you