我有以下 Dockerfile,尝试创建一个封装 CLIP-Fields github 的容器(https://github.com/notmahi/clip-fields):
# Use the official PyTorch base image with CUDA support
FROM pytorch/pytorch:1.8.1-cuda11.1-cudnn8-runtime
# Install system dependencies
RUN apt-get update && apt-get install -y git
RUN pip install --upgrade pip
RUN apt-get install g++ -y
# Clone the CLIP Fields repository
RUN git clone https://github.com/notmahi/clip-fields /clip-fields
WORKDIR /clip-fields
# Clone and install the Detic submodule
RUN git clone https://github.com/notmahi/Detic.git
# Clone and install the LSeg submodule
RUN git clone https://github.com/notmahi/LSeg.git
# Create a conda environment and activate it. py 3.8 used
RUN conda create -n cf python=3.8 && \
echo "conda activate cf" >> ~/.bashrc
SHELL ["/bin/bash", "--login", "-c"]
# Install dependencies
RUN conda install -y pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch-lts -c nvidia
RUN pip install -r requirements.txt
# Set the working directory to the gridencoder folder
WORKDIR /clip-fields/gridencoder
# Install the hashgrid encoder with the relevant CUDA module
# Update the CUDA_HOME path if necessary
# ENV CUDA_HOME=/usr/local/cuda
# RUN apt-get install -y cuda-runtime-11-1
RUN python setup.py install
# Set the working directory back to the root of the CLIP Fields repository
WORKDIR /clip-fields
# Run any necessary commands or scripts here
# Set the command to run when the container starts
CMD ["/bin/bash"]
它在“> [13/14] RUN python setup.py install”上崩溃,并出现以下错误:
0 0.181 mesg: ttyname failed: Inappropriate ioctl for device
#0 0.864 Traceback (most recent call last):
#0 0.864 File "setup.py", line 47, in <module>
#0 0.864 CUDAExtension(
#0 0.864 File "/opt/conda/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 867, in CUDAExtension
#0 0.864 library_dirs += library_paths(cuda=True)
#0 0.864 File "/opt/conda/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 975, in library_paths
#0 0.864 if (not os.path.exists(_join_cuda_home(lib_dir)) and
#0 0.864 File "/opt/conda/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1982, in _join_cuda_home
#0 0.864 raise EnvironmentError('CUDA_HOME environment variable is not set. '
#0 0.864 OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.
------
Dockerfile:35
--------------------
33 | # ENV CUDA_HOME=/usr/local/cuda
34 | # RUN apt-get install -y cuda-runtime-11-1
35 | >>> RUN python setup.py install
36 |
37 | # Set the working directory back to the root of the CLIP Fields repository
--------------------
ERROR: failed to solve: process "/bin/bash --login -c python setup.py install" did not complete successfully: exit code: 1
“FROM pytorch/pytorch:1.8.1-cuda11.1-cudnn8-runtime”是否包含必要的CUDA和pytorch?如何设置 CUDA_HOME?
CUDA_HOME 不能跨层传递。 所以你可能需要在同一行导出 CUDA_HOME 与
python install