mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Make dlib/__init__.py know the paths to cuda that cmake used. Use those
paths instead of relying on CUDA_PATH to be set.
This commit is contained in:
parent
1515adc744
commit
2a3cb83afc
@ -71,3 +71,4 @@ endif()
|
||||
pybind11_add_module(_dlib_pybind11 ${python_srcs})
|
||||
target_link_libraries(_dlib_pybind11 PRIVATE dlib::dlib)
|
||||
|
||||
configure_file(${PROJECT_SOURCE_DIR}/dlib/__init__.py.in ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/dlib/__init__.py)
|
||||
|
@ -1,13 +0,0 @@
|
||||
# Copyright (C) 2020 Davis E. King (davis@dlib.net)
|
||||
# License: Boost Software License See LICENSE.txt for the full license.
|
||||
|
||||
try:
|
||||
import os
|
||||
# On windows you must call os.add_dll_directory() to allow linking to external DLLs. See
|
||||
# https://docs.python.org/3.8/whatsnew/3.8.html#bpo-36085-whatsnew.
|
||||
os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin'))
|
||||
except (AttributeError,KeyError):
|
||||
pass
|
||||
|
||||
from _dlib_pybind11 import *
|
||||
from _dlib_pybind11 import __version__, __time_compiled__
|
20
tools/python/dlib/__init__.py.in
Normal file
20
tools/python/dlib/__init__.py.in
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright (C) 2020 Davis E. King (davis@dlib.net)
|
||||
# License: Boost Software License See LICENSE.txt for the full license.
|
||||
|
||||
def add_lib_to_dll_path(path):
|
||||
""" On windows you must call os.add_dll_directory() to allow linking to external DLLs. See
|
||||
https://docs.python.org/3.8/whatsnew/3.8.html#bpo-36085-whatsnew. This function adds the folder
|
||||
containing path to the dll search path.
|
||||
"""
|
||||
try:
|
||||
import os
|
||||
os.add_dll_directory(os.path.dirname(path))
|
||||
except (AttributeError,KeyError):
|
||||
pass
|
||||
|
||||
if '@DLIB_USE_CUDA@' == 'ON':
|
||||
add_lib_to_dll_path('@cudnn@')
|
||||
add_lib_to_dll_path('@CUDA_CUDART_LIBRARY@')
|
||||
|
||||
from _dlib_pybind11 import *
|
||||
from _dlib_pybind11 import __version__, __time_compiled__
|
Loading…
Reference in New Issue
Block a user