facebookresearch / segment-anything-2

The repository provides code for running inference with the Meta Segment Anything Model 2 (SAM 2), links for downloading the trained model checkpoints, and example notebooks that show how to use the model.
Apache License 2.0
10.67k stars 854 forks source link

My solution when it failed installing #54

Open goodevile opened 1 month ago

goodevile commented 1 month ago

I am tired to explain everything so here it's what I did:

First install CUDA 12.5 (cuda cuda cuda cuda 🎶)

https://developer.nvidia.com/cuda-downloads

Then:

git clone git@github.com:facebookresearch/segment-anything-2.git

cd segment-anything-2

Next: pip install wheel setuptools pip install ninja

why ninja? well... got this error: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. (don't ask me, ask who wrote this code that asks for ninjas 🥷)

Are you using a venv? (virtual environment) then check nvcc version:

nvcc --version

12.* ? then you are good to go and use pip install -e .

not 12.*? then check where cuda is installed:

ls /usr/local/

are you seeing the cuda folder like this?:

bin cuda cuda-12 cuda-12.5 etc games include lib man sbin share src

then do this:

export PATH=/usr/local/cuda-12.5/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-12.5/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

deactivate your environment and activate it again. then:

pip install -e .

You happy? leave a like. Unhappy? I tried ok?

TimoK93 commented 1 month ago

Thanks, that helped! I wanted to add that I needed to set the GCC version to something between 9 < Version <14. You can do this by

CC=gcc-11 pip install -e .

or with an other available version that exists on your device!

seanwhen commented 1 month ago

Which version of python is the conda environment you are using? Is it 3.9 or 3.10?

TimoK93 commented 1 month ago

I use conda with python 3.10.

fritol commented 1 month ago

worked for me:

install torch nightly! install CUDA 12.1 run the sam2 pip command

mahmoodkashmiri commented 1 month ago

Try this