基于Ubuntu系统的docker镜像中安装dlib

问题背景:
为了将face_recognition项目进行迁移,我们使用docker对其进行镜像打包,使用的DockerFile文件如下:

# Start FROM Nvidia PyTorch image https://ngc.nvidia.com/catalog/containers/nvidia:pytorch
FROM registry.baidubce.com/ais-public/ais2.3:cuda10.1_cudnn7-ubuntu16.04-py37

ENV PATH=/home/bml/anaconda3/envs/py3.7.4/bin:${PATH}

# 安装依赖软件
RUN apt-get update -y && \
apt-get install -y git cmake libsm6 libxext6 libxrender-dev

RUN python -m pip install --upgrade pip && \
pip install scikit-build

# 安装编译
RUN apt-get install -y software-properties-common && \
add-apt-repository ppa:ubuntu-toolchain-r/test && \
apt-get update -y  && \
apt-get install -y gcc-6 g++-6 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 50 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 50

# Create working directory
RUN mkdir -p /home/dlib_face_recognition
WORKDIR /home/dlib_face_recognition

# Copy contents
COPY . /home/dlib_face_recognition/ 

#安装dlib 
# RUN git clone -b 'v19.7' --single-branch https://github.com/davisking/dlib.git && \
RUN pip install --index-url https://mirrors.ustc.edu.cn/pypi/web/simple --requirement requirements.txt && \
mkdir -p /home/dlib_face_recognition/dlib-master/build && \
cmake -H/home/dlib_face_recognition/dlib-master -B/home/dlib_face_recognition/dlib-master/build -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1 && \
cmake --build /home/dlib_face_recognition/dlib-master/build && \
cd /home/dlib_face_recognition/dlib-master  && \
python /home/dlib_face_recognition/dlib-master/setup.py install

CMD ["python","app.py"]

在构建过程中出现以下错误:

