【问题标题】:How to install both MATLAB MCR and the dotnet runtime in a Docker container?如何在 Docker 容器中同时安装 MATLAB MCR 和 dotnet 运行时?
【发布时间】:2020-12-14 14:53:13
【问题描述】:

我正在尝试创建一个 Docker 容器,我可以在其中使用 dotnet 运行加载 MATLAB 运行时 (MCR) DLL 以处理一些数据的 C# 程序。 (.net 核心 3.1,MATLAB 2014b)

我已经根据我在网上找到的example 安装了 MATLAB 的 MCR 运行时为 Ubuntu 的官方 dotnet 映像创建了一个映像。这是我的Dockerfile

FROM mcr.microsoft.com/dotnet/core/runtime:3.1-focal 
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get -qq update && apt-get -qq install -y \
    unzip \
    xorg \
    wget \
    curl && \   
    mkdir /mcr-install && \
    mkdir /opt/mcr && \
    cd /mcr-install && \
    wget http://ssd.mathworks.com/supportfiles/downloads/R2014b/deployment_files/R2014b/installers/glnxa64/MCR_R2014b_glnxa64_installer.zip && \
    unzip -q MCR_R2014b_glnxa64_installer.zip && \
    ./install -destinationFolder /opt/mcr -agreeToLicense yes -mode silent && \
    cd / && \
    rm -rf mcr-install

ENV LD_LIBRARY_PATH /opt/mcr/v84/runtime/glnxa64:/opt/mcr/v84/bin/glnxa64:/opt/mcr/v84/sys/os/glnxa64:/opt/mcr/v84/extern/bin/glnxa64

当我以交互方式运行容器并尝试在其中运行 dotnet 时,我收到此错误:

❯ docker run -it dotnet-mcr:0.2 /bin/bash
root@1e15419d3fee:/# dotnet --info
Failed to load ���, error: /opt/mcr/v84/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by /usr/share/dotnet/host/fxr/3.1.10/libhostfxr.so)
The library libhostfxr.so was found, but loading it from /usr/share/dotnet/host/fxr/3.1.10/libhostfxr.so failed
  - Installing .NET Core prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=2063370

似乎我的Dockerfile 中的最后一行——设置LD_LIBRARY_PATH 的那一行——对于MCR 运行时至关重要,但会破坏dotnet 可执行文件。

我该如何解决这个问题?

注意:正如@jdweng 在下面评论的那样,升级到更新版本的 MATLAB 可能会通过调整冲突 DLL 的版本来解决问题。如果可能的话,我希望提供不涉及升级的解决方案。

【问题讨论】:

  • 你编译dll的matlab版本必须和安装的matlab运行时版本一致。 docker 安装必须是安装和不同的运行时版本。

标签: c# matlab docker .net-core matlab-compiler


【解决方案1】:

正如@jdweng 在对我的问题的评论中所写 - 解决方案是使用依赖于相同版本的 C++ 共享对象的 .Net 和 MATLAB 版本。

就我而言,这意味着 .Net Core 3.1 和 MATLAB 2020b (v99)。下面是适用于我的 Dockerfile(同样基于 Michael Perry 的 example)。

FROM mcr.microsoft.com/dotnet/core/runtime:3.1-focal 
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get -qq update && apt-get -qq install -y \
    unzip \
    xorg \
    wget \
    curl && \   
    mkdir /mcr-install && \
    mkdir /opt/mcr && \
    cd /mcr-install && \
    wget https://ssd.mathworks.com/supportfiles/downloads/R2020b/Release/3/deployment_files/installer/complete/glnxa64/MATLAB_Runtime_R2020b_Update_3_glnxa64.zip && \
    unzip -q MATLAB_Runtime_R2020b_Update_3_glnxa64.zip && \
    ./install -destinationFolder /opt/mcr -agreeToLicense yes -mode silent && \
    cd / && \
    rm -rf mcr-install

ENV LD_LIBRARY_PATH /opt/mcr/v99/runtime/glnxa64:/opt/mcr/v99/bin/glnxa64:/opt/mcr/v99/sys/os/glnxa64:/opt/mcr/v99/extern/bin/glnxa64

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-25
    • 1970-01-01
    • 2018-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多