PetervanLunteren/EcoAssist

Was previously working, now 'local variable 'elapsed_time' referenced before assignment'.

Closed this issue · 3 comments

I downloaded eco assist and it was working however was not using the GPU. I then updated the driver for the graphics cards I was using and now I get this error message.

An error has occurred (EcoAssist v4.4): 'local variable 'elapsed_time' referenced before assignment'.

Traceback (most recent call last):
File "EcoAssist\EcoAssist_GUI.py", line 1773, in start_deploy
deploy_model(var_choose_folder.get(), additional_img_options, data_type = "img")
File "EcoAssist\EcoAssist_GUI.py", line 1541, in deploy_model
progress_stats['text'] = create_md_progress_lbl(elapsed_time = elapsed_time,
UnboundLocalError: local variable 'elapsed_time' referenced before assignment

The python files for models models are both present in the pretrained models folder, seems to be another issue. I am a PhD student and have no formal training in python so am a little stuck on what to do...

Hi @almalino238 that error is thrown when there is an unexpected output from MegaDetector. I think it might have to do with your GPU not being found properly, but we let's check it out. Can you run EcoAssist in debug mode and copy-paste the full error message here?

Hi Peter,

Think I figured out the bug, as yesterday the log said "pytorch no longer supports this GPU because it is too old". I don't think the graphics card from 2013 is cutting it, or has the computational power I require for any machine learning related task.
Here is the session log from today:

PYTHONPATH : C:\PROGRA1\EcoAssist_files;C:\PROGRA1\EcoAssist_files\cameratraps;C:\PROGRA1\EcoAssist_files\ai4eutils;C:\PROGRA1\EcoAssist_files\yolov5;C:\PROGRA1\EcoAssist_files\EcoAssist;C:\PROGRA1\EcoAssist_files\labelImg;
PATH : C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv;C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\python3.8\site-packages;C:\Users\40380641\AppData\Local\Programs\Git\cmd;C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv;C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\Library\mingw-w64\bin;C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\Library\usr\bin;C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\Library\bin;C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\Scripts;C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\bin;C:\Users\40380641\AppData\Local\anaconda3\condabin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\libnvvp;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\NVIDIA Corporation\Nsight Compute 2023.3.1;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\40380641\AppData\Local\Programs\Python\Launcher;C:\Users\40380641\AppData\Local\Microsoft\WindowsApps;C:\Users\40380641\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\40380641\AppData\Local\Programs\Git\cmd;C:\PROGRA1\EcoAssist_files
Python 3.8.15
C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\python.exe
C:\Users\40380641\AppData\Local\Microsoft\WindowsApps\python.exe
Opening EcoAssist now...
['C:\Program Files\EcoAssist_files\cameratraps', 'C:\Program Files\EcoAssist_files\yolov5', 'C:\Program Files\EcoAssist_files\ai4eutils', 'C:\Program Files\EcoAssist_files', 'C:\PROGRA
1\EcoAssist_files\EcoAssist', 'C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\site-packages\git\ext\gitdb', 'C:\PROGRA1\EcoAssist_files', 'C:\PROGRA1\EcoAssist_files\cameratraps', 'C:\PROGRA1\EcoAssist_files\ai4eutils', 'C:\PROGRA1\EcoAssist_files\yolov5', 'C:\PROGRA1\EcoAssist_files\EcoAssist', 'C:\PROGRA1\EcoAssist_files\labelImg', 'C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\python38.zip', 'C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\DLLs', 'C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib', 'C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv', 'C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\site-packages', 'C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\site-packages\win32', 'C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\site-packages\win32\lib', 'C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\site-packages\Pythonwin']
EXECUTED: model_cls_animal_options({'self': 'None'})

EXECUTED: model_cls_vehicle_options({'self': 'None'})

EXECUTED: model_cls_person_options({'self': 'None'})

EXECUTED: browse_dir({'var': <tkinter.StringVar object at 0x00000202188FC520>, 'var_short': <tkinter.StringVar object at 0x00000202188FC580>, 'dsp': <tkinter.Label object .!notebook.!frame.!canvas.!frame.!labelframe.!label2>, 'cut_off_length': 25, 'n_row': 0, 'n_column': 0, 'str_sticky': 'w'})

EXECUTED: toggle_cls_frame({})

EXECUTED: start_deploy({})

EXECUTED: deploy_model({'path_to_image_folder': 'F:/Winter 2022_23 CT photos/Kebble/KE 14', 'selected_options': ['--output_relative_filenames', '--recursive'], 'data_type': 'img'})

EXECUTED: switch_yolov5_git_to({'model_type': 'old models'})

command:

['C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\python.exe', 'C:\Program Files\EcoAssist_files\cameratraps\detection\run_detector_batch.py', 'C:\Program Files\EcoAssist_files\pretrained_models\md_v5a.0.0.pt', '--output_relative_filenames', '--recursive', 'F:\Winter 2022_23 CT photos\Kebble\KE 14', 'F:\Winter 2022_23 CT photos\Kebble\KE 14\image_recognition_file.json']

C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\site-packages\torch\cuda_init_.py:120: UserWarning:
Found GPU%d %s which is of cuda capability %d.%d.
PyTorch no longer supports this GPU because it is too old.
The minimum cuda capability supported by this library is %d.%d.

warnings.warn(old_gpu_warn.format(d, name, major, minor, min_arch // 10, min_arch % 10))
4033 image files found in the input directory
PyTorch reports 2 available CUDA devices
GPU available: True
Imported YOLOv5 from PYTHONPATH
Using PyTorch version 1.10.1
Traceback (most recent call last):
File "C:\Program Files\EcoAssist_files\cameratraps\detection\run_detector_batch.py", line 1029, in
main()
File "C:\Program Files\EcoAssist_files\cameratraps\detection\run_detector_batch.py", line 995, in main
results = load_and_run_detector_batch(model_file=args.detector_file,
File "C:\Program Files\EcoAssist_files\cameratraps\detection\run_detector_batch.py", line 458, in load_and_run_detector_batch
detector = load_detector(model_file)
File "C:\PROGRA1\EcoAssist_files\cameratraps\detection\run_detector.py", line 285, in load_detector
detector = PTDetector(model_file, force_cpu, USE_MODEL_NATIVE_CLASSES)
File "C:\PROGRA
1\EcoAssist_files\cameratraps\detection\pytorch_detector.py", line 108, in init
self.model = PTDetector._load_model(model_path, self.device)
File "C:\PROGRA1\EcoAssist_files\cameratraps\detection\pytorch_detector.py", line 141, in _load_model
model = checkpoint['model'].float().fuse().eval()
File "C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\site-packages\torch\nn\modules\module.py", line 735, in float
return self._apply(lambda t: t.float() if t.is_floating_point() else t)
File "C:\PROGRA
1\EcoAssist_files\yolov5\models\yolo.py", line 242, in _apply
self = super()._apply(fn)
File "C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\site-packages\torch\nn\modules\module.py", line 570, in _apply
module._apply(fn)
File "C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\site-packages\torch\nn\modules\module.py", line 570, in _apply
module._apply(fn)
File "C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\site-packages\torch\nn\modules\module.py", line 570, in _apply
module._apply(fn)
File "C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\site-packages\torch\nn\modules\module.py", line 593, in _apply
param_applied = fn(param)
File "C:\Users\40380641\AppData\Local\anaconda3\envs\ecoassistcondaenv\lib\site-packages\torch\nn\modules\module.py", line 735, in
return self._apply(lambda t: t.float() if t.is_floating_point() else t)
RuntimeError: CUDA error: no kernel image is available for execution on the device
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.
ERROR:
local variable 'elapsed_time' referenced before assignment

DETAILS:
Traceback (most recent call last):
File "EcoAssist\EcoAssist_GUI.py", line 1773, in start_deploy
deploy_model(var_choose_folder.get(), additional_img_options, data_type = "img")
File "EcoAssist\EcoAssist_GUI.py", line 1541, in deploy_model
progress_stats['text'] = create_md_progress_lbl(elapsed_time = elapsed_time,
UnboundLocalError: local variable 'elapsed_time' referenced before assignment

Yes, that is indeed the problem. I'm afraid I can't do anything to help that... I'm going to close this issue now. Feel free to reopen if you have further questions.