Skip to content

Commit fa0fd0a

Browse files
authored
Enabled OpenCL in OpenCV (albumentations-team#24)
* Enabled OpenCL in OpenCV * Added comment about OpenCL block to README * Added comment about OpenCL block to README
1 parent 9361d3a commit fa0fd0a

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,15 @@ Alternatively, you can start a web server that rebuilds the documentation
129129
automatically when a change is detected by running `make livehtml`
130130

131131

132+
## Comments
133+
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)
134+
135+
136+
137+
```python
138+
cv2.setNumThreads(0)
139+
cv2.ocl.setUseOpenCL(False)
140+
```
141+
132142
### Thanks:
133143
Special thanks to [@creafz](https://github.com/creafz) for refactoring, documentation, tests, CI and benchmarks. Awesome work!

albumentations/augmentations/functional.py

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
import cv2
55

6-
cv2.setNumThreads(0)
7-
cv2.ocl.setUseOpenCL(False)
8-
96
import numpy as np
107
from scipy.ndimage.filters import gaussian_filter
118

albumentations/augmentations/transforms.py

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import cv2
44

5-
cv2.setNumThreads(0)
6-
cv2.ocl.setUseOpenCL(False)
7-
85
import numpy as np
96

107
from ..core.transforms_interface import to_tuple, DualTransform, ImageOnlyTransform

albumentations/core/transforms_interface.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import numpy as np
22
import cv2
3-
cv2.setNumThreads(0)
4-
cv2.ocl.setUseOpenCL(False)
53

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

0 commit comments

Comments
 (0)