Skip to content

Commit

Permalink
Enabled OpenCL in OpenCV (#24)
Browse files Browse the repository at this point in the history
* Enabled OpenCL in OpenCV

* Added comment about OpenCL block to README

* Added comment about OpenCL block to README
  • Loading branch information
ternaus committed Jul 10, 2018
1 parent 9361d3a commit fa0fd0a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,15 @@ Alternatively, you can start a web server that rebuilds the documentation
automatically when a change is detected by running `make livehtml`


## Comments
In some systems, in the multiple GPU regime PyTorch may deadlock the DataLoader if OpenCV was compiled with OpenCL optimizations. Adding the following two lines before the library import may help. For more details [https://github.com/pytorch/pytorch/issues/1355](https://github.com/pytorch/pytorch/issues/1355)



```python
cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)
```

### Thanks:
Special thanks to [@creafz](https://github.com/creafz) for refactoring, documentation, tests, CI and benchmarks. Awesome work!
3 changes: 0 additions & 3 deletions albumentations/augmentations/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

import cv2

cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)

import numpy as np
from scipy.ndimage.filters import gaussian_filter

Expand Down
3 changes: 0 additions & 3 deletions albumentations/augmentations/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import cv2

cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)

import numpy as np

from ..core.transforms_interface import to_tuple, DualTransform, ImageOnlyTransform
Expand Down
2 changes: 0 additions & 2 deletions albumentations/core/transforms_interface.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import numpy as np
import cv2
cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)

__all__ = ['to_tuple', 'BasicTransform', 'DualTransform', 'ImageOnlyTransform']

Expand Down

0 comments on commit fa0fd0a

Please sign in to comment.