studio: address review feedback
install_python_stack.py: - Print uv error output on failure for debuggability - Refactor pip_install() to use early return after uv success, removing duplicated pip command path setup.sh: - Guard nvidia-smi command substitution with || true so it does not abort the script under set -euo pipefail when nvidia-smi fails (e.g., containerized environments, driver quirks) - Read all GPU compute capabilities and deduplicate, so mixed-GPU hosts get kernels built for all present architectures instead of only the first GPU
This commit is contained in:
parent
6dda8c4c23
commit
a7a66a66b9
2 changed files with 25 additions and 15 deletions
|
|
@ -186,13 +186,14 @@ def pip_install(
|
|||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.STDOUT,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
print(_red(f" uv failed, falling back to pip..."))
|
||||
pip_cmd = _build_pip_cmd(args) + constraint_args + req_args
|
||||
run(label, pip_cmd)
|
||||
else:
|
||||
pip_cmd = _build_pip_cmd(args) + constraint_args + req_args
|
||||
run(label, pip_cmd)
|
||||
if result.returncode == 0:
|
||||
return
|
||||
print(_red(f" uv failed, falling back to pip..."))
|
||||
if result.stdout:
|
||||
print(result.stdout.decode(errors = "replace"))
|
||||
|
||||
pip_cmd = _build_pip_cmd(args) + constraint_args + req_args
|
||||
run(label, pip_cmd)
|
||||
finally:
|
||||
if actual_req is not None and actual_req != req:
|
||||
actual_req.unlink(missing_ok = True)
|
||||
|
|
|
|||
|
|
@ -295,17 +295,26 @@ rm -rf "$LLAMA_CPP_DIR"
|
|||
|
||||
# Detect GPU compute capability and limit CUDA architectures
|
||||
# Without this, cmake builds for ALL default archs (very slow)
|
||||
CUDA_ARCH=""
|
||||
CUDA_ARCHS=""
|
||||
if command -v nvidia-smi &>/dev/null; then
|
||||
_raw_cap=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader 2>/dev/null | head -1 | tr -d '[:space:]')
|
||||
if [[ "$_raw_cap" =~ ^([0-9]+)\.([0-9]+)$ ]]; then
|
||||
CUDA_ARCH="${BASH_REMATCH[1]}${BASH_REMATCH[2]}"
|
||||
fi
|
||||
# Read all GPUs, deduplicate (handles mixed-GPU hosts)
|
||||
_raw_caps=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader 2>/dev/null || true)
|
||||
while IFS= read -r _cap; do
|
||||
_cap=$(echo "$_cap" | tr -d '[:space:]')
|
||||
if [[ "$_cap" =~ ^([0-9]+)\.([0-9]+)$ ]]; then
|
||||
_arch="${BASH_REMATCH[1]}${BASH_REMATCH[2]}"
|
||||
# Append if not already present
|
||||
case ";$CUDA_ARCHS;" in
|
||||
*";$_arch;"*) ;;
|
||||
*) CUDA_ARCHS="${CUDA_ARCHS:+$CUDA_ARCHS;}$_arch" ;;
|
||||
esac
|
||||
fi
|
||||
done <<< "$_raw_caps"
|
||||
fi
|
||||
|
||||
if [ -n "$CUDA_ARCH" ]; then
|
||||
echo " GPU compute capability: sm_${CUDA_ARCH} -- limiting build to this arch"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCH}"
|
||||
if [ -n "$CUDA_ARCHS" ]; then
|
||||
echo " GPU compute capabilities: ${CUDA_ARCHS//;/, } -- limiting build to detected archs"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHS}"
|
||||
else
|
||||
echo " Could not detect GPU arch -- building for all default CUDA architectures (slower)"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue