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
change
sglang
Commits
a77564e0
"vscode:/vscode.git/clone" did not exist on "1e651ca2c9f12bdcc5d63da8830847706e186f22"
Unverified
Commit
a77564e0
authored
Sep 17, 2025
by
EduardDurech
Committed by
GitHub
Sep 16, 2025
Browse files
CUDA Arch Independent (#8813)
parent
4f9e71df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
4 deletions
+36
-4
sgl-kernel/python/sgl_kernel/__init__.py
sgl-kernel/python/sgl_kernel/__init__.py
+36
-4
No files found.
sgl-kernel/python/sgl_kernel/__init__.py
100755 → 100644
View file @
a77564e0
import
ctypes
import
ctypes
import
os
import
os
import
platform
import
platform
import
shutil
from
pathlib
import
Path
import
torch
import
torch
SYSTEM_ARCH
=
platform
.
machine
()
cuda_path
=
f
"/usr/local/cuda/targets/
{
SYSTEM_ARCH
}
-linux/lib/libcudart.so.12"
# copy & modify from torch/utils/cpp_extension.py
if
os
.
path
.
exists
(
cuda_path
):
def
_find_cuda_home
():
ctypes
.
CDLL
(
cuda_path
,
mode
=
ctypes
.
RTLD_GLOBAL
)
"""Find the CUDA install path."""
# Guess #1
cuda_home
=
os
.
environ
.
get
(
"CUDA_HOME"
)
or
os
.
environ
.
get
(
"CUDA_PATH"
)
if
cuda_home
is
None
:
# Guess #2
nvcc_path
=
shutil
.
which
(
"nvcc"
)
if
nvcc_path
is
not
None
:
cuda_home
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
nvcc_path
))
else
:
# Guess #3
cuda_home
=
"/usr/local/cuda"
return
cuda_home
if
torch
.
version
.
hip
is
None
:
cuda_home
=
Path
(
_find_cuda_home
())
if
(
cuda_home
/
"lib"
).
is_dir
():
cuda_path
=
cuda_home
/
"lib"
elif
(
cuda_home
/
"lib64"
).
is_dir
():
cuda_path
=
cuda_home
/
"lib64"
else
:
# Search for 'libcudart.so.12' in subdirectories
for
path
in
cuda_home
.
rglob
(
"libcudart.so.12"
):
cuda_path
=
path
.
parent
break
else
:
raise
RuntimeError
(
"Could not find CUDA lib directory."
)
cuda_include
=
(
cuda_path
/
"libcudart.so.12"
).
resolve
()
if
cuda_include
.
exists
():
ctypes
.
CDLL
(
str
(
cuda_include
),
mode
=
ctypes
.
RTLD_GLOBAL
)
from
sgl_kernel
import
common_ops
from
sgl_kernel
import
common_ops
from
sgl_kernel.allreduce
import
*
from
sgl_kernel.allreduce
import
*
...
...
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