Skip to content

Commit f325a79

Browse files
q10facebook-github-bot
authored andcommitted
Fix nova script (pytorch#2033)
Summary: - Fix a syntax issue with bash associative arrays that caused the Nova build scripts to fail Pull Request resolved: pytorch#2033 Reviewed By: spcyppt Differential Revision: D49529109 Pulled By: q10 fbshipit-source-id: d2e1ac49e3490bc89b266c7596a19117efa0caa8
1 parent 91facab commit f325a79

File tree

5 files changed

+38
-59
lines changed

5 files changed

+38
-59
lines changed

.github/scripts/fbgemm_gpu_build.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ build_fbgemm_gpu_package () {
290290
fbgemm_variant="$3"
291291
fbgemm_variant_targets="$4"
292292
if [ "$fbgemm_variant" == "" ]; then
293-
echo "Usage: ${FUNCNAME[0]} ENV_NAME PACKAGE_NAME VARIANT [TARGETS]"
293+
echo "Usage: ${FUNCNAME[0]} ENV_NAME RELEASE_TYPE VARIANT [VARIANT_TARGETS]"
294294
echo "Example(s):"
295295
echo " ${FUNCNAME[0]} build_env nightly cpu # Nightly CPU-only variant"
296296
echo " ${FUNCNAME[0]} build_env nightly cuda # Nightly CUDA variant for default target(s)"

.github/scripts/fbgemm_gpu_test.bash

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,14 @@ run_fbgemm_gpu_tests () {
129129
################################################################################
130130

131131
test_setup_conda_environment () {
132-
local python_version="$1"
133-
local pytorch_installer="$2"
134-
local pytorch_version="$3"
135-
local pytorch_variant_type="$4"
136-
local pytorch_variant_version="$5"
132+
local env_name="$1"
133+
local python_version="$2"
134+
local pytorch_installer="$3"
135+
local pytorch_version="$4"
136+
local pytorch_variant_type="$5"
137+
local pytorch_variant_version="$6"
137138
if [ "$pytorch_variant_type" == "" ]; then
138-
echo "Usage: ${FUNCNAME[0]} PYTHON_VERSION PYTORCH_INSTALLER PYTORCH_VERSION PYTORCH_VARIANT_TYPE [PYTORCH_VARIANT_VERSION]"
139+
echo "Usage: ${FUNCNAME[0]} ENV_NAME PYTHON_VERSION PYTORCH_INSTALLER PYTORCH_VERSION PYTORCH_VARIANT_TYPE [PYTORCH_VARIANT_VERSION]"
139140
echo "Example(s):"
140141
echo " ${FUNCNAME[0]} build_env 3.8 pip test cuda 11.8.0 # Setup environment with pytorch-test for Python 3.8 + CUDA 11.8.0"
141142
return 1
@@ -148,9 +149,11 @@ test_setup_conda_environment () {
148149
echo ""
149150
fi
150151

151-
local env_name="test_py${python_version}_${pytorch_installer}_pytorch_${pytorch_version}_${pytorch_variant_type}"
152-
if [ "$pytorch_variant_version" != "" ]; then
153-
local env_name="${env_name}_${pytorch_variant_version}"
152+
if [ "$env_name" == "" ]; then
153+
local env_name="test_py${python_version}_${pytorch_installer}_pytorch_${pytorch_version}_${pytorch_variant_type}"
154+
if [ "$pytorch_variant_version" != "" ]; then
155+
local env_name="${env_name}_${pytorch_variant_version}"
156+
fi
154157
fi
155158

156159
echo "Creating the Build Environment: ${env_name} ..."

.github/scripts/nova_prescript.bash

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ if [[ $CU_VERSION = cu* ]]; then
5757
echo "[NOVA] ------------------------------------------"
5858

5959
echo "[NOVA] Building the CUDA variant of FBGEMM_GPU ..."
60-
fbgemm_variant="cuda"
60+
export fbgemm_variant="cuda"
6161

6262
elif [[ $CU_VERSION = rocm* ]]; then
6363
echo "[NOVA] Building the ROCm variant of FBGEMM_GPU ..."
64-
fbgemm_variant="rocm"
64+
export fbgemm_variant="rocm"
6565

6666
else
6767
echo "[NOVA] Building the CPU variant of FBGEMM_GPU ..."
68-
fbgemm_variant="cpu"
68+
export fbgemm_variant="cpu"
6969
fi
7070

7171
# Install the necessary Python eggs for building
@@ -78,7 +78,7 @@ export BUILD_FROM_NOVA
7878

7979
# Build FBGEMM_GPU nightly by default
8080
if [[ ${CHANNEL} == "" ]]; then
81-
CHANNEL="nightly"
81+
export CHANNEL="nightly"
8282
fi
8383

8484
# Build the wheel

.github/scripts/test_torchrec.bash

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,17 @@ set -e
1111
# shellcheck source=/dev/null
1212
. "$(dirname "$(realpath -s "$0")")/setup_env.bash"
1313

14-
create_conda_pytorch_environment () {
15-
local env_name="$1"
16-
local python_version="$2"
17-
local pytorch_channel_name="$3"
18-
local cuda_version="$4"
19-
if [ "$python_version" == "" ]; then
20-
echo "Usage: ${FUNCNAME[0]} ENV_NAME PYTHON_VERSION PYTORCH_CHANNEL_NAME CUDA_VERSION"
21-
echo "Example:"
22-
echo " ${FUNCNAME[0]} build_env 3.10 pytorch-nightly 11.7.1"
23-
return 1
24-
fi
25-
26-
# Create the Conda environment
27-
create_conda_environment "${env_name}" "${python_version}"
28-
29-
# Convert the channels to versions
30-
if [ "${pytorch_channel_name}" == "pytorch-nightly" ]; then
31-
pytorch_version="nightly"
32-
elif [ "${pytorch_channel_name}" == "pytorch-test" ]; then
33-
pytorch_version="test"
34-
else
35-
pytorch_version="latest"
36-
fi
37-
38-
if [ "${cuda_version}" == "" ]; then
39-
# Install the CPU variant of PyTorch
40-
install_pytorch_conda "${env_name}" "${pytorch_version}" cpu
41-
else
42-
# Install CUDA and the GPU variant of PyTorch
43-
install_cuda "${env_name}" "${cuda_version}"
44-
install_pytorch_conda "${env_name}" "${pytorch_version}"
45-
fi
46-
}
47-
4814
verbose=0
15+
env_name=test_binary
4916
torchrec_package_name=""
5017
python_version=""
5118
cuda_version="x"
5219
fbgemm_wheel_path="x"
5320
miniconda_prefix="${HOME}/miniconda"
5421

5522
usage () {
56-
echo "Usage: bash test_torchrec.bash -o PACKAGE_NAME -p PYTHON_VERSION -P PYTORCH_CHANNEL_NAME -c CUDA_VERSION -w FBGEMM_WHEEL_PATH [-m MINICONDA_PREFIX] [-v] [-h]"
23+
# shellcheck disable=SC2086
24+
echo "Usage: bash $(basename ${BASH_SOURCE[0]}) -o PACKAGE_NAME -p PYTHON_VERSION -P PYTORCH_CHANNEL_NAME -c CUDA_VERSION -w FBGEMM_WHEEL_PATH [-m MINICONDA_PREFIX] [-v] [-h]"
5725
echo "-v : verbose"
5826
echo "-h : help"
5927
echo "PACKAGE_NAME : output package name of TorchRec (e.g., torchrec_nightly)"
@@ -65,7 +33,8 @@ usage () {
6533
echo "FBGEMM_WHEEL_PATH : path to FBGEMM_GPU's wheel file"
6634
echo "MINICONDA_PREFIX : path to install Miniconda (default: \$HOME/miniconda)"
6735
echo "Example: Python 3.10 + PyTorch nightly (CUDA 11.7), install miniconda at \$HOME/miniconda, using dist/fbgemm_gpu_nightly.whl"
68-
echo " bash test_torchrec.bash -v -o torchrec_nightly -p 3.10 -P pytorch-nightly -c 11.7 -w dist/fbgemm_gpu_nightly.whl"
36+
# shellcheck disable=SC2086
37+
echo " bash $(basename ${BASH_SOURCE[0]}) -v -o torchrec_nightly -p 3.10 -P pytorch-nightly -c 11.7 -w dist/fbgemm_gpu_nightly.whl"
6938
}
7039

7140
while getopts vho:p:P:c:m:w: flag
@@ -112,30 +81,37 @@ echo "## 1. Set up Miniconda"
11281
setup_miniconda "$miniconda_prefix"
11382

11483
################################################################################
115-
echo "## 2. Create test_binary environment"
84+
echo "## 2. Create Conda environment"
11685
################################################################################
11786

118-
create_conda_pytorch_environment test_binary "$python_version" "$pytorch_channel_name" "$cuda_version"
87+
if [ "${cuda_version}" == "" ]; then
88+
pytorch_variant="cuda ${cuda_version}"
89+
else
90+
pytorch_variant="cpu"
91+
fi
92+
93+
# shellcheck disable=SC2086
94+
test_setup_conda_environment "$env_name" "$python_version" pip "$pytorch_channel_name" $pytorch_variant
11995

12096
# Comment out FBGEMM_GPU since we will install it from "$fbgemm_wheel_path"
12197
sed -i 's/fbgemm-gpu/#fbgemm-gpu/g' requirements.txt
122-
conda run -n test_binary python -m pip install -r requirements.txt
98+
conda run -n "$env_name" python -m pip install -r requirements.txt
12399
# Install FBGEMM_GPU from a local wheel file.
124-
conda run -n test_binary python -m pip install "$fbgemm_wheel_path"
125-
conda run -n test_binary python -c "import fbgemm_gpu"
100+
conda run -n "$env_name" python -m pip install "$fbgemm_wheel_path"
101+
conda run -n "$env_name" python -c "import fbgemm_gpu"
126102

127103
################################################################################
128104
echo "## 3. Build TorchRec"
129105
################################################################################
130106

131107
rm -rf dist
132-
conda run -n test_binary python setup.py bdist_wheel --package_name "${torchrec_package_name}" --python-tag="py${python_tag}"
108+
conda run -n "$env_name" python setup.py bdist_wheel --package_name "${torchrec_package_name}" --python-tag="py${python_tag}"
133109

134110
################################################################################
135111
echo "## 4. Import TorchRec"
136112
################################################################################
137113

138-
conda run -n test_binary python -m pip install dist/"${torchrec_package_name}"*.whl
139-
conda run -n test_binary python -c "import torchrec"
114+
conda run -n "$env_name" python -m pip install dist/"${torchrec_package_name}"*.whl
115+
conda run -n "$env_name" python -c "import torchrec"
140116

141117
echo "Test succeeded"

.github/scripts/utils_cuda.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ install_cudnn () {
102102

103103
# Install cuDNN manually
104104
# Based on install script in https://github.com/pytorch/builder/blob/main/common/install_cuda.sh
105-
local cudnn_packages=(
105+
declare -A cudnn_packages=(
106106
["115"]="https://developer.download.nvidia.com/compute/redist/cudnn/v8.3.2/local_installers/11.5/cudnn-${PLATFORM_NAME_LC}-8.3.2.44_cuda11.5-archive.tar.xz"
107107
["116"]="https://developer.download.nvidia.com/compute/redist/cudnn/v8.3.2/local_installers/11.5/cudnn-${PLATFORM_NAME_LC}-8.3.2.44_cuda11.5-archive.tar.xz"
108108
["117"]="https://ossci-linux.s3.amazonaws.com/cudnn-${PLATFORM_NAME_LC}-8.5.0.96_cuda11-archive.tar.xz"

0 commit comments

Comments
 (0)