Skip to content

Commit dbc059e

Browse files
committed
build: opencv auto detection
1 parent f126482 commit dbc059e

2 files changed

Lines changed: 45 additions & 12 deletions

File tree

deps/build.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ else
6868
info("Did not find a CUDA installation, using CPU-only version of MXNet.")
6969
end
7070

71+
# try to find opencv
72+
HAS_OPENCV = false
73+
let libopencv_core = Libdl.find_library("libopencv_core")
74+
HAS_OPENCV = !isempty(libopencv_core) && Libdl.dlopen_e(libopencv_core) != C_NULL
75+
end
76+
77+
info("Build with OpenCV: $(HAS_OPENCV)")
78+
7179
function get_cpucore()
7280
if haskey(ENV, "TRAVIS") # on travis-ci
7381
2
@@ -188,7 +196,9 @@ if !libmxnet_detected
188196
end
189197

190198
# Configure OpenCV
191-
`sed -i -s 's/USE_OPENCV = 1/USE_OPENCV = 0/' config.mk`
199+
if !HAS_OPENCV
200+
`sed -i -s 's/USE_OPENCV = 1/USE_OPENCV = 0/' config.mk`
201+
end
192202

193203
# Configure CUDA
194204
if HAS_CUDA

docs/src/user-guide/install.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,42 @@ MXNet.jl is built on top of [libmxnet](https://github.com/dmlc/mxnet).
2121
Upon installation, Julia will try to automatically download and build
2222
libmxnet.
2323

24-
There are three environment variables that change this behaviour. If you
25-
already have a pre-installed version of mxnet you can use `MXNET_HOME`
26-
to point the build-process in the right direction. If the automatic
27-
cuda detection fails you can also set `CUDA_HOME` to override the process.
28-
To control which version of libmxnet will be compiled, you can use the
29-
`MXNET_COMMIT` variable to point to either a version tag (e.g. `v0.10.0`), a
30-
branch name (e.g. `master`) or a specific commit hash (e.g. `a0b1c2d3`).
24+
There are three environment variables that change this behaviour.
25+
26+
- `MXNET_HOME`: If you already have a pre-installed version of mxnet,
27+
you can use `MXNET_HOME` to point the build-process in the right direction.
28+
29+
- `CUDA_HOME`: If the automatic cuda detection fails,
30+
you can also set `CUDA_HOME` to override the process.
31+
32+
```julia
33+
ENV["CUDA_HOME"] = "/usr/mycuda"
34+
Pkg.build("MXNet")
35+
```
36+
37+
- `MXNET_COMMIT`: To control which version of libmxnet will be compiled,
38+
you can use the `MXNET_COMMIT` variable to point to either a version tag
39+
(e.g. `v0.10.0`), a branch name (e.g. `master`) or a specific commit hash
40+
(e.g. `a0b1c2d3`).
41+
42+
```julia
43+
ENV["MXNET_COMMIT"] = "master"
44+
Pkg.build("MXNet")
45+
```
3146

3247
The libmxnet source is downloaded to `Pkg.dir("MXNet", "deps", "src", "mxnet")`.
33-
The automatic build is using default configurations, with OpenCV disabled.
34-
If the compilation failed due to unresolved dependency, or if
35-
you want to customize the build, you can compile and
36-
install libmxnet manually. Please see below for more details.
48+
The automatic build will try to detect optional dependencies, including
49+
50+
- [CUDA](https://developer.nvidia.com/cuda-toolkit) 8.0
51+
52+
- [CuDNN](https://developer.nvidia.com/cudnn)
53+
54+
- [OpenCV](https://opencv.org/)
55+
56+
If the compilation failed due to unresolved dependency,
57+
or if you want to customize the build,
58+
you can compile and install libmxnet manually.
59+
Please see below for more details.
3760

3861
Manual Compilation
3962
------------------

0 commit comments

Comments
 (0)