Run Simplygon in a containerized environment
Simplygon can be run in containers, but it's important to be aware of any limitations. Please refer to the limitations section for more information.
To help you get started, please take a look at the Docker example below. This example installs Simplygon, installs Python, creates a Python script, and then runs the script. The script uses the Simplygon API to print the Simplygon version.
Example
# Example build command (Note the license key as build arg )
# docker build --build-arg LICENSE_KEY=<your license key> --rm -f "dockerfile" -t print_simplygon_version:latest "."
#
# Example run command:
# docker run --rm -it print_simplygon_version:latest
#
# This should output:
# Simplygon version:
# 10.1.400
FROM mcr.microsoft.com/windows:ltsc2019
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ARG SG_VERSION=10.1.400.0
ARG LICENSE_KEY
## Download and install Simplygon dependencies
# VC Redist
RUN Invoke-WebRequest https://aka.ms/vs/17/release/vc_redist.x64.exe -OutFile C:\vc_redist.x64.exe; \
Start-Process C:\vc_redist.x64.exe -Wait -ArgumentList '/quiet', '/install', '/norestart'
## Download and extract the Simplygon zip
ADD https://downloads.simplygon.com/SimplygonSDK_$SG_VERSION.zip c:/
RUN Expand-Archive -Path "c:/SimplygonSDK_${env:SG_VERSION}.zip" -DestinationPath c:/
## Install Simplygon license
RUN Start-Process .\SimplygonSDK_${env:SG_VERSION}\SimplygonLicenseApplication.exe -Wait -ArgumentList '-InstallLicense', ${env:LICENSE_KEY}; \
ls "$env:localappdata\Microsoft\SimplygonSDK"
## Setup simplygon
RUN Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser; \
& "./SimplygonSDK_${env:SG_VERSION}/SetupSimplygon.ps1"
# Download and install python
RUN Invoke-WebRequest https://www.python.org/ftp/python/3.10.9/python-3.10.9-amd64.exe -OutFile c:\python-3.10.9.exe ; \
Start-Process c:\python-3.10.9.exe -ArgumentList '/quiet TargetDir=C:\Python3 InstallAllUsers=1 PrependPath=1 Include_doc=0 Include_pip=0 Include_test=0' -Wait ; \
Remove-Item c:\python-3.10.9.exe -Force; \
#the installer updated PATH, so we should refresh our local value
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine);
# Create simple python script that prints the simplygon version
RUN $pyPrintVersion="""\
import gc `n\
from simplygon10 import simplygon_loader `n\
from simplygon10 import Simplygon `n`n\
\
if __name__ == '__main__': `n`t\
sg = simplygon_loader.init_simplygon() `n`t\
if sg is None: `n`t`t\
print('Init Simplygon failed:') `n`t`t\
exit(Simplygon.GetLastInitializationError()) `n`n`t\
\
print('Simplygon version:') `n`t\
sgVersion = sg.GetVersion() `n`t\
print(sgVersion) `n`t\
sg = None `n`t\
gc.collect()"""; \
Add-Content "$PSScriptRoot\PrintSimplygonVersion.py" $pyPrintVersion
CMD py PrintSimplygonVersion.py
To build a Docker image named print_simplygon_version with the tag latest using the example above, run the following command:
docker build --build-arg LICENSE_KEY=<your license key> --rm -f "dockerfile" -t print_simplygon_version:latest "."
In this command, replace <your license key>
with the actual license key you have obtained. This command uses the Dockerfile located in the current directory to build the image. The --rm
option removes intermediate containers after a successful build, and the -t
option assigns a tag to the image.
To run the Docker image and output the Simplygon version, use the following command:
docker run --rm -it print_simplygon_version:latest
This command runs the Docker image tagged as print_simplygon_version:latest in interactive mode and outputs the Simplygon version, which should be:
> Simplygon version:
> 10.1.400
Compatible docker images
- mcr.microsoft.com/windows:ltsc2022
- With DirectX
- mcr.microsoft.com/windows:ltsc2019
- With DirectX
- mcr.microsoft.com/windows/servercore:ltsc2022
- Without DirectX
- mcr.microsoft.com/windows/servercore:ltsc2019
- Without DirectX
Dependencies & Limitations
- Simplygon only works with Windows containers.
- DDS texture loading is disabled when running in a containerized environment without DirectX (see Compatible docker images). Simplygon has a dependency to DirectX for DDS loading.
Compute caster
To run Compute Caster in a Docker container, you need to ensure that the Vulkan Runtime version installed in the container is at least 1.3. This is because Compute Caster requires Vulkan Runtime 1.3 or higher to be present in order to function properly. Without the correct version of Vulkan Runtime, Compute Caster may encounter errors or fail to run altogether. Therefore, it is important to check and confirm that the correct version of Vulkan Runtime is installed in the Docker container before attempting to run Compute Caster.