open-mmlab / mmsegmentation

OpenMMLab Semantic Segmentation Toolbox and Benchmark.
https://mmsegmentation.readthedocs.io/en/main/
Apache License 2.0
7.68k stars 2.53k forks source link

Can't install mmSegmentation correctly #3690

Open RG-Development opened 4 weeks ago

RG-Development commented 4 weeks ago

Describe the problem I've tried installing mmSegmentation for 1-2 weeks, but I can't get it to run. First I tried installing it according to the getting started page, but I encountered several problems (e.g. when I just said to install mmcv, it installed version 2.2.0 and when starting mmsegmentation afterwards, it said that a version >=2.0.0 is needed). After trying installing it on 4 different computers, I decided to write a script to install all necessary components to avoid forgetting a certain component). But the end result on every pc were some import errors.

As a side note, I'm trying to install it on a WSL Ubuntu 22.4

Reproduction

  1. What command or script did you run?
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb

echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] http://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64 /" | sudo tee /etc/apt/sources.list.d/cuda.list

sudo apt update
sudo apt install -y cuda
sudo apt-get -y install cudnn-cuda-11

sudo apt install -y nvidia-cuda-toolkit

sudo apt update
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh

~/miniconda3/bin/conda init bash

After this part, I restart the WSL Ubuntu to commit the conda changes. The CUDA Version is 11.5. Afterwards, I execute the following script:

conda create -n openmmlab python=3.8 -y
conda activate openmmlab

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch -y

git clone https://github.com/open-mmlab/mmsegmentation.git
cd mmsegmentation
pip install -r requirements.txt

pip install -U openmim
mim install mmengine
pip install mmcv==2.1.0 -f https://download.openmmlab.com/mmcv/dist/cu115/torch1.11/index.html

pip install -e .

python -c "import mmcv; import mmseg"

Up to this point, I get no errors. But after I download the test from the getting started page and try to run it, I get the error listed at the end. (the commands to do this:

mim download mmsegmentation --config pspnet_r50-d8_4xb2-40k_cityscapes-512x1024 --dest .
python demo/image_demo.py demo/demo.png configs/pspnet/pspnet_r50-d8_4xb2-40k_cityscapes-512x1024.py pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth --device cuda:0 --out-file result.jpg

)

  1. Did you make any modifications on the code or config? Did you understand what you have modified? other than bundling the installation in a script, I didn't change anything.

  2. What dataset did you use? The one from the get started page in the part of "verify the installation".

Environment

  1. Please run python mmseg/utils/collect_env.py to collect necessary environment information and paste it here.
    
    sys.platform: linux
    Python: 3.8.19 (default, Mar 20 2024, 19:58:24) [GCC 11.2.0]
    CUDA available: False
    MUSA available: False
    numpy_random_seed: 2147483648
    GCC: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
    PyTorch: 2.3.0
    PyTorch compiling details: PyTorch built with:
    - GCC 9.3
    - C++ Version: 201703
    - Intel(R) oneAPI Math Kernel Library Version 2023.1-Product Build 20230303 for Intel(R) 64 architecture applications
    - Intel(R) MKL-DNN v3.3.6 (Git Hash 86e6af5974177e513fd3fee58425e1063e7f1361)
    - OpenMP 201511 (a.k.a. OpenMP 4.5)
    - LAPACK is enabled (usually provided by MKL)
    - NNPACK is enabled
    - CPU capability usage: AVX2
    - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=11 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wsuggest-override -Wno-psabi -Wno-error=pedantic -Wno-error=old-style-cast -Wno-missing-braces -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=2.3.0, USE_CUDA=0, USE_CUDNN=OFF, USE_CUSPARSELT=OFF, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_GLOO=ON, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, USE_ROCM_KERNEL_ASSERT=OFF,

TorchVision: 0.18.0 OpenCV: 4.9.0 MMEngine: 0.10.4 MMSegmentation: 1.2.2+b040e14


side note: I see that it says that CUDA isn't available, but I'm not sure what I have to do different.

2. You may add addition that may be helpful for locating the problem, such as
   - How you installed PyTorch \[e.g., pip, conda, source\]
   - Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)
