Skip to content

Commit 46a6b9c

Browse files
ianbarbermikekgfb
authored andcommitted
Automatically identify cuda from nvidia-smi in install-requirements (#606)
* Automatically identify cuda from nvidia-smi in install-requirements * Update README.md --------- Co-authored-by: Michael Gschwind <[email protected]>
1 parent 785e92a commit 46a6b9c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ cd torchchat
5454
# set up a virtual environment
5555
python3 -m venv .venv
5656
source .venv/bin/activate
57-
```
58-
59-
After the virtual environment is activated, dependencies can be installed.
6057

61-
```bash
6258
# install dependencies
6359
./install_requirements.sh
6460
```

install_requirements.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ $PIP_EXECUTABLE install -r requirements.txt --extra-index-url https://download.p
4242
NIGHTLY_VERSION=dev20240422
4343

4444
# The pip repository that hosts nightly torch packages. cpu by default.
45-
TORCH_NIGHTLY_URL="https://download.pytorch.org/whl/nightly/cpu"
46-
47-
# If cuda is available, use the pytorch nightly with cuda for faster execution on cuda GPUs.
48-
test -f /usr/bin/nvidia-smi && TORCH_NIGHTLY_URL="https://download.pytorch.org/whl/nightly/cu121"
45+
# If cuda is available, based on presence of nvidia-smi, install the pytorch nightly
46+
# with cuda for faster execution on cuda GPUs.
47+
if [[ -x "$(command -v nvidia-smi)" ]];
48+
then
49+
TORCH_NIGHTLY_URL="https://download.pytorch.org/whl/nightly/cu121"
50+
else
51+
TORCH_NIGHTLY_URL="https://download.pytorch.org/whl/nightly/cpu"
52+
fi
4953

5054
# pip packages needed by exir.
5155
REQUIREMENTS_TO_INSTALL=(

0 commit comments

Comments
 (0)