Skip to content

OSError: CUDA_HOME environment variable not set when python setup.py in Dockerfile #95

@stevezkw1998

Description

@stevezkw1998

My Dockerfile

FROM pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime

RUN apt-get update && apt-get install -y git gcc build-essential

RUN mkdir /app
WORKDIR /app

# Install Pytorch Correlation
RUN git clone https://github.com/ClementPinard/Pytorch-Correlation-extension.git
RUN cd Pytorch-Correlation-extension && python setup.py install
RUN cd -

EXPOSE 5252

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

Then raise an Error:
OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.
The full error logs:

 => ERROR [13/14] RUN cd Pytorch-Correlation-extension && python setup.py install                                                                      2.2s
------
 > [13/14] RUN cd Pytorch-Correlation-extension && python setup.py install:
#0 1.843 Traceback (most recent call last):
#0 1.843   File "/app/Pytorch-Correlation-extension/setup.py", line 57, in <module>
#0 1.843     launch_setup()
#0 1.844   File "/app/Pytorch-Correlation-extension/setup.py", line 36, in launch_setup
#0 1.844     Extension('spatial_correlation_sampler_backend',
#0 1.844   File "/opt/conda/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1048, in CUDAExtension
#0 1.844     library_dirs += library_paths(cuda=True)
#0 1.844   File "/opt/conda/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1179, in library_paths
#0 1.845     if (not os.path.exists(_join_cuda_home(lib_dir)) and
#0 1.845   File "/opt/conda/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 2223, in _join_cuda_home
#0 1.845     raise EnvironmentError('CUDA_HOME environment variable is not set. '
#0 1.845 OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.
------
Dockerfile:33
--------------------
  31 |     # Install Pytorch Correlation
  32 |     RUN git clone https://github.com/ClementPinard/Pytorch-Correlation-extension.git
  33 | >>> RUN cd Pytorch-Correlation-extension && python setup.py install
  34 |     RUN cd -
  35 |
--------------------
ERROR: failed to solve: process "/bin/sh -c cd Pytorch-Correlation-extension && python setup.py install" did not complete successfully: exit code: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions