Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
@echo off
REM Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
REM
REM Licensed under the Apache License, Version 2.0 (the "License");
REM you may not use this file except in compliance with the License.
REM You may obtain a copy of the License at
REM
REM http://www.apache.org/licenses/LICENSE-2.0
REM
REM Unless required by applicable law or agreed to in writing, software
REM distributed under the License is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.

REM FastDeploy Windows build script
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 缺少关键环境变量传递

build.bat 调用 setup_ops.py install 时没有传递 FD_BUILDING_ARCSFD_CPU_USE_BF16 环境变量。与 build.sh 不一致,Windows 用户无法自定义 CUDA 架构或启用 CPU BF16。

建议添加类似 build.sh 的环境变量支持。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 缺少 Python 版本检查

build.sh 有 Python 版本检查(确保 >= 3.9),build.bat 缺少此检查。

建议添加版本验证以避免兼容性问题。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 缺少帮助信息

build.sh 有完整的 show_help() 函数,build.bat 只有简单的头部注释。

建议添加 /?-h 支持,输出详细的参数说明和示例。

REM Usage: build.bat [BUILD_MODE] [PYTHON]
REM BUILD_MODE: 0 = build custom ops only, 1 = full build (default)
REM PYTHON: Python executable (default: python)
REM
REM Requires: Visual Studio Build Tools, CUDA Toolkit, Python 3.10+
REM Run from a Developer Command Prompt or ensure cl.exe is on PATH.

setlocal enabledelayedexpansion

set BUILD_MODE=%~1
if "%BUILD_MODE%"=="" set BUILD_MODE=1

set PYTHON=%~2
if "%PYTHON%"=="" set PYTHON=python

echo ============================================
echo FastDeploy Windows Build
echo Mode: %BUILD_MODE% (0=ops only, 1=full)
echo Python: %PYTHON%
echo ============================================

REM Step 1: Build custom ops
echo.
echo [1] Building custom ops...
pushd custom_ops
%PYTHON% setup_ops.py install
if !ERRORLEVEL! neq 0 (
echo [FAIL] Custom ops build failed.
popd
exit /b 1
)
popd
echo [OK] Custom ops built successfully.

if "%BUILD_MODE%"=="0" (
echo.
echo Build complete (ops only).
exit /b 0
)

REM Step 2: Build and install FastDeploy wheel
echo.
echo [2] Building FastDeploy wheel...
%PYTHON% setup.py bdist_wheel
if !ERRORLEVEL! neq 0 (
echo [FAIL] Wheel build failed.
exit /b 1
)

echo [3] Installing FastDeploy wheel...
for %%w in (dist\fastdeploy*.whl) do (
%PYTHON% -m pip install "%%w"
if !ERRORLEVEL! neq 0 (
echo [FAIL] pip install failed for %%w
exit /b 1
)
)

echo.
echo Build complete.
exit /b 0
10 changes: 8 additions & 2 deletions custom_ops/setup_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,13 +562,19 @@ def find_end_files(directory, end_str):
# appended explicitly for SM75 and also discovered by later directory globs.
sources = list(dict.fromkeys(sources))

cuda_libraries = ["cublasLt"]
if sys.platform == "win32":
cuda_link_args = ["/DEFAULTLIB:cuda.lib", "/DEFAULTLIB:nvml.lib"]
else:
cuda_link_args = ["-lcuda", "-lnvidia-ml"]

setup(
name="fastdeploy_ops",
ext_modules=CUDAExtension(
sources=sources,
extra_compile_args={"cxx": cc_compile_args, "nvcc": nvcc_compile_args},
libraries=["cublasLt"],
extra_link_args=["-lcuda", "-lnvidia-ml"],
libraries=cuda_libraries,
extra_link_args=cuda_link_args,
),
packages=find_packages(where="third_party/DeepGEMM"),
package_dir={"": "third_party/DeepGEMM"},
Expand Down
Loading