Skip to content

Commit 784d9f5

Browse files
committed
Added CUDA support for non-x86_64 platforms
1 parent 6b0ce2a commit 784d9f5

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

M/MLX/MLX_CUDA/build_tarballs.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ for platform in platforms
1919

2020
cuda_deps = CUDA.required_dependencies(platform; static_sdk=true)
2121

22+
# Download the CUDA nvcc redist for the host architecture (x86_64) for non-x86_64-linux-gnu platforms
23+
platform_sources = BinaryBuilder.AbstractSource[sources...]
24+
if !platforms_match(platform, Platform("x86_64", "linux"))
25+
cuda_version = platform["cuda"]
26+
push!(platform_sources, CUDA.cuda_nvcc_redist_source(cuda_version, "x86_64"))
27+
end
28+
2229
build_tarballs(ARGS, name, version, sources, script, [platform], products, [dependencies; cuda_deps];
2330
lazy_artifacts=true,
2431
julia_compat,

M/MLX/common.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,24 @@ if [[ $bb_full_target == *cuda* ]]; then
5050
)
5151
fi
5252
53+
if $USE_CCACHE; then
54+
export CMAKE_CUDA_COMPILER_LAUNCHER=ccache
55+
fi
56+
57+
if [[ $bb_full_target == *cuda* && $target != x86_64-linux-gnu* ]]; then
58+
# Add /usr/lib/csl-glibc-x86_64 to LD_LIBRARY_PATH to be able to run host `nvcc`/`ptxas`/`fatbinary`
59+
# while keeping the default /usr/lib/csl-musl-x86_64,
60+
export LD_LIBRARY_PATH=/usr/lib/csl-musl-x86_64:/usr/lib/csl-glibc-x86_64:$LD_LIBRARY_PATH
61+
62+
# Make sure the host CUDA executables are used by copying from the host (x86_64) nvcc redist
63+
NVCC_DIR=(/workspace/srcdir/cuda_nvcc-linux-$(arch)-${cuda_version}*-archive)
64+
rm -rfv $prefix/cuda/bin
65+
cp -av ${NVCC_DIR}/bin $prefix/cuda/bin
66+
67+
rm -rfv $prefix/cuda/nvvm/bin
68+
cp -av ${NVCC_DIR}/nvvm/bin $prefix/cuda/nvvm/bin
69+
fi
70+
5371
install_license LICENSE
5472
5573
if [[ "$target" != aarch64-apple-darwin* ]]; then

0 commit comments

Comments
 (0)