Skip to content

Commit

Permalink
Merge pull request #78 from mooch443/dev
Browse files Browse the repository at this point in the history
* have to unlock data_mutex to avoid deadlock in predictions
  • Loading branch information
mooch443 committed Jan 12, 2022
2 parents 79a07b7 + 76aa5fe commit 0c4577e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Application/src/tracker/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2895,7 +2895,7 @@ void GUI::draw_footer(DrawStructure& base) {
if(section) {
Vec2 mouse_position = _gui.mouse_position();
mouse_position = (mouse_position - section->pos()).div(section->scale());
mouse_status.set_txt(Meta::toStr(std::vector<int>{static_cast<int>(mouse_position.x), static_cast<int>(mouse_position.y)})+" "+Meta::toStr(cache().display_blobs.size())+" blobs "+Meta::toStr(cache()._current_pixels)+"px "+Meta::toStr(cache()._average_pixels)+"px/blob pp:"+Meta::toStr(cache().processed_frame.num_pixels())+"px");
mouse_status.set_txt(Meta::toStr(std::vector<int>{static_cast<int>(mouse_position.x), static_cast<int>(mouse_position.y)})+" "+Meta::toStr(cache().display_blobs.size())+" blobs "+Meta::toStr(cache()._current_pixels)+"px"); //"+Meta::toStr(cache()._average_pixels)+"px/blob pp:"+Meta::toStr(cache().processed_frame.num_pixels())+"px");
}

additional_status.set_txt(additional_status_text());
Expand Down
4 changes: 3 additions & 1 deletion Application/src/tracker/python/GPURecognition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ void PythonIntegration::reinit() {
_main = py::module::import("__main__");
_main.def("set_version", [](std::string x, bool has_gpu, std::string physical_name) {
#ifndef NDEBUG
Debug("set_version called with '%S' and '%S'", &x, &physical_name);
Debug("set_version called with '%S' and '%S' - %s", &x, &physical_name, has_gpu?"gpu":"no gpu");
#endif
auto array = utils::split(x, ' ');
if(array.size() > 0) {
Expand Down Expand Up @@ -586,6 +586,7 @@ void PythonIntegration::reinit() {
tasks.erase(it);

//Debug("Starting python task from queue (elements left: %d)...", tasks.size());
lock.unlock();
try {
task._task();
} catch(py::error_already_set& e) {
Expand All @@ -594,6 +595,7 @@ void PythonIntegration::reinit() {
} catch( ... ) {
Debug("Caught one exception.");
}
lock.lock();
}

if(_terminate)
Expand Down
31 changes: 11 additions & 20 deletions Application/src/tracker/python/trex_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,16 @@
import tensorflow

import platform
if platform.system() == "Darwin":
from tensorflow.python.compiler.mlcompute import mlcompute
if mlcompute.is_apple_mlc_enabled():
found = True
physical = 'MLC'
else:
physical = ''

if not found:
from tensorflow.compat.v1 import ConfigProto, InteractiveSession
config = ConfigProto()
config.gpu_options.allow_growth=True
sess = InteractiveSession(config=config)
from tensorflow.python.client import device_lib
gpus = [x.physical_device_desc for x in device_lib.list_local_devices() if x.device_type == 'GPU']
found = len(gpus) > 0
if found:
for device in gpus:
physical = device.split(',')[1].split(': ')[1]
from tensorflow.compat.v1 import ConfigProto, InteractiveSession
config = ConfigProto()
config.gpu_options.allow_growth=True
sess = InteractiveSession(config=config)
from tensorflow.python.client import device_lib
gpus = [x.physical_device_desc for x in device_lib.list_local_devices() if x.device_type == 'GPU']
found = len(gpus) > 0
if found:
for device in gpus:
physical = device.split(',')[1].split(': ')[1]

except ImportError:
found = False
Expand All @@ -45,4 +36,4 @@
pass

print('setting version',sys.version,found,physical)
set_version(sys.version, found, physical)
set_version(sys.version, found, physical)
2 changes: 1 addition & 1 deletion conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ requirements:
- python # [not arm64]
- python=3.9.9 # [osx and arm64]
- nomkl # [osx]
- h5py # [arm64]
- h5py ==3.1.0 # [arm64]
- pip=21.3.1 # [arm64]
- scipy # [not arm64]
- scipy ==1.7.3 # [arm64]
Expand Down

0 comments on commit 0c4577e

Please sign in to comment.