Skip to content

Commit 6b72436

Browse files
author
Thiago Crepaldi
committed
Adds CNTK libs folder to LD_LIBRARY_PATH at CNTK init routine on Python
1 parent b8edaab commit 6b72436

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

bindings/python/cntk/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
import os
77
os.environ["PATH"] += os.pathsep + os.path.join(os.path.dirname(__file__), 'libs')
8+
cntk_library_path=os.pathsep + os.path.join(os.path.dirname(__file__), 'libs')
9+
if os.environ.get('LD_LIBRARY_PATH'):
10+
os.environ['LD_LIBRARY_PATH'] += cntk_library_path
11+
else:
12+
os.environ['LD_LIBRARY_PATH'] = cntk_library_path
813

914
# Read version information
1015
version_file = open(os.path.join(os.path.dirname(__file__), 'VERSION'), 'r')

bindings/python/cntk/cntk_py_init.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@ def cntk_check_libs():
8585
if call(['where', 'opencv_world*.dll'], stdout=devnull, stderr=devnull) != 0:
8686
warnings.warn(WARNING_MSG % (' OpenCV ', 'https://docs.microsoft.com/en-us/cognitive-toolkit/Setup-Windows-Python#optional-opencv'))
8787
elif __my_system__ == 'linux':
88-
if call('ldconfig -p | grep libmklml_intel*.so*', shell=True, stdout=devnull, stderr=devnull) != 0 or \
89-
call('ldconfig -p | grep libiomp5*.so*', shell=True, stdout=devnull, stderr=devnull) != 0:
88+
if call('ldconfig -N -v $(sed "s/:/ /g" <<< $LD_LIBRARY_PATH) | grep libmklml_intel*.so*', shell=True, executable='/bin/bash', stdout=devnull, stderr=devnull) != 0 or \
89+
call('ldconfig -N -v $(sed "s/:/ /g" <<< $LD_LIBRARY_PATH) | grep libiomp5*.so*', shell=True, executable='/bin/bash', stdout=devnull, stderr=devnull) != 0:
9090
warnings.warn(WARNING_MSG % (' MKL ', 'https://docs.microsoft.com/en-us/cognitive-toolkit/Setup-Linux-Python#mkl'))
91-
if call('ldconfig -p | grep libcudart*.so*', shell=True, stdout=devnull, stderr=devnull) != 0 or \
92-
call('ldconfig -p | grep libcublas*.so*', shell=True, stdout=devnull, stderr=devnull) != 0 or \
93-
call('ldconfig -p | grep libcurand*.so*', shell=True, stdout=devnull, stderr=devnull) != 0 or \
94-
call('ldconfig -p | grep libcusparse*.so*', shell=True, stdout=devnull, stderr=devnull) != 0 or \
95-
call('ldconfig -p | grep libcuda*.so*', shell=True, stdout=devnull, stderr=devnull) != 0 or \
96-
call('ldconfig -p | grep libnvidia-ml*.so*', shell=True, stdout=devnull, stderr=devnull) != 0 or \
97-
call('ldconfig -p | grep libcudnn*.so*', shell=True, stdout=devnull, stderr=devnull) != 0:
91+
if call('ldconfig -N -v $(sed "s/:/ /g" <<< $LD_LIBRARY_PATH) | grep libcudart*.so*', shell=True, executable='/bin/bash', stdout=devnull, stderr=devnull) != 0 or \
92+
call('ldconfig -N -v $(sed "s/:/ /g" <<< $LD_LIBRARY_PATH) | grep libcublas*.so*', shell=True, executable='/bin/bash', stdout=devnull, stderr=devnull) != 0 or \
93+
call('ldconfig -N -v $(sed "s/:/ /g" <<< $LD_LIBRARY_PATH) | grep libcurand*.so*', shell=True, executable='/bin/bash', stdout=devnull, stderr=devnull) != 0 or \
94+
call('ldconfig -N -v $(sed "s/:/ /g" <<< $LD_LIBRARY_PATH) | grep libcusparse*.so*', shell=True, executable='/bin/bash', stdout=devnull, stderr=devnull) != 0 or \
95+
call('ldconfig -N -v $(sed "s/:/ /g" <<< $LD_LIBRARY_PATH) | grep libcuda*.so*', shell=True, executable='/bin/bash', stdout=devnull, stderr=devnull) != 0 or \
96+
call('ldconfig -N -v $(sed "s/:/ /g" <<< $LD_LIBRARY_PATH) | grep libnvidia-ml*.so*', shell=True, executable='/bin/bash', stdout=devnull, stderr=devnull) != 0 or \
97+
call('ldconfig -N -v $(sed "s/:/ /g" <<< $LD_LIBRARY_PATH) | grep libcudnn*.so*', shell=True, executable='/bin/bash', stdout=devnull, stderr=devnull) != 0:
9898
warnings.warn(WARNING_MSG_GPU_ONLY % ('GPU-Specific', 'https://docs.microsoft.com/en-us/cognitive-toolkit/Setup-Linux-Python#optional-gpu-specific-packages'))
99-
if call('ldconfig -p | grep libopencv_core*.so*', shell=True, stdout=devnull, stderr=devnull) != 0 or \
100-
call('ldconfig -p | grep libopencv_imgproc*.so*', shell=True, stdout=devnull, stderr=devnull) != 0 or \
101-
call('ldconfig -p | grep libopencv_imgcodecs*.so*', shell=True, stdout=devnull, stderr=devnull) != 0:
99+
if call('ldconfig -N -v $(sed "s/:/ /g" <<< $LD_LIBRARY_PATH) | grep libopencv_core*.so*', shell=True, executable='/bin/bash', stdout=devnull, stderr=devnull) != 0 or \
100+
call('ldconfig -N -v $(sed "s/:/ /g" <<< $LD_LIBRARY_PATH) | grep libopencv_imgproc*.so*', shell=True, executable='/bin/bash', stdout=devnull, stderr=devnull) != 0 or \
101+
call('ldconfig -N -v $(sed "s/:/ /g" <<< $LD_LIBRARY_PATH) | grep libopencv_imgcodecs*.so*', shell=True, executable='/bin/bash', stdout=devnull, stderr=devnull) != 0:
102102
warnings.warn(WARNING_MSG % (' OpenCV ', 'https://docs.microsoft.com/en-us/cognitive-toolkit/Setup-Linux-Python#optional-opencv'))
103103
devnull.close()

0 commit comments

Comments
 (0)