gaomingqi / Track-Anything

Track-Anything is a flexible and interactive tool for video object tracking and segmentation, based on Segment Anything, XMem, and E2FGVI.
MIT License
6.52k stars 481 forks source link

Torch not compiled with CUDA enabled #94

Open TanvirHafiz opened 1 year ago

TanvirHafiz commented 1 year ago

it says "Torch not compiled with CUDA enabled" how do i enable CUDA and compile torch??? or am I doing something wrong!

I get this

C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torchvision\io\image.py:13: UserWarning: Failed to load image Python extension: Could not find module 'C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\Lib\site-packages\torchvision\image.pyd' (or one of its dependencies). Try using the full path with constructor syntax. warn(f"Failed to load image Python extension: {e}") No CUDA runtime is found, using CUDA_HOME='C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1' C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\mmcv__init.py:20: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details. warnings.warn( Initializing BaseSegmenter to cuda:3 Traceback (most recent call last): File "G:\Track-Anything\app.py", line 385, in model = TrackingAnything(SAM_checkpoint, xmem_checkpoint, e2fgvi_checkpoint,args) File "G:\Track-Anything\track_anything.py", line 18, in init self.samcontroler = SamControler(self.sam_checkpoint, args.sam_model_type, args.device) File "G:\Track-Anything\tools\interact_tools.py", line 37, in init self.sam_controler = BaseSegmenter(SAM_checkpoint, model_type, device) File "G:\Track-Anything\tools\base_segmenter.py", line 26, in init__ self.model.to(device=self.device) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 907, in to return self._apply(convert) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 578, in _apply module._apply(fn) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 578, in _apply module._apply(fn) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 578, in _apply module._apply(fn) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 601, in _apply param_applied = fn(param) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 905, in convert return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\cuda__init__.py", line 210, in _lazy_init raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

but I have cuda 12.1 and 11.7 installed

TanvirHafiz commented 1 year ago

reinstalled torch frest now digging this issue

C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\mmcv__init.py:20: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details. warnings.warn( download checkpoints ...... download successfully! Initializing BaseSegmenter to cuda:3 Traceback (most recent call last): File "G:\Track-Anything\app.py", line 385, in model = TrackingAnything(SAM_checkpoint, xmem_checkpoint, e2fgvi_checkpoint,args) File "G:\Track-Anything\track_anything.py", line 18, in init self.samcontroler = SamControler(self.sam_checkpoint, args.sam_model_type, args.device) File "G:\Track-Anything\tools\interact_tools.py", line 37, in init self.sam_controler = BaseSegmenter(SAM_checkpoint, model_type, device) File "G:\Track-Anything\tools\base_segmenter.py", line 26, in init__ self.model.to(device=self.device) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1149, in to return self._apply(convert) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 801, in _apply module._apply(fn) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 801, in _apply module._apply(fn) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 801, in _apply module._apply(fn) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 824, in _apply param_applied = fn(param) File "C:\Users\Tanvir\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1147, in convert return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) RuntimeError: CUDA error: invalid device ordinal CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1. Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.

Monkiesh commented 1 year ago

Same issue here.

mfkeles commented 1 year ago

same here any chance this was resolved?

jin-eld commented 1 year ago

The error message is misleading, I think the issue is that app.py hardcodes args.device = "cuda:3" which will fail if you have only one card. Try removing that line, in this case the --device command line parameter will actually work again and will also use cuda:0 as default, which should be fine for most users.

aboharbf commented 1 year ago

Same issue, even when commenting out the cuda:3 line

Torch not compiled with CUDA enabled
  File "C:\Track-Anything\tools\base_segmenter.py", line 26, in __init__
    self.model.to(device=self.device)
  File "C:\Track-Anything\tools\interact_tools.py", line 37, in __init__
    self.sam_controler = BaseSegmenter(SAM_checkpoint, model_type, device)
  File "C:\Track-Anything\track_anything.py", line 18, in __init__
    self.samcontroler = SamControler(self.sam_checkpoint, args.sam_model_type, args.device)
  File "C:\Track-Anything\app.py", line 385, in <module>
    model = TrackingAnything(SAM_checkpoint, xmem_checkpoint, e2fgvi_checkpoint,args)
AssertionError: Torch not compiled with CUDA enabled
mfkeles commented 1 year ago

it’s not the same actually you have to install torch that matches your cuda version.

aboharbf commented 1 year ago

I was looking at other posts about this problem, and after putting

        import torch

        print("Torch version:",torch.__version__)

        print("Is CUDA enabled?",torch.cuda.is_available())

I find


Torch version: 2.0.1+cpu
Is CUDA enabled? False

I use a 3080, so not sure why the CPU version is being used. I was under the impression the pip requirements would install CUDA but now I'm getting the package straight from Nvidia via .exe

mfkeles commented 1 year ago

you have to conda install torch with the cuda version that it is compatible. you got torch 2.0.1 installed i think that requires cuda 12 at least

aboharbf commented 1 year ago

Seems like I still have the same problem. Even deleted the env and clean installed image

I'll have to dig into why CUDA may not be turning on despite the env seemingly 'seeing' it.

aboharbf commented 1 year ago

Update: I got it working by following the procedure on this page: https://www.educative.io/answers/how-to-resolve-torch-not-compiled-with-cuda-enabled. Had to uninstall Torch and reinstall using instructions here: https://pytorch.org/get-started/locally/

samadbarrikhojasteh commented 9 months ago

Please change "cuda:3" to "cuda:0" in app.py file (line 380) then install gradio pip install gradio==3.39.0.

TanvirHafiz commented 7 months ago

(venv) F:\Track-Anything>python app.py --device cuda:0 F:\Track-Anything\venv\lib\site-packages\gradio_client\documentation.py:103: UserWarning: Could not get documentation group for <class 'gradio.mix.Parallel'>: No known documentation group for module 'gradio.mix' warnings.warn(f"Could not get documentation group for {cls}: {exc}") F:\Track-Anything\venv\lib\site-packages\gradio_client\documentation.py:103: UserWarning: Could not get documentation group for <class 'gradio.mix.Series'>: No known documentation group for module 'gradio.mix' warnings.warn(f"Could not get documentation group for {cls}: {exc}") Initializing BaseSegmenter to cuda:0 Traceback (most recent call last): File "F:\Track-Anything\app.py", line 385, in model = TrackingAnything(SAM_checkpoint, xmem_checkpoint, e2fgvi_checkpoint,args) File "F:\Track-Anything\track_anything.py", line 18, in init self.samcontroler = SamControler(self.sam_checkpoint, args.sam_model_type, args.device) File "F:\Track-Anything\tools\interact_tools.py", line 37, in init self.sam_controler = BaseSegmenter(SAM_checkpoint, model_type, device) File "F:\Track-Anything\tools\base_segmenter.py", line 26, in init self.model.to(device=self.device) File "F:\Track-Anything\venv\lib\site-packages\torch\nn\modules\module.py", line 1152, in to return self._apply(convert) File "F:\Track-Anything\venv\lib\site-packages\torch\nn\modules\module.py", line 802, in _apply module._apply(fn) File "F:\Track-Anything\venv\lib\site-packages\torch\nn\modules\module.py", line 802, in _apply module._apply(fn) File "F:\Track-Anything\venv\lib\site-packages\torch\nn\modules\module.py", line 802, in _apply module._apply(fn) File "F:\Track-Anything\venv\lib\site-packages\torch\nn\modules\module.py", line 825, in _apply param_applied = fn(param) File "F:\Track-Anything\venv\lib\site-packages\torch\nn\modules\module.py", line 1150, in convert return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) File "F:\Track-Anything\venv\lib\site-packages\torch\cuda__init__.py", line 293, in _lazy_init raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

changed GPU to 3090. all the other programs that uses CUDA works. except this one. removed the line with cuda:3, installed gradio 3.39, sti;; same error