Skip to content

Commit 6de50e6

Browse files
authored
[paddlenlp_ops] update whl (#10576)
* update whl * update
1 parent 2b1efb2 commit 6de50e6

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

csrc/tools/build_wheel.sh

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ function generate_sm_version(){
7272
}
7373

7474
function create_directories(){
75-
mkdir -p $OPS_SRC_DIR/tmp/paddlenlp_ops
76-
touch $OPS_SRC_DIR/tmp/setup.py
77-
touch $OPS_SRC_DIR/tmp/paddlenlp_ops/__init__.py
78-
echo '# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
75+
for sm_version in "${sm_versions[@]}"; do
76+
echo "create sm$sm_version"
77+
mkdir -p $OPS_SRC_DIR/tmp/paddlenlp_ops
78+
touch $OPS_SRC_DIR/tmp/setup.py
79+
touch $OPS_SRC_DIR/tmp/paddlenlp_ops/__init__.py
80+
echo '# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
7981
#
8082
# Licensed under the Apache License, Version 2.0 (the "License");
8183
# you may not use this file except in compliance with the License.
@@ -110,11 +112,6 @@ def read(file: str):
110112
content = f.read().strip()
111113
return content
112114
113-
def get_sm_version():
114-
prop = paddle.device.cuda.get_device_properties()
115-
cc = prop.major * 10 + prop.minor
116-
return cc
117-
118115
def read_version():
119116
"""
120117
read version and return content
@@ -123,7 +120,7 @@ def read_version():
123120
124121
formatted_date = datetime.now().date().strftime("%Y%m%d")
125122
cuda_version = float(paddle.version.cuda())
126-
sm_version = get_sm_version()
123+
sm_version=80
127124
paddle_commit = paddle.__git_commit__[:7]
128125
build_tag = "{}+cuda{}sm{}paddle{}".format(formatted_date, cuda_version, sm_version, paddle_commit)
129126
@@ -195,12 +192,9 @@ try:
195192
except ImportError:
196193
logger.WARNING(f"No {module_name} ")
197194
' > $OPS_SRC_DIR/tmp/paddlenlp_ops/__init__.py
198-
199-
for sm_version in "${sm_versions[@]}"; do
200-
echo "create sm$sm_version"
201-
mkdir -p $OPS_SRC_DIR/tmp/paddlenlp_ops/sm${sm_version}
202-
touch $OPS_SRC_DIR/tmp/paddlenlp_ops/sm${sm_version}/__init__.py
203-
echo '# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
195+
mkdir -p $OPS_SRC_DIR/tmp/paddlenlp_ops/sm${sm_version}
196+
touch $OPS_SRC_DIR/tmp/paddlenlp_ops/sm${sm_version}/__init__.py
197+
echo '# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
204198
#
205199
# Licensed under the Apache License, Version 2.0 (the "License");
206200
# you may not use this file except in compliance with the License.
@@ -221,6 +215,7 @@ try:
221215
except ImportError:
222216
logger.WARNING("No paddlenlp_ops_'${sm_version}' ops")
223217
' > $OPS_SRC_DIR/tmp/paddlenlp_ops/sm${sm_version}/__init__.py
218+
build_ops
224219
done
225220
}
226221

@@ -239,11 +234,11 @@ function init() {
239234
}
240235

241236
function build_ops() {
242-
for sm_version in "${sm_versions[@]}"; do
243-
echo "Building and installing for sm_version: $sm_version"
244-
build_and_install_ops $sm_version
245-
done
246-
return
237+
echo "Building and installing for sm_version: $sm_version"
238+
build_and_install_ops $sm_version
239+
build_and_install_whl
240+
unittest
241+
cleanup
247242
}
248243

249244
function copy_ops(){
@@ -280,6 +275,7 @@ function build_and_install_whl() {
280275
echo -e "${BLUE}[build]${NONE} building paddlenlp_ops wheel..."
281276
rm -rf ./dist
282277
cd ${TMP_DIR}
278+
sed -i "s/sm_version=80/sm_version=${sm_version}/g" setup.py
283279
${python} setup.py bdist_wheel --dist-dir ./$DIST_DIR
284280
if [ $? -ne 0 ]; then
285281
echo -e "${RED}[FAIL]${NONE} build paddlenlp_ops wheel failed !"
@@ -297,7 +293,8 @@ function build_and_install_whl() {
297293
fi
298294
echo -e "${BLUE}[install]${NONE} ${GREEN}paddlenlp_ops install success\n"
299295
cd ..
300-
mv $DIST_DIR ../
296+
mkdir -p ../$DIST_DIR
297+
mv $DIST_DIR/* ../$DIST_DIR/
301298
cd ..
302299
}
303300

@@ -332,10 +329,6 @@ trap 'abort' 0
332329
set -e
333330

334331
init
335-
build_ops
336-
build_and_install_whl
337-
unittest
338-
cleanup
339332

340333
# get Paddle version
341334
PADDLE_VERSION=`${python} -c "import paddle; print(paddle.version.full_version)"`

0 commit comments

Comments
 (0)