8
8
# Exit on failure
9
9
set -e
10
10
11
- # shellcheck source=/dev/null
12
- . " $( dirname " $( realpath -s " $0 " ) " ) /setup_env.bash"
13
-
14
11
verbose=0
15
- env_name=test_binary
16
12
torchrec_package_name=" "
17
13
python_version=" "
18
14
cuda_version=" x"
19
- fbgemm_wheel_path=" x"
20
15
miniconda_prefix=" ${HOME} /miniconda"
21
16
22
17
usage () {
23
18
# 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]"
19
+ echo " Usage: bash $( basename ${BASH_SOURCE[0]} ) -o PACKAGE_NAME -p PYTHON_VERSION -P PYTORCH_CHANNEL_NAME -c CUDA_VERSION [-m MINICONDA_PREFIX] [-v] [-h]"
25
20
echo " -v : verbose"
26
21
echo " -h : help"
27
22
echo " PACKAGE_NAME : output package name of TorchRec (e.g., torchrec_nightly)"
@@ -30,14 +25,13 @@ usage () {
30
25
echo " PYTHON_VERSION : Python version (e.g., 3.10)"
31
26
echo " PYTORCH_CHANNEL_NAME: PyTorch's channel name (e.g., pytorch-nightly, pytorch-test (=pre-release), pytorch (=stable release))"
32
27
echo " CUDA_VERSION : PyTorch's CUDA version (e.g., 12.4)"
33
- echo " FBGEMM_WHEEL_PATH : path to FBGEMM_GPU's wheel file"
34
28
echo " MINICONDA_PREFIX : path to install Miniconda (default: \$ HOME/miniconda)"
35
29
echo " Example: Python 3.10 + PyTorch nightly (CUDA 12.4), install miniconda at \$ HOME/miniconda, using dist/fbgemm_gpu_nightly.whl"
36
30
# shellcheck disable=SC2086
37
31
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"
38
32
}
39
33
40
- while getopts vho:p:P:c:m:w : flag
34
+ while getopts vho:p:P:c:m:b : flag
41
35
do
42
36
case " $flag " in
43
37
v) verbose=" 1" ;;
46
40
P) pytorch_channel_name=" ${OPTARG} " ;;
47
41
c) cuda_version=" ${OPTARG} " ;;
48
42
m) miniconda_prefix=" ${OPTARG} " ;;
49
- w) fbgemm_wheel_path =" ${OPTARG} " ;;
43
+ b) build_env =" ${OPTARG} " ;;
50
44
h) usage
51
45
exit 0;;
52
46
* ) usage
53
47
exit 1;;
54
48
esac
55
49
done
56
50
57
- if [ " $torchrec_package_name " == " " ] || [ " $python_version " == " " ] || [ " $cuda_version " == " x" ] || [ " $miniconda_prefix " == " " ] || [ " $pytorch_channel_name " == " " ] || [ " $fbgemm_wheel_path " == " " ]; then
51
+ if [ " $torchrec_package_name " == " " ] || [ " $python_version " == " " ] || [ " $cuda_version " == " x" ] || [ " $miniconda_prefix " == " " ] || [ " $pytorch_channel_name " == " " ] || [ " $build_env " == " " ]; then
58
52
usage
59
53
exit 1
60
54
fi
55
+
56
+ env_name=$build_env
61
57
python_tag=" ${python_version// \. / } "
62
58
63
59
if [ " $verbose " == " 1" ]; then
@@ -74,44 +70,60 @@ if [ ! -d "torchrec" ]; then
74
70
exit 1
75
71
fi
76
72
77
- # ###############################################################################
78
- echo " ## 1. Set up Miniconda"
79
- # ###############################################################################
80
-
81
- setup_miniconda " $miniconda_prefix "
73
+ # Install PyTorch
74
+ conda run -n " $env_name " pip install torch --index-url https://download.pytorch.org/whl/nightly/cpu
75
+ conda run -n " $env_name " python -c " import torch"
82
76
83
- # ###############################################################################
84
- echo " ## 2. Create Conda environment"
85
- # ###############################################################################
77
+ # Import torch.distributed
78
+ conda run -n " $env_name " python -c " import torch.distributed"
86
79
87
- if [ " ${cuda_version} " != " " ]; then
88
- pytorch_variant=" cuda ${cuda_version} "
89
- else
90
- pytorch_variant=" cpu"
91
- fi
80
+ # Import fbgemm_gpu
92
81
93
- # shellcheck disable=SC2086
94
- test_setup_conda_environment " $env_name " gcc " $python_version " pip " $pytorch_channel_name " $pytorch_variant
82
+ echo " [INSTALL] Installing FBGEMM-GPU wheel: ${wheel_path} ..."
83
+ cd ../fbgemm_gpu
84
+ conda run --no-capture-output -n " $env_name " python -m pip install -r requirements.txt
85
+ conda run -n " $env_name " python setup.py clean
86
+ conda run -n " $env_name " python setup.py bdist_wheel --python-tag=" py${python_tag} "
87
+ conda run -n " $env_name " pip install fbgemm-gpu ../* .whl
88
+ conda run -n " $env_name " python -c " import fbgemm_gpu"
89
+ cd ../torchrec
95
90
96
- # Comment out FBGEMM_GPU since we will install it from "$fbgemm_wheel_path"
91
+ # ###############################################################################
92
+ echo " ## 1. Install TorchRec Requirements"
93
+ # ###############################################################################
94
+ # Comment out FBGEMM_GPU since we should pre-install it from the downloaded wheel file
97
95
sed -i ' s/fbgemm-gpu/#fbgemm-gpu/g' requirements.txt
98
96
conda run -n " $env_name " python -m pip install -r requirements.txt
99
- # Install FBGEMM_GPU from a local wheel file.
100
- conda run -n " $env_name " python -m pip install " $fbgemm_wheel_path "
101
- conda run -n " $env_name " python -c " import fbgemm_gpu"
97
+
102
98
103
99
# ###############################################################################
104
- echo " ## 3 . Build TorchRec"
100
+ echo " ## 2 . Build TorchRec"
105
101
# ###############################################################################
106
102
107
103
rm -rf dist
108
- conda run -n " $env_name " python setup.py bdist_wheel --package_name " ${torchrec_package_name} " -- python-tag=" py${python_tag} "
104
+ conda run -n " $env_name " python setup.py bdist_wheel --python-tag=" py${python_tag} "
109
105
110
106
# ###############################################################################
111
- echo " ## 4 . Import TorchRec"
107
+ echo " ## 3 . Import TorchRec"
112
108
# ###############################################################################
113
109
114
- conda run -n " $env_name " python -m pip install dist/" ${torchrec_package_name} " * .whl
115
110
conda run -n " $env_name " python -c " import torchrec"
116
111
117
112
echo " Test succeeded"
113
+
114
+ # ###############################################################################
115
+ echo " ## 4. Run TorchRec tests"
116
+ # ###############################################################################
117
+
118
+ conda install -n " $env_name " -y pytest
119
+ # Read the list of tests to skip from a file, ignoring empty lines and comments
120
+ skip_expression=$( awk ' !/^($|#)/ {printf " and not %s", $0}' ./.github/scripts/tests_to_skip.txt)
121
+ # Check if skip_expression is effectively empty
122
+ if [ -z " $skip_expression " ]; then
123
+ skip_expression=" "
124
+ else
125
+ skip_expression=${skip_expression: 5} # Remove the leading " and "
126
+ fi
127
+ conda run -n " $env_name " \
128
+ python -m pytest torchrec -v -s -W ignore::pytest.PytestCollectionWarning --continue-on-collection-errors \
129
+ --ignore-glob=** /test_utils/ -k " $skip_expression "
0 commit comments