# Docker image

> Learn how to install, license, and run the Pixyz SDK Docker image for CAD and 3D data transformations.

## General Information

Pixyz SDK is *cloud-ready*. [Unity Cloud](https://unity.com/fr/products/unity-cloud) currently uses Pixyz-based Docker images for its automatic CAD and 3D transformation pipelines, including thumbnail generation, GLB web-previews, metadata extraction, file conversions, 3D data streaming, and more.

As a standalone toolkit, Pixyz SDK is available for on-premise (local) or VPC deployments for Unity external customers who cannot leverage Unity Cloud online services.

## Get Started

The Pixyz SDK Docker image is available on [Docker Hub](https://hub.docker.com/r/pixyzinc/sdk).

A floating license server is required to run the Pixyz SDK Docker container.

### Set Up the License Server

The license server must be running on the network and accessible from the container. Ports `27000` to `27010` must be opened.

License server installation guides:

* [Windows](https://support.unity.com/hc/en-us/articles/4417145043092-How-do-I-set-up-a-floating-license-server-FlexNet-on-Windows)
* [Linux](https://support.unity.com/hc/en-us/articles/4416621427476-How-do-I-set-up-a-floating-license-server-FlexNet-on-Linux)

### Get the SDK Docker Container

```bash
docker pull pixyzinc/sdk:2024.2.1.3
```

### Install License

A license file must be mounted (with write permission) to `/usr/share/PixyzSDK/licenses/pixyz.lic` for the container to run.

Create the `pixyz.lic` file with the following content:

```xml
<?xml version="1.0" encoding="utf-8" ?>
<license product="PixyzSDK">
  <version/>
  <validity start="" end=""/>
  <customer>
    <company/>
    <name/>
    <email/>
    <site/>
    <phone/>
  </customer>
  <floatting>True</floatting>
  <server>
    <port>27000</port>
    <host>##YOUR_SERVER_IP_OR_HOSTNAME###</host>
    <flexLM>True</flexLM>
  </server>
  <machine/>
</license>
```

Replace `##YOUR_SERVER_IP_OR_HOSTNAME###` with the IP address or hostname of the license server.

### Configure License Server

Use the following code at the top of your datap reparation script to configure the license server:

```python title="Python"
import pxz
from pxz import core

# init Pixyz
pxz.initialize()

# print Pixyz version
print(core.getVersion())

# set log level to INFO so you can see the logs in the console
core.configureInterfaceLogger(True, True, True)
core.addConsoleVerbose(core.Verbose.INFO)

# if no license is found, try to configure a license server
if not core.checkLicense():
    core.configureLicenseServer("company-server-hostname", 27000, True)

# use io.importScene to import a file and enjoy :)
```

Replace `company-server-hostname` with the IP address or hostname of the license server.

For more detailed information on licensing, please refer to the [licensing documentation](./license/licensingintro).

## GPU Requirement

Some Pixyz algorithms require a GPU to run. [More information](./system#gpu).

The GPU must be allocated to the container if you intend to use these algorithms.

## Run Your Data Preparation Scripts

The Pixyz SDK is located at `/opt/pixyz` in the container. Its entrypoint is designed to automatically initialize Pixyz SDK and run the provided Python script path.

### Locally

```bash
export LIC_FILE=/path/to/your/pixyz.lic
export FILES_DIR=/path/to/your/cad_files
export SCRIPTS_DIR=/path/to/your/dataprep_scripts

docker run \
  -d --rm \
  --name=pixyz_sdk \
  --runtime=nvidia \
  --gpus all \
  -e NVIDIA_VISIBLE_DEVICES=all \
  -e NVIDIA_DRIVER_CAPABILITIES=all \
  -e DISPLAY=$DISPLAY \
  -v /usr/share/vulkan/icd.d/nvidia_icd.json:/usr/share/vulkan/icd.d/nvidia_icd.json \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v $LIC_FILE:/usr/share/PixyzSDK/licenses/pixyz.lic \
  -v $FILES_DIR:/files \
  -v $SCRIPTS_DIR:/scripts \
  pixyzinc/sdk:2024.2.0.52 /scripts/myconvertionscript.py /files/myfiletoconvert.obj
```

To improve the performance of the container, you can use the `--cpus ##NUMBER##` and `--memory ##VALUE##` flags.

### Running in the Cloud

The Docker container is compatible with all cloud providers.

When running with Kubernetes with GPU:

* The NVIDIA drivers must be provided on the node.
* The NVIDIA daemonset must be deployed (e.g., on [Azure](https://learn.microsoft.com/en-us/azure/aks/gpu-cluster?tabs=add-ubuntu-gpu-node-pool#manually-install-the-nvidia-device-plugin)).

### Unity Cloud Transformations and Asset Manager

Subscribe now on [unity.com](https://cloud.unity.com).
