MoyGcc / vid2avatar

Vid2Avatar: 3D Avatar Reconstruction from Videos in the Wild via Self-supervised Scene Decomposition (CVPR2023)
https://moygcc.github.io/vid2avatar/
Other
1.2k stars 102 forks source link

Is PyTorch3D compatible with the other libraries versions? #49

Closed leobcc closed 9 months ago

leobcc commented 9 months ago

I have been setting up a docker image to run the code inside a container, everything is being set up properly (except Kaolin, I have not tested it yet). The image installs everything as indicated, following the versions you propose. However, installing PyTorch3D is giving me problems. I have tested all the different install options proposed in https://github.com/facebookresearch/pytorch3d/blob/main/INSTALL.md and none of them succeeded in building the wheel for PyTorch3D. Looking at the required versions for PyTorch3D on the above mentioned page, they say the following are needed:

Requirements Core library Linux or macOS or Windows Python 3.8, 3.9 or 3.10 PyTorch 1.10.0, 1.10.1, 1.10.2, 1.11.0, 1.12.0, 1.12.1, 1.13.0, 2.0.0 or 2.0.1. torchvision that matches the PyTorch installation. You can install them together as explained at pytorch.org to make sure of this. gcc & g++ ≥ 4.9 fvcore ioPath If CUDA is to be used, use a version which is supported by the corresponding pytorch version and at least version 9.2. If CUDA older than 11.7 is to be used and you are building from source, the CUB library must be available. We recommend version 1.10.0.

In particular, Python 3.7 and PyTorch 1.9.1 seem to not be supported. Am I doing something wrong and there is a simple solution? Or should I use compatible versions of Python and PyTorch risking errors in the code? For completeness, I am sharing also the Dockerfile I am using in order to set everything up:

# --------------------------------------------------------------------------------------------------------------------
# Keep in mind that the image needs to be run with: $ docker run -it --pgus all if3d_image 
# If changes are not being included in the build use $ docker build --no-cache -t if3d_image . 
# --------------------------------------------------------------------------------------------------------------------

# Build the container using the CUDA toolkit version 11.1 image as the base image
FROM nvidia/cuda:11.1.1-devel-ubuntu20.04

# Fetch the keys that are missing from the cuda base image 
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub

# For more details on the installation refere to https://saturncloud.io/blog/how-to-use-gpus-inside-docker-containers-resolving-cuda-version-and-torchcudaisavailable-issues/
# Also, refere to https://www.howtogeek.com/devops/how-to-use-an-nvidia-gpu-with-docker-containers/
RUN apt-get update && apt-get install -y --no-install-recommends \
    cuda-cudart-11-1 \
    && rm -rf /var/lib/apt/lists/*

# Install general dependecies
RUN apt-get update && \
    apt-get install -y \
    python3.7 \
    python3-pip \
    build-essential \
    git 
    #nvidia-docker2 || I don't know if this one is necessary. It should be tested when run on the servers

# Upgrade pip (this is necessary otherwise the installation of setuptools gives problems for some versions)
RUN python3 -m pip install --upgrade pip

# Set environment variables
ENV FORCE_CUDA=1

# Clone the IF3D repository. 
RUN git clone https://huggingface.co/spaces/leobcc/IF3D

# Change working directory to the project folder
WORKDIR /IF3D

# Install dependencies
RUN pip install -r requirement.txt

# Install the cuda compatible version of torch 1.9.1
RUN pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html

# Install PyTorch3D
RUN pip install git+https://github.com/facebookresearch/pytorch3d.git@stable

# Run setup
RUN cd code; python3 setup.py develop; cd ..

# Install Kaolin (version 0.10.0)
#RUN git clone --recursive https://github.com/NVIDIAGameWorks/kaolin \
#    && cd kaolin \
#    && git checkout v0.10.0 \
#    && python setup.py develop \
#    && cd ..
MoyGcc commented 9 months ago

Hi, thanks for the detailed report! The requirement I listed is according to the environment that I used during our development where I used a relatively old PyTorch3D version that supports the aforementioned Python and Pytorch versions. I also tested on newer Python and Pytorch versions and it turns out it's error-free. So if you're worried about the potential conflicts, you could try Python 3.8 and Pytorch 1.13.1.

Note that if you re-install PyTorch, you need to build kaolin again using the new PyTorch version. And it's recommended to install PyTorch3D using the prebuilt wheels https://github.com/facebookresearch/pytorch3d/blob/main/INSTALL.md#3-install-wheels-for-linux. However, it's better to keep pytorch-lightning version consistent with the requirement.

leobcc commented 9 months ago

Thank you for the clarification, I'll consider updating to the newer versions for my project if they don't cause conflicts.