Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
julia: rename build env var MXNET_HOME to MXNET_ROOT
Browse files Browse the repository at this point in the history
- Add MXNET_LIBRARY_PATH support

Ref: #15561
  • Loading branch information
iblislin committed Jul 17, 2019
1 parent 4d07d78 commit aa9d149
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
8 changes: 4 additions & 4 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ unittest_ubuntu_gpu_R() {
unittest_ubuntu_cpu_julia() {
set -ex
export PATH="$1/bin:$PATH"
export MXNET_HOME='/work/mxnet'
export MXNET_ROOT='/work/mxnet'
export JULIA_DEPOT_PATH='/work/julia-depot'
export INTEGRATION_TEST=1

Expand All @@ -1062,7 +1062,7 @@ unittest_ubuntu_cpu_julia() {
export LD_PRELOAD='/usr/lib/x86_64-linux-gnu/libjemalloc.so'
export LD_LIBRARY_PATH=/work/mxnet/lib:$LD_LIBRARY_PATH

# use the prebuilt binary from $MXNET_HOME/lib
# use the prebuilt binary from $MXNET_ROOT/lib
julia --project=./julia -e 'using Pkg; Pkg.build("MXNet")'

# run the script `julia/test/runtests.jl`
Expand Down Expand Up @@ -1213,7 +1213,7 @@ build_docs() {

# Setup environment for Julia docs
export PATH="/work/julia10/bin:$PATH"
export MXNET_HOME='/work/mxnet'
export MXNET_ROOT='/work/mxnet'
export JULIA_DEPOT_PATH='/work/julia-depot'

julia -e 'using InteractiveUtils; versioninfo()'
Expand Down Expand Up @@ -1425,7 +1425,7 @@ deploy_docs() {

# Setup for Julia docs
export PATH="/work/julia10/bin:$PATH"
export MXNET_HOME='/work/mxnet'
export MXNET_ROOT='/work/mxnet'
export JULIA_DEPOT_PATH='/work/julia-depot'

julia -e 'using InteractiveUtils; versioninfo()'
Expand Down
2 changes: 1 addition & 1 deletion ci/windows/test_jl07_cpu.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# set default output encoding to utf8
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'

$env:MXNET_HOME = [System.IO.Path]::GetFullPath('.\windows_package')
$env:MXNET_ROOT = [System.IO.Path]::GetFullPath('.\windows_package')
$env:JULIA_URL = "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7.0-win64.exe"
$env:JULIA_DEPOT_PATH = [System.IO.Path]::GetFullPath('.\julia-depot')

Expand Down
2 changes: 1 addition & 1 deletion ci/windows/test_jl10_cpu.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# set default output encoding to utf8
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'

$env:MXNET_HOME = [System.IO.Path]::GetFullPath('.\windows_package')
$env:MXNET_ROOT = [System.IO.Path]::GetFullPath('.\windows_package')
$env:JULIA_URL = "https://julialang-s3.julialang.org/bin/winnt/x64/1.0/julia-1.0.3-win64.exe"
$env:JULIA_DEPOT_PATH = [System.IO.Path]::GetFullPath('.\julia-depot')

Expand Down
27 changes: 20 additions & 7 deletions julia/deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,27 @@ libmxnet_detected = false
libmxnet_curr_ver = get(ENV, "MXNET_COMMIT", "master")
curr_win = "20180211" # v1.1.0

if haskey(ENV, "MXNET_HOME")
MXNET_HOME = ENV["MXNET_HOME"]
@info("MXNET_HOME environment detected: $MXNET_HOME")
MXNET_ROOT = get(ENV, "MXNET_ROOT", "")
search_locations = if !isempty(MXNET_ROOT)
@info "env var: MXNET_ROOT -> $MXNET_ROOT"
[joinpath(MXNET_ROOT, "lib"), MXNET_ROOT]
else
[]
end

MXNET_LIBRARY_PATH = get(ENV, "MXNET_LIBRARY_PATH", "")
println(typeof(MXNET_LIBRARY_PATH))
# In case of macOS, if user build libmxnet from source and set the MXNET_ROOT,
# the output is still named as `libmxnet.so`.
search_names = ["libmxnet.$(Libdl.dlext)", "libmxnet.so"]
if !isempty(MXNET_LIBRARY_PATH)
@info "env var: MXNET_LIBRARY_PATH -> $MXNET_LIBRARY_PATH"
pushfirst!(search_names, MXNET_LIBRARY_PATH)
end

if (!isempty(MXNET_ROOT)) || (!isempty(MXNET_LIBRARY_PATH))
@info("Trying to load existing libmxnet...")
# In case of macOS, if user build libmxnet from source and set the MXNET_HOME,
# the output is still named as `libmxnet.so`.
lib = Libdl.find_library(["libmxnet.$(Libdl.dlext)", "libmxnet.so"],
[joinpath(MXNET_HOME, "lib"), MXNET_HOME])
lib = Libdl.find_library(search_names, search_locations)
if !isempty(lib)
@info("Existing libmxnet detected at $lib, skip building...")
libmxnet_detected = true
Expand Down
13 changes: 10 additions & 3 deletions julia/src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@ const grad_req_map = Dict{Symbol,GRAD_REQ}(
################################################################################
# Initialization and library API entrance
################################################################################
const MXNET_LIB = Libdl.find_library(["libmxnet.$(Libdl.dlext)", "libmxnet.so"], # see build.jl
[joinpath(get(ENV, "MXNET_HOME", ""), "lib"),
get(ENV, "MXNET_HOME", ""),
function _get_search_names()
MXNET_LIBRARY_PATH = get(ENV, "MXNET_LIBRARY_PATH", "")
A = ["libmxnet.$(Libdl.dlext)", "libmxnet.so"] # see build.jl
!isempty(MXNET_LIBRARY_PATH) && pushfirst!(A, MXNET_LIBRARY_PATH)
A
end

const MXNET_LIB = Libdl.find_library(_get_search_names(),
[joinpath(get(ENV, "MXNET_ROOT", ""), "lib"),
get(ENV, "MXNET_ROOT", ""),
joinpath(@__DIR__, "..",
"deps", "usr", "lib")])
const LIB_VERSION = Ref{Cint}(0)
Expand Down

0 comments on commit aa9d149

Please sign in to comment.