SHI-Labs / OneFormer

OneFormer: One Transformer to Rule Universal Image Segmentation, arxiv 2022 / CVPR 2023
https://praeclarumjj3.github.io/oneformer
MIT License
1.41k stars 128 forks source link

Install.md missing requirements #46

Closed Vilhelmas1 closed 1 year ago

Vilhelmas1 commented 1 year ago

Setting up the environment for the first time can be a bit tricky since this projects depends on specific CUDA and GCC version. Maybe add them in the Install.md file. Wrote the version that worked for me.

We use an evironment with the following specifications, packages and dependencies:

praeclarumjj3 commented 1 year ago

Hi @Vilhelmas1, thanks for your interest in our work.

Thanks for the suggestion. May I ask what sort of issues did you face with other CUDA and GCC versions?

Vilhelmas1 commented 1 year ago

Hey,

Regarding CUDA. Had initially 11.0 and 11.2 versions installed. Tried to first install pytorch and torchvision with them, but obviously failed.

For GCC, the default version on my ubuntu system was set to 7.5. With it it failed to build detectron2 properly. Upgrading the GCC version fixed this issue. Though this might not be an issue for other as long as the version is not too high.

In the end found that the best combination is the one I mentioned in the initial comment. While this is fairly easy to fix, having the version in installation readme.md can help save some time. And unfortunately don't have logs to share.

praeclarumjj3 commented 1 year ago

Thanks! I will incorporate these suggestions in a future commit.

nikolaydyankov commented 1 year ago

So far I've spent a full day trying to setup the environment, a Dockerfile would be incredibly helpful. I think detectron isn't being built correctly, I'm getting the following error:

ImportError: libtorch_cuda_cu.so: cannot open shared object file: No such file or directory

This is my Dockerfile so far:

# Use the official Ubuntu 20.04.3 LTS base image
FROM ubuntu:20.04

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8

# Update package list and install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    wget \
    ca-certificates \
    git \
    build-essential \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender1 \
    libyaml-cpp-dev \
    libopencv-dev \
    && rm -rf /var/lib/apt/lists/*

# Install Python 3.8.13
RUN wget https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz \
    && tar xzf Python-3.8.13.tgz \
    && cd Python-3.8.13 \
    && ./configure --enable-optimizations \
    && make -j$(nproc) \
    && make altinstall \
    && cd .. \
    && rm -rf Python-3.8.13.tgz Python-3.8.13 \
    && ln -s /usr/local/bin/python3.8 /usr/local/bin/python

# Install GCC, G++ 9
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc-9 \
    g++-9 \
    && rm -rf /var/lib/apt/lists/* \
    && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 \
    && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100

# Install conda 4.12.0
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py38_4.12.0-Linux-x86_64.sh -O miniconda.sh \
    && chmod +x miniconda.sh \
    && ./miniconda.sh -b -p /opt/conda \
    && rm miniconda.sh \
    && /opt/conda/bin/conda clean -tipsy \
    && ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh \
    && echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc \
    && echo "conda activate base" >> ~/.bashrc

# Set some environment variables
ENV PATH /opt/conda/bin:$PATH
ENV WANDB_API_KEY=...
ENV CUDA_HOME=/usr/local/cuda
ENV FORCE_CUDA=1

# Clone OneFormer repository and set working directory
RUN git clone https://github.com/SHI-Labs/OneFormer.git /OneFormer
WORKDIR /OneFormer

# Install dependencies
RUN conda install pytorch==1.10.1 torchvision==0.11.2 cudatoolkit=11.3 -c pytorch -c conda-forge
RUN pip3 install -U opencv-python
RUN python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu113/torch1.10/index.html
RUN pip3 install git+https://github.com/cocodataset/panopticapi.git
RUN pip3 install git+https://github.com/mcordts/cityscapesScripts.git
RUN pip3 install -r requirements.txt
RUN pip3 install wandb
RUN wandb login

RUN cd oneformer/modeling/pixel_decoder/ops \
    && sh make.sh \
    && cd ../../../..

# Run the command line by default
CMD ["/bin/bash"]
nikolaydyankov commented 1 year ago

Maybe I should open a new issue with the Dockerfile suggestion?