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,54 @@ if [ ! -d "torchrec" ]; then
74
70
exit 1
75
71
fi
76
72
77
- # ###############################################################################
78
- echo " ## 1. Set up Miniconda"
79
- # ###############################################################################
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"
76
+
77
+ # Import torch.distributed
78
+ conda run -n " $env_name " python -c " import torch.distributed"
80
79
81
- setup_miniconda " $miniconda_prefix "
80
+ # Import fbgemm_gpu
81
+ echo " [INSTALL] Installing FBGEMM-GPU wheel: ${wheel_path} ..."
82
+ conda run -n " $env_name " pip install fbgemm-gpu ../* .whl
83
+ conda run -n " $env_name " python -c " import fbgemm_gpu"
82
84
83
85
# ###############################################################################
84
- echo " ## 2. Create Conda environment "
86
+ echo " ## 1. Install TorchRec Requirements "
85
87
# ###############################################################################
86
-
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 " gcc " $python_version " pip " $pytorch_channel_name " $pytorch_variant
95
-
96
- # Comment out FBGEMM_GPU since we will install it from "$fbgemm_wheel_path"
88
+ # Comment out FBGEMM_GPU since we should pre-install it from the downloaded wheel file
97
89
sed -i ' s/fbgemm-gpu/#fbgemm-gpu/g' requirements.txt
98
90
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"
91
+
102
92
103
93
# ###############################################################################
104
- echo " ## 3 . Build TorchRec"
94
+ echo " ## 2 . Build TorchRec"
105
95
# ###############################################################################
106
96
107
97
rm -rf dist
108
- conda run -n " $env_name " python setup.py bdist_wheel --package_name " ${torchrec_package_name} " -- python-tag=" py${python_tag} "
98
+ conda run -n " $env_name " python setup.py bdist_wheel --python-tag=" py${python_tag} "
109
99
110
100
# ###############################################################################
111
- echo " ## 4 . Import TorchRec"
101
+ echo " ## 3 . Import TorchRec"
112
102
# ###############################################################################
113
103
114
- conda run -n " $env_name " python -m pip install dist/" ${torchrec_package_name} " * .whl
115
104
conda run -n " $env_name " python -c " import torchrec"
116
105
117
106
echo " Test succeeded"
107
+
108
+ # ###############################################################################
109
+ echo " ## 4. Run TorchRec tests"
110
+ # ###############################################################################
111
+
112
+ conda install -n " $env_name " -y pytest
113
+ # Read the list of tests to skip from a file, ignoring empty lines and comments
114
+ skip_expression=$( awk ' !/^($|#)/ {printf " and not %s", $0}' ./.github/scripts/tests_to_skip.txt)
115
+ # Check if skip_expression is effectively empty
116
+ if [ -z " $skip_expression " ]; then
117
+ skip_expression=" "
118
+ else
119
+ skip_expression=${skip_expression: 5} # Remove the leading " and "
120
+ fi
121
+ conda run -n " $env_name " \
122
+ python -m pytest torchrec -v -s -W ignore::pytest.PytestCollectionWarning --continue-on-collection-errors \
123
+ --ignore-glob=** /test_utils/ -k " $skip_expression "
0 commit comments