Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Megatron-LM
Commits
54ded172
Commit
54ded172
authored
Oct 07, 2020
by
Jared Casper
Browse files
Create build directory for fused_kernels before building.
parent
56e16cba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
megatron/fused_kernels/__init__.py
megatron/fused_kernels/__init__.py
+21
-7
No files found.
megatron/fused_kernels/__init__.py
View file @
54ded172
...
@@ -26,7 +26,7 @@ from torch.utils import cpp_extension
...
@@ -26,7 +26,7 @@ from torch.utils import cpp_extension
os
.
environ
[
"TORCH_CUDA_ARCH_LIST"
]
=
""
os
.
environ
[
"TORCH_CUDA_ARCH_LIST"
]
=
""
def
get_cuda_bare_metal_version
(
cuda_dir
):
def
get_cuda_bare_metal_version
(
cuda_dir
):
raw_output
=
subprocess
.
check_output
([
cuda_dir
+
"/bin/nvcc"
,
"-V"
],
raw_output
=
subprocess
.
check_output
([
cuda_dir
+
"/bin/nvcc"
,
"-V"
],
universal_newlines
=
True
)
universal_newlines
=
True
)
output
=
raw_output
.
split
()
output
=
raw_output
.
split
()
release_idx
=
output
.
index
(
"release"
)
+
1
release_idx
=
output
.
index
(
"release"
)
+
1
...
@@ -36,6 +36,12 @@ def get_cuda_bare_metal_version(cuda_dir):
...
@@ -36,6 +36,12 @@ def get_cuda_bare_metal_version(cuda_dir):
return
raw_output
,
bare_metal_major
,
bare_metal_minor
return
raw_output
,
bare_metal_major
,
bare_metal_minor
def
create_build_dir
(
buildpath
):
try
:
os
.
mkdir
(
buildpath
)
except
OSError
:
if
not
os
.
path
.
isdir
(
buildpath
):
print
(
f
"Creation of the build directory
{
buildpath
}
failed"
)
def
load_scaled_upper_triang_masked_softmax_fusion_kernel
():
def
load_scaled_upper_triang_masked_softmax_fusion_kernel
():
...
@@ -47,11 +53,15 @@ def load_scaled_upper_triang_masked_softmax_fusion_kernel():
...
@@ -47,11 +53,15 @@ def load_scaled_upper_triang_masked_softmax_fusion_kernel():
cc_flag
.
append
(
'arch=compute_80,code=sm_80'
)
cc_flag
.
append
(
'arch=compute_80,code=sm_80'
)
srcpath
=
pathlib
.
Path
(
__file__
).
parent
.
absolute
()
srcpath
=
pathlib
.
Path
(
__file__
).
parent
.
absolute
()
buildpath
=
srcpath
/
'build'
create_build_dir
(
buildpath
)
scaled_upper_triang_masked_softmax_cuda
=
cpp_extension
.
load
(
scaled_upper_triang_masked_softmax_cuda
=
cpp_extension
.
load
(
name
=
'scaled_upper_triang_masked_softmax_cuda'
,
name
=
'scaled_upper_triang_masked_softmax_cuda'
,
sources
=
[
srcpath
/
'scaled_upper_triang_masked_softmax.cpp'
,
sources
=
[
srcpath
/
'scaled_upper_triang_masked_softmax.cpp'
,
srcpath
/
'scaled_upper_triang_masked_softmax_cuda.cu'
],
srcpath
/
'scaled_upper_triang_masked_softmax_cuda.cu'
],
build_directory
=
srcpath
/
'
build
'
,
build_directory
=
build
path
,
extra_cflags
=
[
'-O3'
,],
extra_cflags
=
[
'-O3'
,],
extra_cuda_cflags
=
[
'-O3'
,
extra_cuda_cflags
=
[
'-O3'
,
'-gencode'
,
'arch=compute_70,code=sm_70'
,
'-gencode'
,
'arch=compute_70,code=sm_70'
,
...
@@ -72,11 +82,15 @@ def load_scaled_masked_softmax_fusion_kernel():
...
@@ -72,11 +82,15 @@ def load_scaled_masked_softmax_fusion_kernel():
cc_flag
.
append
(
'arch=compute_80,code=sm_80'
)
cc_flag
.
append
(
'arch=compute_80,code=sm_80'
)
srcpath
=
pathlib
.
Path
(
__file__
).
parent
.
absolute
()
srcpath
=
pathlib
.
Path
(
__file__
).
parent
.
absolute
()
buildpath
=
srcpath
/
'build'
create_build_dir
(
buildpath
)
scaled_upper_triang_masked_softmax_cuda
=
cpp_extension
.
load
(
scaled_upper_triang_masked_softmax_cuda
=
cpp_extension
.
load
(
name
=
'scaled_masked_softmax_cuda'
,
name
=
'scaled_masked_softmax_cuda'
,
sources
=
[
srcpath
/
'scaled_masked_softmax.cpp'
,
sources
=
[
srcpath
/
'scaled_masked_softmax.cpp'
,
srcpath
/
'scaled_masked_softmax_cuda.cu'
],
srcpath
/
'scaled_masked_softmax_cuda.cu'
],
build_directory
=
srcpath
/
'
build
'
,
build_directory
=
build
path
,
extra_cflags
=
[
'-O3'
,],
extra_cflags
=
[
'-O3'
,],
extra_cuda_cflags
=
[
'-O3'
,
extra_cuda_cflags
=
[
'-O3'
,
'-gencode'
,
'arch=compute_70,code=sm_70'
,
'-gencode'
,
'arch=compute_70,code=sm_70'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment