@@ -81,7 +81,7 @@ Once the pull request is approved, a team member will take care of merging.
8181
8282## Setting up an Environment
8383
84- Python 3.7 or later is required.
84+ Python 3.9 or later is required.
8585
8686Setting up your KerasNLP development environment requires you to fork the
8787KerasNLP repository and clone it locally. With the
@@ -93,72 +93,53 @@ cd keras-nlp
9393```
9494
9595Next we must setup a python environment with the correct dependencies. We
96- recommend using ` conda ` to install tensorflow dependencies (such as CUDA), and
97- ` pip ` to install python packages from PyPI. The exact method will depend on your
98- OS.
99-
100- ** Note** : Please be careful not to use the ` tensorflow ` pre-packaged with conda,
101- which is incompatible with ` tensorflow-text ` on PyPi, and follow the
102- instructions below.
96+ recommend using ` conda ` to set up a base environment, and ` pip ` to install
97+ python packages from PyPI. The exact method will depend on your OS.
10398
10499### Linux (recommended)
105100
106- To setup a complete environment with TensorFlow, a local install of keras-nlp,
107- and all development tools, run the following or adapt it to suit your needs.
101+ For devloping and unit testing the library, a CPU only environment is often
102+ sufficient. For any training or inference with the library, you will quickly
103+ want accelerator support. The easiest way to get GPU support across all of our
104+ backends is to set up a few different python environements and pull in all cuda
105+ dependencies via ` pip ` .
106+
107+ The shell snippet below will install four conda environments: ` keras-nlp-cpu ` ,
108+ ` keras-nlp-jax ` , ` keras-nlp-torch ` , and ` keras-nlp-tensorflow ` . The cpu
109+ environement supports all backends without cuda, and each backend environement
110+ has cuda support.
108111
109112``` shell
110- # Create and activate conda environment.
111- conda create -n keras-nlp python=3.9
112- conda activate keras-nlp
113-
114- # The following can be omitted if GPU support is not required.
115- conda install -c conda-forge cudatoolkit-dev=11.2 cudnn=8.1.0
116- mkdir -p $CONDA_PREFIX /etc/conda/activate.d/
117- echo ' export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/' >> $CONDA_PREFIX /etc/conda/activate.d/env_vars.sh
118- echo ' export XLA_FLAGS=--xla_gpu_cuda_data_dir=$CONDA_PREFIX/' >> $CONDA_PREFIX /etc/conda/activate.d/env_vars.sh
119- source $CONDA_PREFIX /etc/conda/activate.d/env_vars.sh
120-
121- # Install dependencies.
122- python -m pip install --upgrade pip
123- python -m pip install -r requirements.txt
124- python -m pip install -e " ."
113+ conda create -y -n keras-nlp-cpu python=3.10
114+ conda activate keras-nlp-cpu
115+ pip install -r requirements.txt # install deps
116+ python pip_build.py --install # install keras-nlp
117+
118+ for backend in " jax" " torch" " tensorflow" ; do
119+ conda create -y -n keras-nlp-${backend} python=3.10
120+ conda activate keras-nlp-${backend}
121+ pip install -r requirements-${backend} -cuda.txt # install deps
122+ python pip_build.py --install # install keras-nlp
123+ done
125124```
126125
127- ### MacOS
128-
129- ⚠️⚠️⚠️ MacOS binaries are for the M1 architecture are not currently available from
130- official sources. You can try experimental development workflow leveraging the
131- [ tensorflow metal plugin] ( https://developer.apple.com/metal/tensorflow-plugin/ )
132- and a [ community maintained build] ( https://github.com/sun1638650145/Libraries-and-Extensions-for-TensorFlow-for-Apple-Silicon )
133- of ` tensorflow-text ` . These binaries are not provided by Google, so proceed at
134- your own risk.
135-
136- #### Experimental instructions for Arm (M1)
126+ To activate the jax environment and set keras to use jax, run:
137127
138128``` shell
139- # Create and activate conda environment.
140- conda create -n keras-nlp python=3.9
141- conda activate keras-nlp
142-
143- # Install dependencies.
144- conda install -c apple tensorflow-deps=2.9
145- python -m pip install --upgrade pip
146- python -m pip install -r requirements-macos-m1.txt
147- python -m pip install -e " ."
129+ conda activate keras-nlp-jax && export KERAS_BACKEND=jax
148130```
149131
150- #### Instructions for x86 (Intel)
132+ ### MacOS
151133
152- ``` shell
153- # Create and activate conda environment.
154- conda create -n keras-nlp python=3.9
155- conda activate keras-nlp
156-
157- # Install dependencies.
158- python -m pip install --upgrade pip
159- python -m pip install -r requirements.txt
160- python -m pip install -e " ."
161- ```
134+ ` tensorflow-text ` does not release precompiled binaries for MacOS M-series
135+ chips, though the library does support building from source on MacOS.
136+
137+ We strongly recommend a Linux development environment for an easy contribution
138+ experience. To build a dev environement from scratch on MacOS, see the following
139+ guides:
140+
141+ https://developer.apple.com/metal/tensorflow-plugin/
142+ https://github.com/tensorflow/text
162143
163144### Windows
164145
0 commit comments