Skip to content

Commit

Permalink
build: opencv auto detection
Browse files Browse the repository at this point in the history
  • Loading branch information
iblislin committed Nov 25, 2017
1 parent f126482 commit dbc059e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 12 deletions.
12 changes: 11 additions & 1 deletion deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ else
info("Did not find a CUDA installation, using CPU-only version of MXNet.")
end

# try to find opencv
HAS_OPENCV = false
let libopencv_core = Libdl.find_library("libopencv_core")
HAS_OPENCV = !isempty(libopencv_core) && Libdl.dlopen_e(libopencv_core) != C_NULL
end

info("Build with OpenCV: $(HAS_OPENCV)")

function get_cpucore()
if haskey(ENV, "TRAVIS") # on travis-ci
2
Expand Down Expand Up @@ -188,7 +196,9 @@ if !libmxnet_detected
end

# Configure OpenCV
`sed -i -s 's/USE_OPENCV = 1/USE_OPENCV = 0/' config.mk`
if !HAS_OPENCV
`sed -i -s 's/USE_OPENCV = 1/USE_OPENCV = 0/' config.mk`
end

# Configure CUDA
if HAS_CUDA
Expand Down
45 changes: 34 additions & 11 deletions docs/src/user-guide/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,42 @@ MXNet.jl is built on top of [libmxnet](https://github.com/dmlc/mxnet).
Upon installation, Julia will try to automatically download and build
libmxnet.

There are three environment variables that change this behaviour. If you
already have a pre-installed version of mxnet you can use `MXNET_HOME`
to point the build-process in the right direction. If the automatic
cuda detection fails you can also set `CUDA_HOME` to override the process.
To control which version of libmxnet will be compiled, you can use the
`MXNET_COMMIT` variable to point to either a version tag (e.g. `v0.10.0`), a
branch name (e.g. `master`) or a specific commit hash (e.g. `a0b1c2d3`).
There are three environment variables that change this behaviour.

- `MXNET_HOME`: If you already have a pre-installed version of mxnet,
you can use `MXNET_HOME` to point the build-process in the right direction.

- `CUDA_HOME`: If the automatic cuda detection fails,
you can also set `CUDA_HOME` to override the process.

```julia
ENV["CUDA_HOME"] = "/usr/mycuda"
Pkg.build("MXNet")
```

- `MXNET_COMMIT`: To control which version of libmxnet will be compiled,
you can use the `MXNET_COMMIT` variable to point to either a version tag
(e.g. `v0.10.0`), a branch name (e.g. `master`) or a specific commit hash
(e.g. `a0b1c2d3`).

```julia
ENV["MXNET_COMMIT"] = "master"
Pkg.build("MXNet")
```

The libmxnet source is downloaded to `Pkg.dir("MXNet", "deps", "src", "mxnet")`.
The automatic build is using default configurations, with OpenCV disabled.
If the compilation failed due to unresolved dependency, or if
you want to customize the build, you can compile and
install libmxnet manually. Please see below for more details.
The automatic build will try to detect optional dependencies, including

- [CUDA](https://developer.nvidia.com/cuda-toolkit) 8.0

- [CuDNN](https://developer.nvidia.com/cudnn)

- [OpenCV](https://opencv.org/)

If the compilation failed due to unresolved dependency,
or if you want to customize the build,
you can compile and install libmxnet manually.
Please see below for more details.

Manual Compilation
------------------
Expand Down

0 comments on commit dbc059e

Please sign in to comment.