facebookresearch / dinov2

PyTorch code and models for the DINOv2 self-supervised learning method.
Apache License 2.0
9.05k stars 799 forks source link

Can not install in Colab #347

Open pitikorn32 opened 10 months ago

pitikorn32 commented 10 months ago

I have issue about install DinoV2 in Google Colab.

First, I want to run https://github.com/facebookresearch/dinov2/blob/main/notebooks/semantic_segmentation.ipynb in Colab.

import sys

INSTALL = True # Switch this to install dependencies
if INSTALL: # Try installing package with extras
    REPO_URL = "https://github.com/facebookresearch/dinov2"
    !{sys.executable} -m pip install -e {REPO_URL}'[extras]' --extra-index-url https://download.pytorch.org/whl/cu117  --extra-index-url https://pypi.nvidia.com
else:
    REPO_PATH = "<FIXME>" # Specify a local path to the repository (or use installed package instead)
    sys.path.append(REPO_PATH)

And I switched INSTALL = True to install but I found this

ERROR: https://github.com/facebookresearch/dinov2[extras] is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with bzr+http, bzr+https, bzr+ssh, bzr+sftp, bzr+ftp, bzr+lp, bzr+file, git+http, git+https, git+ssh, git+git, git+file, hg+file, hg+http, hg+https, hg+ssh, hg+static-http, svn+ssh, svn+http, svn+https, svn+svn, svn+file).

image

Then I tried another way follow this https://github.com/facebookresearch/dinov2/issues/219#issuecomment-1722482446. But still error while pip install -r requirements.txt -r requirements-extras.txt

image

If someone can run semantic_segmentation in Colab help me please.

thomasf1 commented 8 months ago

Getting the same error. Quite strange that nobody seems to have checked if the Colab version works :o - It´s usally the first thing people try and a good indication of a projects health.

yassineyahyaoui commented 7 months ago

Same here. Have you found a workaround @thomasf1 @pitikorn32 ?

thomasf1 commented 7 months ago

@yassineyahyaoui I have concluded that if they don't care about that, the rest will be a bit of a mess, too and moved on to use another project.

JyotsanaS commented 7 months ago

Is there any other project for Dino v2? I am facing same error.

yassineyahyaoui commented 6 months ago

@JyotsanaS Here are a few DinoV2 projects I've worked on that have worked for me using google colab:

First of all, make sure you have CUDA version 11.7 Next, you need to install the Microsoft C++ Build Tools. Here's a link that helped me Now follow the instructions below

conda create -n myenv python=3.9 
conda activate myenv
install jupyter
conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 pytorch-cuda=11.7 -c pytorch -c nvidia
conda install pip
pip install fvcore
pip install iopath
pip install omegaconf
pip install xformers=0.0.18
pip install git+https://github.com/facebookincubator/submitit
pip install ftfy
pip install regex
pip install -U openmim
mim install mmcv==1.5.0
mim install mmsegmentation==0.27.0

That's how it worked for me, I hope it works for you too.

yassineyahyaoui commented 6 months ago

@thomasf1 @pitikorn32 @JyotsanaS I finally found a workaround that fixes Dinov2 Semantic Segmentation Notebook: Link

ckevar commented 2 months ago

I changed the section of the code as follows:

import sys

INSTALL = True # Switch this to install dependencies
if INSTALL: # Try installing package with extras
    REPO_URL = "https://github.com/facebookresearch/dinov2"
    !git clone {REPO_URL}
    %cd dinov2
    !{sys.executable} -m pip install -e . --extra-index-url https://download.pytorch.org/whl/cu117  --extra-index-url https://pypi.nvidia.com
    !{sys.executable} -m pip install -r requirements-extras.txt --extra-index-url https://download.pytorch.org/whl/cu117  --extra-index-url https://pypi.nvidia.com
else:
    REPO_PATH = "<FIXME>" # Specify a local path to the repository (or use installed package instead)
    sys.path.append(REPO_PATH)

Edit: It might be an Error about "Failed to build installable wheels for some pyproject.toml based projects (mmcv-full)". So in order to install mmcv-full do this (in a separate section):

!pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.1.0/index.html