facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.7k stars 1.3k forks source link

pytorch3d installation on colab taking too long #1871

Closed DomenicoMeconi closed 1 week ago

DomenicoMeconi commented 1 week ago

I am running this on colab: import os import sys import torch need_pytorch3d=False try: import pytorch3d except ModuleNotFoundError: need_pytorch3d=True if need_pytorch3d: if torch.version.startswith("2.1.") and sys.platform.startswith("linux"):

We try to install PyTorch3D via a released wheel.

    pyt_version_str=torch.__version__.split("+")[0].replace(".", "")
    version_str="".join([
        f"py3{sys.version_info.minor}_cu",
        torch.version.cuda.replace(".",""),
        f"_pyt{pyt_version_str}"
    ])
    !pip install fvcore iopath
    !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html
else:
    # We try to install PyTorch3D from source.
    !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'

This results in a correct installation but it takes every time around 25 minutes to complete, the torch version is 2.4.0+cu121, is there any way to speed up the process? Maybe upgrade to an earlier version? I've tried a few, even changing torch versions, but they don't seem to work.

bottler commented 1 week ago

If you take the new version of this code which you will find in the current tutorials, then you will see that the installation will be much quicker because it will find a wheel. In particular we no longer have a check on the torch version.

On Wed, 18 Sept 2024, 11:06 Dondo, @.***> wrote:

I am running this on colab: import os import sys import torch need_pytorch3d=False try: import pytorch3d except ModuleNotFoundError: need_pytorch3d=True if need_pytorch3d: if torch.version.startswith("2.1.") and sys.platform.startswith("linux"):

We try to install PyTorch3D via a released wheel.

pyt_version_str=torch.version.split("+")[0].replace(".", "") version_str="".join([ f"py3{sys.version_info.minor}_cu", torch.version.cuda.replace(".",""), f"_pyt{pyt_version_str}" ]) !pip install fvcore iopath !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html else:

We try to install PyTorch3D from source.

!pip install @.*** '

This results in a correct installation but it takes every time around 25 minutes to complete, the torch version is 2.4.0+cu121, is there any way to speed up the process? Maybe upgrade to an earlier version? I've tried a few, even changing torch versions, but they don't seem to work.

— Reply to this email directly, view it on GitHub https://github.com/facebookresearch/pytorch3d/issues/1871, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFDQQPMOMWWCLXXBT6EQPDZXFGBJAVCNFSM6AAAAABONKHT3CVHI2DSMVQWIX3LMV43ASLTON2WKOZSGUZTGMRZHAZDANA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

DomenicoMeconi commented 1 week ago

Thanks, I used this code taken from the updated tutorials: import os import sys import torch import subprocess need_pytorch3d=False try: import pytorch3d except ModuleNotFoundError: need_pytorch3d=True if need_pytorch3d: pyt_version_str=torch.version.split("+")[0].replace(".", "") version_str="".join([ f"py3{sys.version_info.minor}_cu", torch.version.cuda.replace(".",""), f"_pyt{pyt_version_str}" ]) !pip install iopath if sys.platform.startswith("linux"): print("Trying to install wheel for PyTorch3D") !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html pip_list = !pip freeze need_pytorch3d = not any(i.startswith("pytorch3d==") for i in pip_list) if need_pytorch3d: print(f"failed to find/install wheel for {version_str}") if need_pytorch3d: print("Installing PyTorch3D from source") !pip install ninja !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'

This gave an error, fixed by adding !pip install fvcore after the line !pip install iopath. Now it works and is fast.

bottler commented 1 week ago

Thanks for that. I know why it's happening. The wheel is version 0.7.7 but the code is corresponding to version 0.7.8 in which we newly do not depend on fvcore. We can fix by updating the wheel.

bottler commented 1 week ago

Should now be done

bottler commented 1 week ago

And it's now pyt2.4.1; also done.