A bug about dockerfile
See original GitHub issueInstructions To Reproduce the š Bug:
- Full runnable code or full changes you made:
docker build -t detectron2:v0 .
- What exact command you run: docker build -t detectron2:v0 .
- Full logs or other relevant observations:
ERROR: Package 'detectron2' requires a different Python: 3.6.9 not in '>=3.7'
- 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:
- Created a year ago
- Comments:5
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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
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
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 throwsImportError: cannot import name 'multiarray' from 'numpy.core'error. detectron2_numpy_import_error_full_log.txtTo 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.txtFinally, here is the full Dockerfile that worked for me: Dockerfile.txt
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 usingRUN wget https://bootstrap.pypa.io/get-pip.py && \), then changed to /cu111/ (had /cu101/) in the lineRUN pip install --user torch==1.10.1 torchvision==0.11.2 -f https://download.pytorch.org/whl/cu111/torch_stable.html