ERROR: Command errored out with exit status 1:
   command: /home/bml/anaconda3/envs/py3.7.4/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-p8j36mb6/cryptography_932a41c98c9e47cb83ae52a12653f21b/setup.py'"'"'; __file__='"'"'/tmp/pip-install-p8j36mb6/cryptography_932a41c98c9e47cb83ae52a12653f21b/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-2yv7tziu
       cwd: /tmp/pip-install-p8j36mb6/cryptography_932a41c98c9e47cb83ae52a12653f21b/
  Complete output (116 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.7
  creating build/lib.linux-x86_64-3.7/cryptography
  copying src/cryptography/__about__.py -> build/lib.linux-x86_64-3.7/cryptography
  copying src/cryptography/__init__.py -> build/lib.linux-x86_64-3.7/cryptography
  copying src/cryptography/exceptions.py -> build/lib.linux-x86_64-3.7/cryptography
  copying src/cryptography/fernet.py -> build/lib.linux-x86_64-3.7/cryptography
  copying src/cryptography/utils.py -> build/lib.linux-x86_64-3.7/cryptography
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat
  copying src/cryptography/hazmat/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat
  creating build/lib.linux-x86_64-3.7/cryptography/x509
  copying src/cryptography/x509/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/x509
  copying src/cryptography/x509/base.py -> build/lib.linux-x86_64-3.7/cryptography/x509
  copying src/cryptography/x509/extensions.py -> build/lib.linux-x86_64-3.7/cryptography/x509
  copying src/cryptography/x509/general_name.py -> build/lib.linux-x86_64-3.7/cryptography/x509
  copying src/cryptography/x509/name.py -> build/lib.linux-x86_64-3.7/cryptography/x509
  copying src/cryptography/x509/oid.py -> build/lib.linux-x86_64-3.7/cryptography/x509
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat/backends
  copying src/cryptography/hazmat/backends/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends
  copying src/cryptography/hazmat/backends/interfaces.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends
  copying src/cryptography/hazmat/backends/multibackend.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat/bindings
  copying src/cryptography/hazmat/bindings/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/bindings
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/cmac.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/constant_time.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/hashes.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/hmac.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/keywrap.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/padding.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/serialization.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/commoncrypto
  copying src/cryptography/hazmat/backends/commoncrypto/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/commoncrypto
  copying src/cryptography/hazmat/backends/commoncrypto/backend.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/commoncrypto
  copying src/cryptography/hazmat/backends/commoncrypto/ciphers.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/commoncrypto
  copying src/cryptography/hazmat/backends/commoncrypto/hashes.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/commoncrypto
  copying src/cryptography/hazmat/backends/commoncrypto/hmac.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/commoncrypto
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/backend.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ciphers.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/cmac.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/decode_asn1.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/dh.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/dsa.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ec.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/encode_asn1.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/hashes.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/hmac.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/rsa.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/utils.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/x509.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/backends/openssl
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat/bindings/commoncrypto
  copying src/cryptography/hazmat/bindings/commoncrypto/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/bindings/commoncrypto
  copying src/cryptography/hazmat/bindings/commoncrypto/binding.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/bindings/commoncrypto
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat/bindings/openssl
  copying src/cryptography/hazmat/bindings/openssl/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/bindings/openssl
  copying src/cryptography/hazmat/bindings/openssl/_conditional.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/bindings/openssl
  copying src/cryptography/hazmat/bindings/openssl/binding.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/bindings/openssl
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/dh.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/dsa.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/ec.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/padding.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/rsa.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/utils.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/asymmetric
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/algorithms.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/base.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/modes.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/ciphers
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/interfaces
  copying src/cryptography/hazmat/primitives/interfaces/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/interfaces
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/concatkdf.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/hkdf.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/kbkdf.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/pbkdf2.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/scrypt.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/x963kdf.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/kdf
  creating build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/__init__.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/hotp.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/totp.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/utils.py -> build/lib.linux-x86_64-3.7/cryptography/hazmat/primitives/twofactor
  running egg_info
  writing src/cryptography.egg-info/PKG-INFO
  writing dependency_links to src/cryptography.egg-info/dependency_links.txt
  writing entry points to src/cryptography.egg-info/entry_points.txt
  writing requirements to src/cryptography.egg-info/requires.txt
  writing top-level names to src/cryptography.egg-info/top_level.txt
  reading manifest file 'src/cryptography.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  no previously-included directories found matching 'docs/_build'
  warning: no previously-included files matching '*' found under directory 'vectors'
  writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
  running build_ext
  generating cffi module 'build/temp.linux-x86_64-3.7/_padding.c'
  creating build/temp.linux-x86_64-3.7
  generating cffi module 'build/temp.linux-x86_64-3.7/_constant_time.c'
  generating cffi module 'build/temp.linux-x86_64-3.7/_openssl.c'
  building '_openssl' extension
  creating build/temp.linux-x86_64-3.7/build
  creating build/temp.linux-x86_64-3.7/build/temp.linux-x86_64-3.7
  gcc -pthread -B /home/bml/anaconda3/envs/py3.7.4/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/bml/anaconda3/envs/py3.7.4/include/python3.7m -c build/temp.linux-x86_64-3.7/_openssl.c -o build/temp.linux-x86_64-3.7/build/temp.linux-x86_64-3.7/_openssl.o
  build/temp.linux-x86_64-3.7/_openssl.c:570:30: fatal error: openssl/opensslv.h: No such file or directory
   #include <openssl/opensslv.h>
                                ^
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for cryptography

从报错信息中可以看出,主要错误如下:

build/temp.linux-x86_64-3.7/_openssl.c:570:30: fatal error: openssl/opensslv.h: No such file or directory
   #include <openssl/opensslv.h>
                                ^
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for cryptography

可能缺少openssl,在ubuntu系统中,安装libssl-dev

# Start FROM Nvidia PyTorch image https://ngc.nvidia.com/catalog/containers/nvidia:pytorch
FROM registry.baidubce.com/ais-public/ais2.3:cuda10.1_cudnn7-ubuntu16.04-py37

ENV PATH=/home/bml/anaconda3/envs/py3.7.4/bin:${PATH}

# 安装依赖软件
RUN apt-get update -y && \
apt-get install -y git cmake libsm6 libxext6 libxrender-dev libssl-dev

RUN python -m pip install --upgrade pip && \
pip install scikit-build

# 安装编译
RUN apt-get install -y software-properties-common && \
add-apt-repository ppa:ubuntu-toolchain-r/test && \
apt-get update -y  && \
apt-get install -y gcc-6 g++-6 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 50 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 50

# Create working directory
RUN mkdir -p /home/dlib_face_recognition
WORKDIR /home/dlib_face_recognition

# Copy contents
COPY . /home/dlib_face_recognition/ 

#安装dlib 
# RUN git clone -b 'v19.7' --single-branch https://github.com/davisking/dlib.git && \
RUN pip install --index-url https://mirrors.ustc.edu.cn/pypi/web/simple --requirement requirements.txt && \
mkdir -p /home/dlib_face_recognition/dlib-master/build && \
cmake -H/home/dlib_face_recognition/dlib-master -B/home/dlib_face_recognition/dlib-master/build -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1 && \
cmake --build /home/dlib_face_recognition/dlib-master/build && \
cd /home/dlib_face_recognition/dlib-master  && \
python /home/dlib_face_recognition/dlib-master/setup.py install


CMD ["python","app.py"]

最终构建成功

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Ubuntu系统上使用Docker Compose安装Rancher,首先你需要确保你的系统已经安装了以下基本软件: 1. Docker:作为容器引擎的基础,你需要安装并启动Docker。你可以从Docker官网下载适用于Ubuntu安装包进行安装,命令如下: ``` sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io ``` 2. Docker Compose:Docker Compose是一个编排工具,用于定义和运行多容器应用程序。你可以通过添加apt-repository来安装它: ``` curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose ``` 接下来,安装Rancher: 3. 获取Rancher安装包:访问Rancher的官方网站(https://rancher.com/downloads/)下载适合Ubuntu的二进制包或使用RKE(Rancher Kubernetes Engine)。 4. 安装Rancher服务器:通常会涉及到下载Rancher服务器的tarball文件,解压并配置,然后运行启动脚本。例如,如果你选择下载tarball,执行如下步骤: ``` tar -zxvf rancher-server.tar.gz cd rancher-server sudo ./bin/rancher server --ip <your_server_ip> --url <your_rancher_url> ``` 需要替换 `<your_server_ip>` 和 `<your_rancher_url>` 为你的实际服务器IP地址和访问URL。 5. 配置和服务:Rancher通常还需要配置环境变量、证书以及网络设置,具体请参照官方文档:https://rancher.com/docs/rancher/v2.x/en/installation/requirements/

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

great-wind

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值