This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Docker容器配置

本文介绍Docker容器配置过程。Docker使您能够在容器内隔离的不同环境中开发或运行基于UNIGINE的应用程序。您的计算机需要有一个NVIDIA图形卡和Linux系统与Ubuntu复制所有必要的步骤。

要在Amazon、Open Suse、Debian、Centos或RHEL等其他发行版中工作,请参阅NVIDIA Container Toolkit文档

系统要求#

您需要关闭所有播放声音的程序。应在系统中安装ALSA驱动程序才能正确播放声音。

注意

Docker守护程序绑定到Unix套接字,而不是TCP端口。默认情况下,拥有Unix套接字的是root用户,其他用户只能使用sudo访问它(阅读更多)。Docker守护程序始终以root用户身份运行。

如果您不想在docker命令的前面加上sudo,请创建一个名为docker的Unix组并向其添加用户(阅读更多)。当Docker守护程序启动时,它会创建一个可由docker组的成员访问的Unix套接字。

Docker配置#

要配置Docker,请执行以下步骤:

  1. 安装NVIDIA容器工具包
  2. 获取Docker容器镜像或者自己组装
  3. 在测试模式下运行Docker容器

NVIDIA容器工具包安装#

  1. 根据其配置文档,配置NVIDIA Container Toolkit。安装包存储库和GPG键,键入命令行:

    输出
    $ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
    && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
    && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
        sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
        sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
  2. 安装nvidia-docker2:

    输出
    $ sudo apt-get update
    $ sudo apt-get install -y nvidia-docker2

  3. 重启Docker:

    输出
    $ sudo systemctl daemon-reload
    $ sudo systemctl restart docker

准备容器映像#

Docker Hub上有一个我们为您准备的即用型容器映像:查看以下链接run-unigine-in-docker并使用以下命令:

输出
docker pull unigine/run-unigine-in-docker

如果出于任何原因,您想要手动准备和组装容器映像,而不是使用Docker Hub的容器映像,请按照以下说明进行操作:

  1. 创建要使用容器的文件夹:

    输出
    $ mkdir ~/unigine-in-docker
  2. unigine-in-docker/文件夹内创建一个Dockerfile文本文件:

    输出
    $ cd ~/unigine-in-docker
    $ touch Dockerfile
  3. 将以下行添加到Dockerfile文件并保存:

    输出
    FROM nvidia/opengl:base-ubuntu20.04
    VOLUME /tmp/.X11-unix
    RUN apt update && apt upgrade -y
    
    # linux-headers- hardcoded, if it don't build - try update version of linux-headers
    RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt install -y \
    	python3 \
    	wget gnupg \
    	xvfb \
    	x11-xserver-utils \
    	python3-pip \
    	libegl1-mesa \
    	libgl1-mesa-dev \
    	libxv1 \
    	gcc g++ make ccache \
    	libxrandr-dev \
    	libxinerama-dev \
    	libopenal1 \
    	libxrender-dev \
    	libxext-dev \
    	libc6-dev \
    	libx11-dev \
    	libxi-dev \
    	libxml2-dev \
    	cmake \
    	nano vim \
    	lshw \
    	libglu1-mesa \
    	mesa-utils \
    	glmark2 \
    	xxd \
    	# for sdk bro2 \
    	libxcb-shape0 \
    	libxcb-xkb1 \
    	libxcb-icccm4 \
    	libxcb-image0 \
    	libxcb-keysyms1 \
    	libxcb-render-util0 \
    	libxkbcommon-x11-0 \
    	linux-headers-5.4.0-135-generic \
    	lxterminal \
    	# sound \
    	alsa-base \
    	alsa-utils \
    	libsndfile1-dev
    
    COPY ./asound.conf /etc/
    
    RUN python3 -m pip install pyinotify
    
    ENV XDG_RUNTIME_DIR=/tmp/.X11-unix
    
    # install dotnet and runtime
    # if it don't build - try to find more recent versions of dotnet at https://dotnet.microsoft.com/en-us/download/dotnet/6.0
    
    RUN wget -O dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/01292c7c-a1ec-4957-90fc-3f6a2a1e5edc/025e84c4d9bd4aeb003d4f07b42e9159/dotnet-sdk-6.0.418-linux-x64.tar.gz
    RUN wget -O dotnet-runtime.tar.gz https://download.visualstudio.microsoft.com/download/pr/b63daa46-51f4-480e-ad03-ef2c5a6a2885/ae059763456991305109bf98b3a67640/aspnetcore-runtime-6.0.26-linux-x64.tar.gz
    RUN mkdir /usr/local/etc/dotnet-sdk-6.0
    RUN tar -xzf dotnet.tar.gz -C /usr/local/etc/dotnet-sdk-6.0
    RUN tar -xzf dotnet-runtime.tar.gz -C /usr/local/etc/dotnet-sdk-6.0
    RUN rm -rf /usr/bin/dotnet
    RUN ln -s /usr/local/etc/dotnet-sdk-6.0/dotnet /usr/bin/dotnet
    
    # path to libraries
    ENV LD_LIBRARY_PATH="/opt/project/bin"
  4. 创建一个新的asound.conf文件:

    输出
    $ sudo vi asound.conf
  5. 将以下脚本写入asound.conf文件:

    输出
    pcm.!default {
            type plug
            slave {
                    pcm "hw:0,0"
            }
    }
    
    ctl.!default {
            type hw
            card 0
    }
    
    pcm.mixed-analog {
        type plug
            slave.pcm "dmix-analog"
            hint {
                show on
                    description "Mixed Analog Output - Use analog outputs, converting samples, format, and rate as necessary. Allows mixing with system sounds."
            }
    }
    
    # Control device (mixer, etc.) for the card
    ctl.mixed-analog {
        type hw
            card 0
    }
  6. 组装Docker映像(在unigine-in-docker文件夹内):

    输出
    $ docker build --rm --tag run_unigine_in_docker:latest -f Dockerfile .

Docker测试运行#

  1. 在试用模式下启动容器以查看GPU特性:

    输出
    $ cd ~/unigine-in-docker/
    $ docker run -it --rm --network host \
    --runtime=nvidia --gpus 0 -e NVIDIA_VISIBLE_DEVICES=0 \
    -e DISPLAY=${DISPLAY} \
    -e NVIDIA_DRIVER_CAPABILITIES=display,compute \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
     run_unigine_in_docker:latest \
     /bin/bash
    # nvidia-smi

  2. 使用以下命令检查选定的GPU驱动程序:glxinfo | grep "OpenGL"。您将看到有关GPU的完整信息。或者使用命令glxinfo | grep "OpenGL renderer"显示所用GPU的型号名称。响应的一个例子:

使用Docker容器#

最新更新: 2024-08-16
Build: ()