Skip to content

Commit 52f1600

Browse files
iseeyuanMartin Yuan
authored andcommitted
Retry: Install the correct nightly version for torchchat (#362)
Co-authored-by: Martin Yuan <[email protected]>
1 parent 305dfeb commit 52f1600

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ source .venv/torchchat/bin/activate
2626
# get the code and dependencies
2727
git clone https://github.com/pytorch/torchchat.git
2828
cd torchchat
29-
pip install -r requirements.txt
29+
bash ./install_requirements.sh
3030
3131
# ensure everything installed correctly
3232
python torchchat.py --help

install_requirements.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
# Install required python dependencies for developing
9+
# Dependencies are defined in .pyproject.toml
10+
if [[ -z $PYTHON_EXECUTABLE ]];
11+
then
12+
if [[ -z $CONDA_DEFAULT_ENV ]] || [[ $CONDA_DEFAULT_ENV == "base" ]] || [[ ! -x "$(command -v python)" ]];
13+
then
14+
PYTHON_EXECUTABLE=python3
15+
else
16+
PYTHON_EXECUTABLE=python
17+
fi
18+
fi
19+
20+
if [[ "$PYTHON_EXECUTABLE" == "python" ]];
21+
then
22+
PIP_EXECUTABLE=pip
23+
else
24+
PIP_EXECUTABLE=pip3
25+
fi
26+
27+
#
28+
# First install requirements in requirements.txt. Older torch may be
29+
# installed from the dependency of other models. It will be overridden by
30+
# newer version of torch nightly installed later in this script.
31+
#
32+
33+
$PIP_EXECUTABLE install -r requirements.txt
34+
35+
# Since torchchat often uses main-branch features of pytorch, only the nightly
36+
# pip versions will have the required features. The NIGHTLY_VERSION value should
37+
# agree with the third-party/pytorch pinned submodule commit.
38+
#
39+
# NOTE: If a newly-fetched version of the executorch repo changes the value of
40+
# NIGHTLY_VERSION, you should re-run this script to install the necessary
41+
# package versions.
42+
NIGHTLY_VERSION=dev20240415
43+
44+
# The pip repository that hosts nightly torch packages.
45+
TORCH_NIGHTLY_URL="https://download.pytorch.org/whl/nightly/cpu"
46+
47+
# pip packages needed by exir.
48+
REQUIREMENTS_TO_INSTALL=(
49+
torch=="2.4.0.${NIGHTLY_VERSION}"
50+
)
51+
52+
# Install the requirements. `--extra-index-url` tells pip to look for package
53+
# versions on the provided URL if they aren't available on the default URL.
54+
$PIP_EXECUTABLE install --extra-index-url "${TORCH_NIGHTLY_URL}" \
55+
"${REQUIREMENTS_TO_INSTALL[@]}"

0 commit comments

Comments
 (0)