@@ -11,49 +11,17 @@ set -e
11
11
# shellcheck source=/dev/null
12
12
. " $( dirname " $( realpath -s " $0 " ) " ) /setup_env.bash"
13
13
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
-
48
14
verbose=0
15
+ env_name=test_binary
49
16
torchrec_package_name=" "
50
17
python_version=" "
51
18
cuda_version=" x"
52
19
fbgemm_wheel_path=" x"
53
20
miniconda_prefix=" ${HOME} /miniconda"
54
21
55
22
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]"
57
25
echo " -v : verbose"
58
26
echo " -h : help"
59
27
echo " PACKAGE_NAME : output package name of TorchRec (e.g., torchrec_nightly)"
@@ -65,7 +33,8 @@ usage () {
65
33
echo " FBGEMM_WHEEL_PATH : path to FBGEMM_GPU's wheel file"
66
34
echo " MINICONDA_PREFIX : path to install Miniconda (default: \$ HOME/miniconda)"
67
35
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"
69
38
}
70
39
71
40
while getopts vho:p:P:c:m:w: flag
@@ -112,30 +81,37 @@ echo "## 1. Set up Miniconda"
112
81
setup_miniconda " $miniconda_prefix "
113
82
114
83
# ###############################################################################
115
- echo " ## 2. Create test_binary environment"
84
+ echo " ## 2. Create Conda environment"
116
85
# ###############################################################################
117
86
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
119
95
120
96
# Comment out FBGEMM_GPU since we will install it from "$fbgemm_wheel_path"
121
97
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
123
99
# 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"
126
102
127
103
# ###############################################################################
128
104
echo " ## 3. Build TorchRec"
129
105
# ###############################################################################
130
106
131
107
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} "
133
109
134
110
# ###############################################################################
135
111
echo " ## 4. Import TorchRec"
136
112
# ###############################################################################
137
113
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"
140
116
141
117
echo " Test succeeded"
0 commit comments