compile cuda_ops.so for cuda10.1
Signed-off-by: zhoufeng <zhoufeng54@huawei.com>
This commit is contained in:
parent
81e98d3f82
commit
5b5cb2fcf8
|
@ -184,9 +184,10 @@ if(ENABLE_GPU)
|
|||
endif()
|
||||
endif()
|
||||
install(
|
||||
TARGETS cuda_ops
|
||||
TARGETS cuda_ops LIBRARY
|
||||
DESTINATION ${INSTALL_PLUGIN_DIR}/gpu${CUDA_VERSION}
|
||||
COMPONENT mindspore
|
||||
NAMELINK_SKIP
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -89,9 +89,10 @@ if(ENABLE_GPU)
|
|||
endif()
|
||||
endif()
|
||||
install(
|
||||
TARGETS cuda_ops
|
||||
TARGETS cuda_ops LIBRARY
|
||||
DESTINATION ${INSTALL_PLUGIN_DIR}/gpu${CUDA_VERSION}
|
||||
COMPONENT mindspore
|
||||
NAMELINK_SKIP
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -117,7 +118,7 @@ if(ENABLE_SYM_FILE)
|
|||
install(CODE "\
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -DMS_PACK_ROOT_DIR=${CPACK_PACKAGE_DIRECTORY} \
|
||||
-DMS_INSTALL_DIR=${CPACK_PACKAGE_DIRECTORY}/_CPack_Packages/${CMAKE_HOST_SYSTEM_NAME}/${CPACK_GENERATOR} \
|
||||
-DMS_PACKAGE_FILE_NAME=${CPACK_PACKAGE_FILE_NAME} -P${CMAKE_SOURCE_DIR}/cmake/plugin_debuginfo_script.cmake)"
|
||||
-DMS_PACKAGE_FILE_NAME=${CPACK_PACKAGE_FILE_NAME} -P ${CMAKE_SOURCE_DIR}/cmake/plugin_debuginfo_script.cmake)"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -59,18 +59,16 @@ function(set_nvcc_flag CUDA_NVCC_FLAGS)
|
|||
list(APPEND cuda_archs_bin ${arch_bin})
|
||||
endforeach()
|
||||
else()
|
||||
message("Failed to detect gpu arch automatically, build a base arch 5.3.")
|
||||
list(APPEND CUDA_NVCC_FLAGS -arch=sm_53)
|
||||
message("Failed to detect gpu arch automatically, build a base arch 6.0.")
|
||||
list(APPEND CUDA_NVCC_FLAGS -arch=sm_60)
|
||||
endif()
|
||||
# Get build flag from env to choose common/auto build.
|
||||
set(NVCC_ARCH_FLAG_FROM_ENV $ENV{CUDA_ARCH})
|
||||
if(NVCC_ARCH_FLAG_FROM_ENV STREQUAL "common")
|
||||
message("Build common archs for release.")
|
||||
list(APPEND CUDA_NVCC_FLAGS -gencode=arch=compute_53,code=sm_53
|
||||
-gencode=arch=compute_60,code=sm_60
|
||||
list(APPEND CUDA_NVCC_FLAGS -gencode=arch=compute_60,code=sm_60
|
||||
-gencode=arch=compute_61,code=sm_61
|
||||
-gencode=arch=compute_70,code=sm_70
|
||||
-gencode=arch=compute_72,code=sm_72)
|
||||
-gencode=arch=compute_70,code=sm_70)
|
||||
if(${CUDA_VERSION} VERSION_GREATER "9.5")
|
||||
list(APPEND CUDA_NVCC_FLAGS -gencode=arch=compute_75,code=sm_75)
|
||||
if(${CUDA_VERSION} VERSION_LESS "11.0")
|
||||
|
@ -93,9 +91,9 @@ function(set_nvcc_flag CUDA_NVCC_FLAGS)
|
|||
foreach(arch ${cuda_archs_bin})
|
||||
list(APPEND CUDA_NVCC_FLAGS -gencode=arch=compute_${arch},code=sm_${arch})
|
||||
endforeach()
|
||||
# For auto build, it only generate the code for indeed arch, so add sm_53 as a default arch
|
||||
# For auto build, it only generate the code for indeed arch, so add sm_60 as a default arch
|
||||
# to avoid error in different archs. It may increase the compilation time.
|
||||
list(APPEND CUDA_NVCC_FLAGS -arch=sm_53)
|
||||
list(APPEND CUDA_NVCC_FLAGS -arch=sm_60)
|
||||
endif()
|
||||
list(REMOVE_DUPLICATES CUDA_NVCC_FLAGS)
|
||||
message("Final CUDA_NVCC_FLASG " ${CUDA_NVCC_FLAGS})
|
||||
|
|
|
@ -34,6 +34,9 @@ if(ENABLE_GPU)
|
|||
target_compile_options(cuda_common_obj PRIVATE "/std:c++17")
|
||||
endif()
|
||||
cuda_add_library(cuda_ops SHARED ${CUDA_OPS_SRC_LIST} $<TARGET_OBJECTS:cuda_common_obj>)
|
||||
if(NOT BUILD_LITE)
|
||||
set_target_properties(cuda_ops PROPERTIES SOVERSION ${CUDA_VERSION_MAJOR})
|
||||
endif()
|
||||
if(NOT MSVC)
|
||||
target_link_options(cuda_ops PRIVATE "-Wl,--allow-shlib-undefined")
|
||||
else()
|
||||
|
|
|
@ -28,6 +28,7 @@ for whl in "$@"; do
|
|||
done
|
||||
|
||||
MAX_GPU_VERSION=0
|
||||
declare -A GPU_VERSION_MAP
|
||||
for ((i=1;i<$counter;i=$i+1))
|
||||
do
|
||||
echo "Rename $i dirname to mindspore ..."
|
||||
|
@ -50,18 +51,32 @@ do
|
|||
fi;
|
||||
CUR_GPU_VERSION=`find "./$i/mindspore/lib/plugin" -name 'gpu*' -exec sh -c 'echo ${0##*gpu}' {} \;`
|
||||
if [ -n "$CUR_GPU_VERSION" ]; then
|
||||
GPU_VERSION_MAP[$CUR_GPU_VERSION]=$i
|
||||
else
|
||||
rm -rf $i
|
||||
fi;
|
||||
done
|
||||
|
||||
for key in $(for x in "${!GPU_VERSION_MAP[@]}"; do echo $x; done | sort)
|
||||
do
|
||||
i=${GPU_VERSION_MAP[$key]}
|
||||
CUR_GPU_VERSION=$key
|
||||
CUDA_OPS_FILE=`basename ./$i/mindspore/lib/plugin/gpu$CUR_GPU_VERSION/libcuda_ops.so*`
|
||||
if [ "`echo "$CUR_GPU_VERSION > $MAX_GPU_VERSION" | bc`" -eq 1 ]; then
|
||||
if [ "`echo "$CUR_GPU_VERSION > $MAX_GPU_VERSION" | bc`" -eq 1 ]; then
|
||||
MAX_GPU_VERSION=$CUR_GPU_VERSION
|
||||
fi;
|
||||
if [ ! -d "$BASE_PACKAGE_UNZIP_DIR/mindspore/lib/plugin/gpu" ]; then
|
||||
mkdir -p $BASE_PACKAGE_UNZIP_DIR/mindspore/lib/plugin/gpu
|
||||
fi;
|
||||
\cp -rf ./$i/mindspore/lib/plugin/gpu$CUR_GPU_VERSION/libcuda_ops.so $BASE_PACKAGE_UNZIP_DIR/mindspore/lib/plugin/gpu
|
||||
fi;
|
||||
rm -f $BASE_PACKAGE_UNZIP_DIR/mindspore/lib/plugin/gpu$CUR_GPU_VERSION/libcuda_ops.so
|
||||
\cp -rf ./$i/mindspore/lib/plugin/gpu$CUR_GPU_VERSION/$CUDA_OPS_FILE \
|
||||
$BASE_PACKAGE_UNZIP_DIR/mindspore/lib/plugin/gpu/$CUDA_OPS_FILE
|
||||
fi;
|
||||
rm -f $BASE_PACKAGE_UNZIP_DIR/mindspore/lib/plugin/gpu$CUR_GPU_VERSION/libcuda_ops.so*
|
||||
rm -rf $i
|
||||
done
|
||||
|
||||
|
||||
export COMMIT_ID=`cat $BASE_PACKAGE_UNZIP_DIR/mindspore/.commit_id | awk '{print $3}' | sed $'s/\'//g'`
|
||||
VERSION=`cat $BASE_PACKAGE_UNZIP_DIR/mindspore/version.py | awk '{print $3}' | sed $'s/\'//g'`
|
||||
echo -n "$VERSION" > $MINDSPORE_ROOT_PATH/version.txt
|
||||
|
|
Loading…
Reference in New Issue