Skip to content

Commit b4b21a4

Browse files
authored
feat(conda): share envs with transformer-based backends (#1465)
* feat(conda): share env between diffusers and bark * Detect if env already exists * share diffusers and petals * tests: add petals * Use smaller model for tests with petals * test only model load on petals * tests(petals): run only load model tests * Revert "test only model load on petals" This reverts commit 111cfa9. * move transformers and sentencetransformers to common env * Share also transformers-musicgen
1 parent 23eced1 commit b4b21a4

File tree

23 files changed

+189
-266
lines changed

23 files changed

+189
-266
lines changed

.github/workflows/test-extra.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,37 @@ jobs:
133133
134134
135135
136+
tests-petals:
137+
runs-on: ubuntu-latest
138+
steps:
139+
- name: Clone
140+
uses: actions/checkout@v4
141+
with:
142+
submodules: true
143+
- name: Dependencies
144+
run: |
145+
sudo apt-get update
146+
sudo apt-get install build-essential ffmpeg
147+
curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg && \
148+
sudo install -o root -g root -m 644 conda.gpg /usr/share/keyrings/conda-archive-keyring.gpg && \
149+
gpg --keyring /usr/share/keyrings/conda-archive-keyring.gpg --no-default-keyring --fingerprint 34161F5BF5EB1D4BFBBB8F0A8AEB4F8B29D82806 && \
150+
sudo /bin/bash -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" > /etc/apt/sources.list.d/conda.list' && \
151+
sudo /bin/bash -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" | tee -a /etc/apt/sources.list.d/conda.list' && \
152+
sudo apt-get update && \
153+
sudo apt-get install -y conda
154+
sudo apt-get install -y ca-certificates cmake curl patch
155+
sudo apt-get install -y libopencv-dev && sudo ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
156+
157+
sudo rm -rfv /usr/bin/conda || true
158+
159+
- name: Test petals
160+
run: |
161+
export PATH=$PATH:/opt/conda/bin
162+
make -C backend/python/petals
163+
make -C backend/python/petals test
164+
165+
166+
136167
tests-bark:
137168
runs-on: ubuntu-latest
138169
steps:

backend/python/bark/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
.PHONY: ttsbark
22
ttsbark:
3-
@echo "Creating virtual environment..."
4-
@conda env create --name ttsbark --file ttsbark.yml
5-
@echo "Virtual environment created."
3+
$(MAKE) -C ../common-env/transformers
64

75
.PHONY: run
86
run:

backend/python/bark/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
export PATH=$PATH:/opt/conda/bin
77

88
# Activate conda environment
9-
source activate ttsbark
9+
source activate transformers
1010

1111
# get the directory where the bash script is located
1212
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

backend/python/bark/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## A bash script wrapper that runs the bark server with conda
44

55
# Activate conda environment
6-
source activate ttsbark
6+
source activate transformers
77

88
# get the directory where the bash script is located
99
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CONDA_ENV_PATH = "transformers.yml"
2+
3+
ifeq ($(BUILD_TYPE), cublas)
4+
CONDA_ENV_PATH = "transformers-nvidia.yml"
5+
endif
6+
7+
.PHONY: transformers
8+
transformers:
9+
@echo "Installing $(CONDA_ENV_PATH)..."
10+
bash install.sh $(CONDA_ENV_PATH)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
# Check if environment exist
5+
conda_env_exists(){
6+
! conda list --name "${@}" >/dev/null 2>/dev/null
7+
}
8+
9+
if conda_env_exists "transformers" ; then
10+
echo "Creating virtual environment..."
11+
conda env create --name transformers --file $1
12+
echo "Virtual environment created."
13+
else
14+
echo "Virtual environment already exists."
15+
fi

backend/python/bark/ttsbark.yml renamed to backend/python/common-env/transformers/transformers-nvidia.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: bark
1+
name: transformers
22
channels:
33
- defaults
44
dependencies:
@@ -35,6 +35,8 @@ dependencies:
3535
- certifi==2023.7.22
3636
- charset-normalizer==3.3.0
3737
- datasets==2.14.5
38+
- sentence-transformers==2.2.2
39+
- sentencepiece==0.1.99
3840
- dill==0.3.7
3941
- einops==0.7.0
4042
- encodec==0.1.1
@@ -68,6 +70,7 @@ dependencies:
6870
- packaging==23.2
6971
- pandas==2.1.1
7072
- peft==0.5.0
73+
- git+https://github.com/bigscience-workshop/petals
7174
- protobuf==4.24.4
7275
- psutil==5.9.5
7376
- pyarrow==13.0.0
@@ -93,4 +96,4 @@ dependencies:
9396
- urllib3==1.26.17
9497
- xxhash==3.4.1
9598
- yarl==1.9.2
96-
prefix: /opt/conda/envs/bark
99+
prefix: /opt/conda/envs/transformers

backend/python/transformers/transformers.yml renamed to backend/python/common-env/transformers/transformers.yml

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,58 +20,68 @@ dependencies:
2020
- setuptools=68.0.0=py311h06a4308_0
2121
- sqlite=3.41.2=h5eee18b_0
2222
- tk=8.6.12=h1ccaba5_0
23-
- tzdata=2023c=h04d1e81_0
2423
- wheel=0.41.2=py311h06a4308_0
2524
- xz=5.4.2=h5eee18b_0
2625
- zlib=1.2.13=h5eee18b_0
2726
- pip:
27+
- accelerate==0.23.0
28+
- aiohttp==3.8.5
29+
- aiosignal==1.3.1
30+
- async-timeout==4.0.3
31+
- attrs==23.1.0
32+
- bark==0.1.5
33+
- boto3==1.28.61
34+
- botocore==1.31.61
2835
- certifi==2023.7.22
2936
- charset-normalizer==3.3.0
30-
- click==8.1.7
37+
- datasets==2.14.5
38+
- sentence-transformers==2.2.2
39+
- sentencepiece==0.1.99
40+
- dill==0.3.7
41+
- einops==0.7.0
42+
- encodec==0.1.1
3143
- filelock==3.12.4
32-
- fsspec==2023.9.2
44+
- frozenlist==1.4.0
45+
- fsspec==2023.6.0
46+
- funcy==2.0
3347
- grpcio==1.59.0
34-
- huggingface-hub==0.17.3
48+
- huggingface-hub==0.16.4
3549
- idna==3.4
36-
- install==1.3.5
3750
- jinja2==3.1.2
38-
- joblib==1.3.2
51+
- jmespath==1.0.1
3952
- markupsafe==2.1.3
4053
- mpmath==1.3.0
54+
- multidict==6.0.4
55+
- multiprocess==0.70.15
4156
- networkx==3.1
42-
- nltk==3.8.1
4357
- numpy==1.26.0
44-
- nvidia-cublas-cu12==12.1.3.1
45-
- nvidia-cuda-cupti-cu12==12.1.105
46-
- nvidia-cuda-nvrtc-cu12==12.1.105
47-
- nvidia-cuda-runtime-cu12==12.1.105
48-
- nvidia-cudnn-cu12==8.9.2.26
49-
- nvidia-cufft-cu12==11.0.2.54
50-
- nvidia-curand-cu12==10.3.2.106
51-
- nvidia-cusolver-cu12==11.4.5.107
52-
- nvidia-cusparse-cu12==12.1.0.106
53-
- nvidia-nccl-cu12==2.18.1
54-
- nvidia-nvjitlink-cu12==12.2.140
55-
- nvidia-nvtx-cu12==12.1.105
5658
- packaging==23.2
57-
- pillow==10.0.1
59+
- pandas==2.1.1
60+
- peft==0.5.0
61+
- git+https://github.com/bigscience-workshop/petals
5862
- protobuf==4.24.4
63+
- psutil==5.9.5
64+
- pyarrow==13.0.0
65+
- python-dateutil==2.8.2
66+
- pytz==2023.3.post1
5967
- pyyaml==6.0.1
6068
- regex==2023.10.3
6169
- requests==2.31.0
62-
- safetensors==0.4.0
63-
- scikit-learn==1.3.1
70+
- rouge==1.0.1
71+
- s3transfer==0.7.0
72+
- safetensors==0.3.3
6473
- scipy==1.11.3
65-
- sentence-transformers==2.2.2
66-
- sentencepiece==0.1.99
74+
- six==1.16.0
6775
- sympy==1.12
68-
- threadpoolctl==3.2.0
69-
- tokenizers==0.14.1
76+
- tokenizers==0.14.0
7077
- torch==2.1.0
71-
- torchvision==0.16.0
78+
- torchaudio==2.1.0
7279
- tqdm==4.66.1
7380
- transformers==4.34.0
7481
- triton==2.1.0
7582
- typing-extensions==4.8.0
76-
- urllib3==2.0.6
83+
- tzdata==2023.3
84+
- urllib3==1.26.17
85+
- xxhash==3.4.1
86+
- yarl==1.9.2
7787
prefix: /opt/conda/envs/transformers

backend/python/diffusers/diffusers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ dependencies:
7070
- typing-extensions==4.8.0
7171
- urllib3==2.0.6
7272
- zipp==3.17.0
73-
prefix: /opt/conda/envs/diffusers
73+
prefix: /opt/conda/envs/diffusers

backend/python/petals/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
.PHONY: petals
22
petals:
3-
@echo "Creating virtual environment..."
4-
@conda env create --name petals --file petals.yml
5-
@echo "Virtual environment created."
3+
$(MAKE) -C ../common-env/transformers
64

75
.PHONY: run
86
run:
97
@echo "Running petals..."
108
bash run.sh
119
@echo "petals run."
10+
11+
.PHONY: test
12+
test:
13+
@echo "Testing petals..."
14+
bash test.sh
15+
@echo "petals tested."

0 commit comments

Comments
 (0)