Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build issues on Windows #2428

Merged
merged 5 commits into from
Oct 26, 2022
Merged
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
19 changes: 19 additions & 0 deletions build_win.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo off

set DS_BUILD_AIO=0
set DS_BUILD_SPARSE_ATTN=0

echo Administrative permissions required. Detecting permissions...

net session >nul 2>&1
if %errorLevel% == 0 (
echo Success: Administrative permissions confirmed.
) else (
echo Failure: Current permissions inadequate.
goto end
)


python setup.py bdist_wheel

:end
2 changes: 1 addition & 1 deletion csrc/transformer/inference/includes/inference_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Context {
void* GetWorkSpace() { return _workspace; }
void* GetAttentionUnfusedWorkspace()
{
return _workspace + _attention_unfused_workspace_offset;
return (char*)_workspace + _attention_unfused_workspace_offset;
}

inline unsigned new_token(unsigned layer_id)
Expand Down
1 change: 1 addition & 0 deletions op_builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ def nvcc_args(self):
else:
cuda_major, _ = installed_cuda_version()
args += [
'-allow-unsupported-compiler' if sys.platform == "win32" else '',
'--use_fast_math',
'-std=c++17'
if sys.platform == "win32" and cuda_major > 10 else '-std=c++14',
Expand Down
9 changes: 7 additions & 2 deletions op_builder/fused_adam.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""
from .builder import CUDAOpBuilder

import sys


class FusedAdamBuilder(CUDAOpBuilder):
BUILD_VAR = "DS_BUILD_FUSED_ADAM"
Expand All @@ -27,6 +29,9 @@ def cxx_args(self):
def nvcc_args(self):
nvcc_flags = ['-O3'] + self.version_dependent_macros()
if not self.is_rocm_pytorch():
nvcc_flags.extend(['-lineinfo',
'--use_fast_math'] + self.compute_capability_args())
nvcc_flags.extend([
'-allow-unsupported-compiler' if sys.platform == "win32" else '',
'-lineinfo',
'--use_fast_math'
] + self.compute_capability_args())
return nvcc_flags
9 changes: 7 additions & 2 deletions op_builder/fused_lamb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""
from .builder import CUDAOpBuilder

import sys


class FusedLambBuilder(CUDAOpBuilder):
BUILD_VAR = 'DS_BUILD_FUSED_LAMB'
Expand Down Expand Up @@ -33,6 +35,9 @@ def nvcc_args(self):
'-DROCM_VERSION_MINOR=%s' % ROCM_MINOR
]
else:
nvcc_flags.extend(['-lineinfo',
'--use_fast_math'] + self.compute_capability_args())
nvcc_flags.extend([
'-allow-unsupported-compiler' if sys.platform == "win32" else '',
'-lineinfo',
'--use_fast_math'
] + self.compute_capability_args())
return nvcc_flags
18 changes: 10 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
DeepSpeed library

To build wheel on Windows:
1. Install pytorch, such as pytorch 1.8 + cuda 11.1
1. Install pytorch, such as pytorch 1.12 + cuda 11.6
2. Install visual cpp build tool
3. Launch cmd console with Administrator privilege for creating required symlink folders
3. Include cuda toolkit
4. Launch cmd console with Administrator privilege for creating required symlink folders

Create a new wheel via the following command:
python setup.py bdist_wheel
build_win.bat

The wheel will be located at: dist/*.whl
"""
Expand Down Expand Up @@ -224,11 +225,12 @@ def create_dir_symlink(src, dest):
hip_version = "0.0"
if torch_available and torch.version.cuda is not None:
cuda_version = ".".join(torch.version.cuda.split('.')[:2])
if isinstance(torch.cuda.nccl.version(), int):
# This will break if minor version > 9
nccl_version = ".".join(str(torch.cuda.nccl.version())[:2])
else:
nccl_version = ".".join(map(str, torch.cuda.nccl.version()[:2]))
if sys.platform != "win32":
if isinstance(torch.cuda.nccl.version(), int):
# This will break if minor version > 9
nccl_version = ".".join(str(torch.cuda.nccl.version())[:2])
else:
nccl_version = ".".join(map(str, torch.cuda.nccl.version()[:2]))
if hasattr(torch.cuda, 'is_bf16_supported') and torch.cuda.is_available():
bf16_support = torch.cuda.is_bf16_supported()
if torch_available and hasattr(torch.version, 'hip') and torch.version.hip is not None:
Expand Down