question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

A bug about dockerfile

See original GitHub issue

Instructions To Reproduce the šŸ› Bug:

  1. Full runnable code or full changes you made:
docker build -t detectron2:v0 .
  1. What exact command you run: docker build -t detectron2:v0 .
  2. Full logs or other relevant observations:
ERROR: Package 'detectron2' requires a different Python: 3.6.9 not in '>=3.7'
  1. please simplify the steps as much as possible so they do not require additional resources to run, such as a private dataset.

Expected behavior:

it will build successful

Environment:

Provide your environment information using the following command:

Failed to load OpenCL runtime
No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
---------------------  --------------------------------------------------------------------------
sys.platform           linux
Python                 3.6.9 (default, Mar 15 2022, 13:55:28) [GCC 8.4.0]
numpy                  1.13.3
detectron2             0.6 @/home/appuser/detectron2_repo/detectron2
detectron2._C          not built correctly: No module named 'detectron2._C'
Compiler ($CXX)        c++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
DETECTRON2_ENV_MODULE  <not set>
PyTorch                1.10.0+cu111 @/home/appuser/.local/lib/python3.6/site-packages/torch
PyTorch debug build    False
GPU available          No: torch.cuda.is_available() == False
Pillow                 8.4.0
torchvision            0.11.1+cu111 @/home/appuser/.local/lib/python3.6/site-packages/torchvision
fvcore                 0.1.5
iopath                 0.1.10
cv2                    3.2.0
---------------------  --------------------------------------------------------------------------
PyTorch built with:
  - GCC 7.3
  - C++ Version: 201402
  - Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191122 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.2.3 (Git Hash 7336ca9f055cf1bfa13efb658fe15dc9b41f0740)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX512
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.1, CUDNN_VERSION=8.0.5, CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/c++, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.10.0, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON,

If your issue looks like an installation issue / environment issue, please first try to solve it yourself with the instructions in https://detectron2.readthedocs.io/tutorials/install.html#common-installation-issues

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

18reactions
farukcankayacommented, Jul 16, 2022

As @peiyingxin said, root cause is python version inconsistency. Iā€™ve tried two approaches to fix the problem:

  • Upgrade ubuntu version from 18.04 to 20.4

    FROM nvidia/cuda:11.1.1-cudnn8-devel-ubuntu20.04 # 18.04 to 20.04
    ...
    RUN wget https://bootstrap.pypa.io/get-pip.py && \ # do not specify pip version
    ...
    

    It worked for building and running the image. issue#3524 says upgrading ubuntu causes opencv incompatibility problem but it might be outdated anymore.

  • Upgrade python version on ubuntu 18.04 to Python3.7

     ...
     ENV DEBIAN_FRONTEND noninteractive
     RUN apt-get update && apt-get install -y \
          python3.7 python3.7-dev python3.7-distutils \
          python3-opencv ca-certificates git wget sudo ninja-build
    
      # Make python3 available for python3.7
      RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
      RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2
      RUN update-alternatives --config python3
      # Make python available for python3.7
      RUN ln -sv /usr/bin/python3.7 /usr/bin/python
    
      # create a non-root user
      ...
      RUN wget https://bootstrap.pypa.io/pip/get-pip.py && \
          python3.7 get-pip.py --user && \
          rm get-pip.py
    
      # Important! Otherwise, it uses existing numpy from host-modules which throws error
      RUN pip install --user numpy==1.20.3
      ...
    

    This was a bit tricky. Even if the python version is upgraded to 3.7, detectron repo installation fetches the existing numpy==1.13.1 from host modules(/usr/lib/python3/dist-packages/) then it throws ImportError: cannot import name 'multiarray' from 'numpy.core' error. detectron2_numpy_import_error_full_log.txt

    To fix it, I simply added RUN pip install --user numpy==1.20.3. This installs numpy to local modules(./.local/lib/python3.7/site-packages) thus pip can fetch the correct numpy while installing detectron2 repo. detectron2_py37_successful_build_full_log.txt

    Finally, here is the full Dockerfile that worked for me: Dockerfile.txt

3reactions
Kodemannencommented, Sep 6, 2022

The first of @farukcankayaā€™s bullets worked for me, but I had to also change PyTorch to be installed with the same version of Cuda as used in the Docker container.

I similarly changed the first line to FROM nvidia/cuda:11.1.1-cudnn8-devel-ubuntu20.04 , (installed the latest pip using RUN wget https://bootstrap.pypa.io/get-pip.py && \), then changed to /cu111/ (had /cu101/) in the line RUN pip install --user torch==1.10.1 torchvision==0.11.2 -f https://download.pytorch.org/whl/cu111/torch_stable.html

Read more comments on GitHub >

github_iconTop Results From Across the Web

docker build uses wrong Dockerfile content (bug?)
Looks like the Dockerfile content itself is being cached or something, and it is reusing a previous Dockerfile. Environment: Docker Desktop forĀ ...
Read more >
Docker security non-events
This page lists security vulnerabilities which Docker mitigated, such that processes run in Docker containers were never vulnerable to the bugā€”even beforeĀ ...
Read more >
Bug #1515065 ā€œDockerfile is in .dockerignore OMGā€
.dockerignore contain files which should not be copied by COPY command, so this files should not be in produced image. Dockerfile should not...
Read more >
Possible bug report - default build dockerfile doesn't exist - Fly.io
I am attempting to launch a phoenix+postgres app on Fly.io for the first time, and hit a speedbump. It seems the default build...
Read more >
Bug: Dockerfile contai... (#43484) - OpenProject Community
Bug. Dockerfile contains deprectaed environment variables ... Start an openproject docker container with for example docker run --rm -itĀ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found