AWS EC2 Deployment
The PhotoEditor SDK for server can be deployed to AWS EC2 instances and make use of GPU instances.
This guide describes how to setup an Amazon AWS EC2 instance to run the PhotoEditor SDK Server. The server supports GPU (WebGL) and CPU (Canvas) based rendering.
CPU Based Setup#
Just use any AWS instance you prefer (the more memory, the better) and specify
canvas as the
preferredRenderer in the
PesdkServer.editors options. This will limit rendering to the CPU and doesn't require a GPU, but will probably yield lower performance compared to WebGL in the future. Once you created your instance, just follow the steps in 'PESDK Server Setup'.
GPU Based Setup to use WebGL Renderer#
Running a headless WebGL server requires some upfront setup work, but will pay off with increased performance in the future. To run the PESDKServer on AWS EC2, follow these steps:
Recommended Instance Type: g2.2xlarge
Choose an Ubuntu 16.04 LTS AMI that's compatible with the g2.2xlarge instance (
Nvidia Driver Installation#
sudo apt-add-repository ppa:ubuntu-x-swat/updates sudo apt-get update sudo apt-get install nvidia-current
Reboot after driver installation#
sudo reboot now
Configure X Server with a virtual display :0#
sudo apt-get install xserver-xorg libglu1-mesa-dev freeglut3-dev mesa-common-dev libxmu-dev libxi-dev sudo nvidia-xconfig -a --use-display-device=None --virtual=1280x1024
$ nvidia-smi should already show the K520 GPU.
Connect the GPU to the virtual display#
BusID "0:3:0" in the Section "Device"` section:
Section "Device" Identifier "Device0" Driver "nvidia" VendorName "NVIDIA Corporation" BoardName "GRID K520" BusID "0:3:0" EndSection
Launch X Server#
sudo /usr/bin/X :0 &
PESDK Server Setup
- Clone repository / install npm package
scp -i "AWS.pem" /path/to/folder ubuntu@<address>:/home/ubuntu/pesdk cd /home/ubuntu/pesdk
- Install NodeJS
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash sudo apt-get install -y nodejs
- Install required dependencies and build PhotoEditorSDK
sudo apt-get install libcairo2-dev libjpeg-dev libpango1.0-dev \ libgif-dev build-essential g++ npm install npm run-script build
- To run the Server you'll need a valid license files. You may upload this using scp and just store it within the instance. The file is then passed to the SDK using the
-l license.jsonparameter or the files contents are .
TypeError: Cannot set property 'id' of null
Export the currently attached virtual display:
node: symbol lookup error: /home/ubuntu/pesdk/node_modules/gl/build/Release/webgl.node: undefined symbol: _Z15XextFindDisplayP15_XExtensionInfoP9_XDisplay
This seems to be caused by a hardcoded display within
webgl.node. To fix it, you'll have to manually rebuild
webgl.node as described in steps 1-6 of the packages repository:
- Switch to home directory:
- Clone the repository:
git clone https://github.com/stackgl/headless-gl.git
- Switch to the headless gl directory:
- Initialize the angle submodule:
git submodule init
- Update the angle submodule:
git submodule update
- Install npm dependencies:
- Run node-gyp to generate build scripts:
npm run rebuild
You've now built a 'working'
webgl.node version for your current setup. Replace the prebuilt one installed in the
gl module with the following command:
cp ~/headless-gl/build/Release/webgl.node ~/pesdk/node_modules/gl/build/Release/webgl.node
For more details on this issue, take a look at the discussion on GitHub.