Skip to content

Commit d84276b

Browse files
authored
Fix documentation for setting TORCH_CUDA_ARCH_LIST (#328)
1. Quotes are required for the `TORCH_CUDA_ARCH_LIST` so bash doesn't only pick up the first arch. Add that to the `-h` printout for `./build.sh`. 2. Update the README to use `--cuda-arch-list` instead of setting `TORCH_CUDA_ARCH_LIST`. --------- Signed-off-by: Matthew Cong <mcong@nvidia.com>
1 parent 8fe92df commit d84276b

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ docker build -t fvdb-devel .
106106
docker run -it --mount type=bind,src="$(pwd)",target=/workspace fvdb-devel bash
107107
cd /workspace;
108108
pip install -r env/build_requirements.txt
109-
TORCH_CUDA_ARCH_LIST="7.5;8.0;9.0;10.0;12.0+PTX" \
110-
./build.sh install -v
109+
./build.sh install --cuda-arch-list="7.5;8.0;9.0;10.0;12.0+PTX" -v
111110
```
112111

113112
In order to extract an artifact from the container such as the Python wheel, query the container ID using `docker ps` and copy the artifact using `docker cp`.
@@ -126,7 +125,7 @@ Using a Python virtual environment enables you to use your system provided compi
126125
python -m venv fvdb
127126
source fvdb/bin/activate
128127
pip install -r env/build_requirements.txt
129-
TORCH_CUDA_ARCH_LIST="7.5;8.0;9.0;10.0;12.0+PTX" ./build.sh install -v
128+
./build.sh install --cuda-arch-list="7.5;8.0;9.0;10.0;12.0+PTX" -v
130129
```
131130

132131
Note: adjust the TORCH_CUDA_ARCH_LIST to suit your needs. If you are building just to run on a single machine, including only the present GPU architecture(s) reduces build time.

build.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ usage() {
1818
echo " -h, --help Display this help message and exit."
1919
echo " --cuda-arch-list <value> Set TORCH_CUDA_ARCH_LIST (auto-detects if not specified; "
2020
echo " use 'default' to force auto-detect)."
21-
echo " Example: --cuda-arch-list=8.0;8.6+PTX"
21+
echo " Example: --cuda-arch-list=\"8.0;8.6+PTX\""
2222
echo ""
2323
echo "Build Modifiers (for 'install' and 'wheel' build types, typically passed after build_type):"
2424
echo " gtests Enable building tests (sets FVDB_BUILD_TESTS=ON)."
@@ -85,18 +85,17 @@ setup_parallel_build_jobs() {
8585
set_cuda_arch_list() {
8686
local list="$1"
8787
if [ -n "$list" ] && [ "$list" != "default" ]; then
88-
echo "Using TORCH_CUDA_ARCH_LIST=$list"
88+
echo "Using specified TORCH_CUDA_ARCH_LIST=$list"
8989
export TORCH_CUDA_ARCH_LIST="$list"
9090
else
91-
if ([ "$list" == "default" ] || [ -z "$TORCH_CUDA_ARCH_LIST" ]) && command -v nvidia-smi >/dev/null 2>&1; then
91+
if ([ "$list" == "default" ] && [ -z "$TORCH_CUDA_ARCH_LIST" ]) && command -v nvidia-smi >/dev/null 2>&1; then
9292
echo "Detecting CUDA architectures via nvidia-smi"
9393
# Try via nvidia-smi (compute_cap available on newer drivers)
9494
TORCH_CUDA_ARCH_LIST=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader 2>/dev/null | awk 'NF' | awk '!seen[$0]++' | sed 's/$/+PTX/' | paste -sd';' -)
95-
fi
96-
97-
if [ -n "$TORCH_CUDA_ARCH_LIST" ]; then
9895
export TORCH_CUDA_ARCH_LIST
9996
echo "Detected CUDA architectures: $TORCH_CUDA_ARCH_LIST"
97+
elif ([ "$list" == "default" ] && [ -n "$TORCH_CUDA_ARCH_LIST" ]); then
98+
echo "Using environment TORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST"
10099
else
101100
echo "Warning: Could not auto-detect CUDA architectures. Consider setting TORCH_CUDA_ARCH_LIST manually (e.g., 8.0;8.6+PTX)."
102101
fi

0 commit comments

Comments
 (0)