facebookresearch / pytorch3d

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

Example Google Colab Notebooks have stopped working #1177

Closed satyajit-ink closed 2 years ago

satyajit-ink commented 2 years ago

Google Colab Example Notebooks have stopped working

Recently Colab upgraded to PyTorch 1.11.0 with Cuda 11.3, this has broken the example notebooks

import os
import sys
import torch
need_pytorch3d=False
try:
    import pytorch3d
except ModuleNotFoundError:
    need_pytorch3d=True
if need_pytorch3d:
    if torch.__version__.startswith("1.10.") 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 pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html
    else:
        # We try to install PyTorch3D from source.
        !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz
        !tar xzf 1.10.0.tar.gz
        os.environ["CUB_HOME"] = os.getcwd() + "/cub-1.10.0"
        !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'

and here's the output

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   128  100   128    0     0    364      0 --:--:-- --:--:-- --:--:--   364
100  404k  100  404k    0     0   502k      0 --:--:-- --:--:-- --:--:--  502k
Collecting git+https://github.com/facebookresearch/pytorch3d.git@stable
  Cloning https://github.com/facebookresearch/pytorch3d.git (to revision stable) to /tmp/pip-req-build-euq9uqyq
  Running command git clone -q https://github.com/facebookresearch/pytorch3d.git /tmp/pip-req-build-euq9uqyq
  Running command git checkout -q 3fc3ea507bfbf7e1c2d5023a6db202698206f91d
Collecting fvcore
  Downloading fvcore-0.1.5.post20220414.tar.gz (50 kB)
     |████████████████████████████████| 50 kB 2.7 MB/s 
Collecting iopath
  Downloading iopath-0.1.9-py3-none-any.whl (27 kB)
Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from fvcore->pytorch3d==0.6.1) (1.21.6)
Collecting yacs>=0.1.6
  Downloading yacs-0.1.8-py3-none-any.whl (14 kB)
Collecting pyyaml>=5.1
  Downloading PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (596 kB)
     |████████████████████████████████| 596 kB 12.2 MB/s 
Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from fvcore->pytorch3d==0.6.1) (4.64.0)
Requirement already satisfied: termcolor>=1.1 in /usr/local/lib/python3.7/dist-packages (from fvcore->pytorch3d==0.6.1) (1.1.0)
Requirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (from fvcore->pytorch3d==0.6.1) (7.1.2)
Requirement already satisfied: tabulate in /usr/local/lib/python3.7/dist-packages (from fvcore->pytorch3d==0.6.1) (0.8.9)
Collecting portalocker
  Downloading portalocker-2.4.0-py2.py3-none-any.whl (16 kB)
Building wheels for collected packages: pytorch3d, fvcore
  Building wheel for pytorch3d (setup.py) ... error
  ERROR: Failed building wheel for pytorch3d
  Running setup.py clean for pytorch3d
  Building wheel for fvcore (setup.py) ... done
  Created wheel for fvcore: filename=fvcore-0.1.5.post20220414-py3-none-any.whl size=61211 sha256=82d481974b7c2b8a44f677c514d094807310294378b2004b4cdb90a2741f9c3b
  Stored in directory: /root/.cache/pip/wheels/df/f4/b8/7b5df8b6722f4c72315ce70c31aa693e00cef6a5056149bd28
Successfully built fvcore
Failed to build pytorch3d
Installing collected packages: pyyaml, portalocker, yacs, iopath, fvcore, pytorch3d
  Attempting uninstall: pyyaml
    Found existing installation: PyYAML 3.13
    Uninstalling PyYAML-3.13:
      Successfully uninstalled PyYAML-3.13
    Running setup.py install for pytorch3d ... error
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-euq9uqyq/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-euq9uqyq/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-_l3ym2x6/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7/pytorch3d Check the logs for full command output.

Instructions To Reproduce the Issue:

Run any of the notebooks in the tutorial, for example: https://colab.research.google.com/github/facebookresearch/pytorch3d/blob/stable/docs/tutorials/deform_source_mesh_to_target_mesh.ipynb

For torch version 1.11.0+cu113 in colab, the url should be https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py37_cu113_pyt1110/download.html which doesn't exist, also build from source is not working. This could be temporaily fixed by downgrading torch for now.

satyajit-ink commented 2 years ago

downgrading torch fixes it

%pip install torch==1.10.0+cu113 torchvision==0.11.0+cu113 torchtext==0.11.0 torchaudio==0.10.0+cu113 -f https://download.pytorch.org/whl/torch_stable.html

but i think using the nightly builds might work as well

hamid162 commented 2 years ago

Hi I'm facing the same issue on Colab. Running torch.__version__ gives me PyTorch version 1.11.0+cu113.

Other than downgrading torch, is there any other solution to solve this problem?

bottler commented 2 years ago

Colab has just upgraded to PyTorch version 1.11.0, which the current PyTorch3D release doesn't have a build for. So now, running the tutorial means it will try to build from source, which fails after a couple of minutes because the current release (stable) of PyTorch3D is not compatible with PyTorch 1.11.0. (If you add --verbose to the pip install, you will see the error, specifically fatal error: TH/TH.h: No such file or directory on a line #include <TH/TH.h>.)

The incompatibility has been fixed on the main branch of PyTorch3D. So I hope it will work (albeit with a very slow build from source) if you replace

!pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'

with

!pip install 'git+https://github.com/facebookresearch/pytorch3d.git'

We hope to release another version of PyTorch3D very soon, which will fix this.

bottler commented 2 years ago

Actually, installing from main fails right now because of a problem with the console_scripts specification in setup.py. We'll fix soon.

bottler commented 2 years ago

Actually, installing from main fails right now because of a problem with the console_scripts specification in setup.py. We'll fix soon.

This bit of the problem has just been fixed by 41c594ca. !pip install 'git+https://github.com/facebookresearch/pytorch3d.git' should now work. (Although it is still very slow!)

tobyy22 commented 2 years ago

Hi, is the original example supposed to work now as new version of pytorch3d 0.6.2 has been released? I am still getting the same error. Thank you

bottler commented 2 years ago

I'm afraid this isn't fixed yet. You still need to build from source in the tutorial notebooks. Yesterday's release does not include linux wheels, at least not yet. I have encountered difficulties in building a wheel for CUDA 11.1 / PyTorch 1.11.0 / Python 3.7, which corresponds to the current Colab environment.

bottler commented 2 years ago

The wheel for colab for the release (0.6.2) is now present, and the stable tag has been updated. This means the tutorials are expected to work fine on Colab without building from source.

bykof commented 2 years ago

I am getting an "Access denied" error from: https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py38_cu102_pyt1110/download.html

Running in google colab:

!pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py38_cu102_pyt1110/download.html

cashes with:

Looking in links: https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py38_cu102_pyt1110/download.html
ERROR: Could not find a version that satisfies the requirement pytorch3d (from versions: none)
ERROR: No matching distribution found for pytorch3d
bottler commented 2 years ago

@bykof That wheel doesn't exist. The linux wheels mainly exist to support Google Colab, which is on CUDA 11.1. They don't have versions built for dependencies older than Colab's, and they don't try to. Since you aren't using Colab, can you use conda, which is the binary distribution format for linux which we support properly?

bykof commented 2 years ago

@bottler I am actually using Google Colab…

bottler commented 2 years ago

Is Colab using CUDA 10.2 for you? Is that because you did something special?

bykof commented 2 years ago

It was CUDA 10.2, but after restarting my environment its 11.3 now o.O

pzy37_cu113_pyt1110 Now the installation worked:

py37_cu113_pyt1110
Looking in links: https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py37_cu113_pyt1110/download.html
Collecting pytorch3d
  Downloading https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py37_cu113_pyt1110/pytorch3d-0.6.2-cp37-cp37m-linux_x86_64.whl (43.2 MB)
     |████████████████████████████████| 43.2 MB 1.2 MB/s 
bottler commented 2 years ago

This is confusing. I thought the cuda version was constant for the whole of colab, and at the moment I thought it was 11.1.

bykof commented 2 years ago

So I created a new colab notebook and entered: !nvcc --version output was:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Oct_12_20:09:46_PDT_2020
Cuda compilation tools, release 11.1, V11.1.105
Build cuda_11.1.TC455_06.29190527_0

You were right, it's 11.1, sorry for confusing you :)

cajoek commented 2 years ago

@bottler Is pytorch3d expected to work on colab now? With:

import sys
import torch
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 --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html

From https://github.com/facebookresearch/pytorch3d/blob/main/INSTALL.md#3-install-wheels-for-linux I'm randomly getting on of:

Looking in links: https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py37_cu113_pyt1110/download.html
Collecting pytorch3d
  Downloading https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py37_cu113_pyt1110/pytorch3d-0.6.2-cp37-cp37m-linux_x86_64.whl (43.2 MB)
     |████████████████████████████████| 43.2 MB 1.2 MB/s 
ERROR: Could not find a version that satisfies the requirement iopath (from pytorch3d) (from versions: none)
ERROR: No matching distribution found for iopath

or:

Looking in links: https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py37_cu113_pyt1110/download.html
Collecting pytorch3d
  Downloading https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py37_cu113_pyt1110/pytorch3d-0.6.2-cp37-cp37m-linux_x86_64.whl (43.2 MB)
     |████████████████████████████████| 43.2 MB 1.3 MB/s 
ERROR: Could not find a version that satisfies the requirement fvcore (from pytorch3d) (from versions: none)
ERROR: No matching distribution found for fvcore
bottler commented 2 years ago

The tutorials are fine now. Look carefully at how they begin - there's a !pip install fvcore iopath which you need first.

MarinerZZ commented 1 year ago

Hi, I am having the same issue trying to install the dependencies. I am following the colab examples about how to install the package:

import os
import sys
import torch
need_pytorch3d=False
try:
    import pytorch3d
except ModuleNotFoundError:
    need_pytorch3d=True
if need_pytorch3d:
    if torch.__version__.startswith("1.13.") 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.
        !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz
        !tar xzf 1.10.0.tar.gz
        os.environ["CUB_HOME"] = os.getcwd() + "/cub-1.10.0"
        !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable

And this is the error I am getting:

error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Building wheel for pytorch3d (setup.py) ... error
  ERROR: Failed building wheel for pytorch3d
  Running setup.py clean for pytorch3d
Failed to build pytorch3d
Installing collected packages: pytorch3d
  error: subprocess-exited-with-error

  × Running setup.py install for pytorch3d did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Running setup.py install for pytorch3d ... error
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pytorch3d

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Currently in colab i am using cuda version 11.8 and torch version 1.10.0+cu113

Is it possible that I am skipping something from the installation process like downgrading cuda maybe? Also I tried both, the stable version and the main branch version and the error keeps appearing. Thanks in advance for the help!

bottler commented 1 year ago

@MarinerZZ Please open a new issue for a new question. This issue is two years old and resolved.

MarinerZZ commented 1 year ago

Ok sorry!