Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: build: opencv auto detection #344

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions 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 @@ -139,7 +147,7 @@ if !libmxnet_detected
USE_JULIA_BLAS = true
FORCE_LAPACK = true
end
info("USE_JULIA_BLAS -> $USE_JULIA_BLAS")
info("Build with Julia's BLAS lib -> $USE_JULIA_BLAS")

blas_name = blas_vendor == :openblas64 ? "openblas" : string(blas_vendor)
MSHADOW_LDFLAGS = "MSHADOW_LDFLAGS=-lm $blas_path"
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:/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