我是Docker的新手,尤其是Nvidia-Docker。我正在尝试将代码包装到docker容器中,并在一些主机上运行它。但显然有些地方出了问题,我无法在docker中运行我的代码。我已经安装了Nvidia-docker,Dockerfile取自here。这是我完整的docker代码
FROM nvidia/cuda:9.1-runtime-ubuntu16.04
RUN apt-get update && apt-get install -y \
cuda-command-line-tools-$CUDA_PKG_VERSION \
cuda-libraries-dev-$CUDA_PKG_VERSION \
cuda-minimal-build-$CUDA_PKG_VERSION \
&& \
rm -rf /var/lib/apt/lists/*
ENV LIBRARY_PATH /usr/local/cuda/lib64/stubs
FROM python:3.7-slim
RUN pip install numpy
RUN apt update && \
apt-get -y install gcc && \
apt-get -y install g++
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ADD helmsolver /helmsolver
CMD dpkg -l | grep -i cuda
CMD cd helmsolver && bash tests.sh和bash脚本代码,其中cudahelmf和cudahelmd以前是由
nvcc helm3dcudafnd.cu -o cudahelm -I/usr/local/cuda/samples/common/inc/ -lcufft -lcufftw -D DOUBLE#!/bin/sh
mkdir helmholtz
cd helmholtz
mkdir build
mkdir workdir
mkdir src
mkdir scripts
ls
cp ../cudahelmf ./build
cp ../cudahelmd ./build
cp ../tmp.py ./scripts/
cd workdir
python3 ../scripts/script1.py 21 21 1
../build/cudahelmd config.cfg >> results_double.txt
../build/cudahelmf config.cfg >> results_float.txt为了构建和运行docker,我使用
nvidia-docker build -t helm .
nvidia-docker run --rm -ti helm在运行之后,我有错误
../build/cudahelmd: error while loading shared libraries: libcufft.so.9.1: cannot open shared object file: No such file or directory我做错了什么?这是不是因为-lcufft编译选项和docker不知道从哪里获取它而发生的?并且docker在安装后没有/usr/local/cuda/目录。这看起来很奇怪,因为cuda- library -dev包含cufft库,安装成功结束。
这是我电脑上的nvcc版本,代码是在这里编译和测试的。
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85和nvidia-docker版本
Docker version 19.03.3, build a872fc2f86附言:也许有一个选项可以在docker中编译代码?
发布于 2019-10-17 13:17:05
问题是你正在运行一个没有COPY的多级dockerfile文件从一个容器到另一个容器,因此你最终只能得到独立的python3容器,它没有来自nvidia容器的任何东西,所以你需要在python容器中复制所需的文件,如下所示:
COPY --from=0 SOURCE DESThttps://stackoverflow.com/questions/58415644
复制相似问题