Skip to content

Commit

Permalink
[bugfix] Link against pytorch library by name rather than path (attem…
Browse files Browse the repository at this point in the history
…pting to fix linking issue). (dmlc#3246)

* Use library name

* fix for mac builds from source

Co-authored-by: Quan (Andy) Gan <[email protected]>
  • Loading branch information
nv-dlasalle and BarclayII authored Aug 19, 2021
1 parent ea06688 commit fc6f0b9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions tensoradapter/pytorch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ set(TORCH_TARGET_NAME "tensoradapter_pytorch_${TORCH_VER}")
file(GLOB TA_TORCH_SRC *.cpp)
add_library(${TORCH_TARGET_NAME} SHARED "${TA_TORCH_SRC}")

if (MSVC)
# Linking on windows requires all libraries
set(TENSORADAPTER_TORCH_LIBS ${TORCH_LIBRARIES})
else()
set(TENSORADAPTER_TORCH_LIBS ${TORCH_LIBRARY})
endif(MSVC)
# use the library name rather than the path
set(TENSORADAPTER_TORCH_LIBS torch)

message(STATUS "tensoradapter found PyTorch includes: ${TORCH_INCLUDE_DIRS}")
message(STATUS "tensoradapter found PyTorch lib: ${TENSORADAPTER_TORCH_LIBS}")
Expand Down
2 changes: 1 addition & 1 deletion tensoradapter/pytorch/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CMAKE_FLAGS="-DCUDA_TOOLKIT_ROOT_DIR=$CUDA_TOOLKIT_ROOT_DIR -DTORCH_CUDA_ARCH_LI
if [ $# -eq 0 ]; then
$CMAKE_COMMAND $CMAKE_FLAGS ..
make -j
cp -v *.so $BINDIR/tensoradapter/pytorch
cp -v $CPSOURCE $BINDIR/tensoradapter/pytorch
else
for PYTHON_INTERP in $@; do
rm -rf *
Expand Down

0 comments on commit fc6f0b9

Please sign in to comment.