```none
echo "$PATH"
/home/tim/miniconda3/envs/openmmlab/bin:/home/tim/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/libnvvp:/mnt/c/Program Files/Oculus/Support/oculus-runtime:/mnt/c/windows/system32:/mnt/c/windows:/mnt/c/windows/System32/Wbem:/mnt/c/windows/System32/WindowsPowerShell/v1.0:/mnt/c/windows/System32/OpenSSH:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files/dotnet:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/mnt/c/Program Files/nodejs:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/mnt/c/Program Files (x86)/Eclipse/Sumo/bin:/mnt/c/Program Files (x86)/Eclipse/Sumo/tools:/mnt/c/Program Files/Git/cmd:/mnt/c/Softwareprojekt/Sumo/bin:/mnt/c/Softwareprojekt/Sumo/tools:/mnt/c/Program Files/MATLAB/R2023a/bin:/mnt/c/Program Files/NVIDIA Corporation/Nsight Compute 2023.1.0:/mnt/c/Users/mi/AppData/Local/Programs/Python/Python310/Scripts:/mnt/c/Users/mi/AppData/Local/Programs/Python/Python310:/mnt/c/Users/mi/AppData/Local/Microsoft/WindowsApps:/mnt/c/ProgramData/mi/GitHubDesktop/bin:/mnt/c/Users/mi/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/mi/AppData/Roaming/npm:/mnt/c/Users/mi/AppData/Local/JetBrains/Toolbox/scripts:/mnt/c/Users/mi/AppData/Local/gitkraken/bin:/mnt/c/Users/mi/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/mi/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0/LocalCache/local-packages/Python310/Scripts:/snap/bin
echo "$LD_LIBRARY_PATH"
echo "$PYTHONPATH"

sidenote: in a previous installation I manually added the path in $LD_LIBRARY_PATH, but the error consisted. Error traceback

If applicable, paste the error trackback here.

python demo/image_demo.py demo/demo.png configs/pspnet/pspnet_r50-d8_4xb2-40k_cityscapes-512x1024.py pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth --device cuda:0 --out-file result.jpg
Traceback (most recent call last):
  File "demo/image_demo.py", line 6, in <module>
    from mmseg.apis import inference_model, init_model, show_result_pyplot
  File "/home/tim/mmsegmentation/mmseg/apis/__init__.py", line 2, in <module>
    from .inference import inference_model, init_model, show_result_pyplot
  File "/home/tim/mmsegmentation/mmseg/apis/inference.py", line 14, in <module>
    from mmseg.models import BaseSegmentor
  File "/home/tim/mmsegmentation/mmseg/models/__init__.py", line 3, in <module>
    from .backbones import *  # noqa: F401,F403
  File "/home/tim/mmsegmentation/mmseg/models/backbones/__init__.py", line 2, in <module>
    from .beit import BEiT
  File "/home/tim/mmsegmentation/mmseg/models/backbones/beit.py", line 19, in <module>
    from ..utils import PatchEmbed
  File "/home/tim/mmsegmentation/mmseg/models/utils/__init__.py", line 2, in <module>
    from .basic_block import BasicBlock, Bottleneck
  File "/home/tim/mmsegmentation/mmseg/models/utils/basic_block.py", line 10, in <module>
    from mmseg.utils import OptConfigType
  File "/home/tim/mmsegmentation/mmseg/utils/__init__.py", line 24, in <module>
    from .mask_classification import MatchMasks, seg_data_to_instance_data
  File "/home/tim/mmsegmentation/mmseg/utils/mask_classification.py", line 5, in <module>
    from mmcv.ops import point_sample
  File "/home/tim/miniconda3/envs/openmmlab/lib/python3.8/site-packages/mmcv/ops/__init__.py", line 3, in <module>
    from .active_rotated_filter import active_rotated_filter
  File "/home/tim/miniconda3/envs/openmmlab/lib/python3.8/site-packages/mmcv/ops/active_rotated_filter.py", line 10, in <module>
    ext_module = ext_loader.load_ext(
  File "/home/tim/miniconda3/envs/openmmlab/lib/python3.8/site-packages/mmcv/utils/ext_loader.py", line 13, in load_ext
    ext = importlib.import_module('mmcv.' + name)
  File "/home/tim/miniconda3/envs/openmmlab/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libc10_cuda.so: cannot open shared object file: No such file or directory