@@ -84,25 +84,90 @@ Once the pull request is approved, a team member will take care of merging.
8484Python 3.7 or later is required.
8585
8686Setting up your KerasNLP development environment requires you to fork the
87- KerasNLP repository, clone the repository, create a virtual environment, and
88- install dependencies.
89-
90- You can achieve this by running the following commands:
87+ KerasNLP repository and clone it locally. With the
88+ [ GitHub CLI] ( https://github.com/cli/cli ) installed, you can do this as follows:
9189
9290``` shell
9391gh repo fork keras-team/keras-nlp --clone --remote
9492cd keras-nlp
95- python -m venv ~ /keras-nlp-venv
96- source ~ /keras-nlp-venv/bin/activate
97- pip install -e " .[tests]"
9893```
9994
100- The first line relies on having an installation of
101- [ the GitHub CLI] ( https://github.com/cli/cli ) .
95+ Next 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+ ### Linux (recommended)
101+
102+ To setup a complete environment with TensorFlow, a local install of keras-nlp,
103+ and all development tools, run the following or adapt it to suit your needs.
104+
105+ ``` shell
106+ # Create and activate conda environment.
107+ conda create -n keras-nlp python=3.9
108+ conda activate keras-nlp
109+
110+ # The following can be omitted if GPU support is not required.
111+ conda install -c conda-forge cudatoolkit-dev=11.2 cudnn=8.1.0
112+ mkdir -p $CONDA_PREFIX /etc/conda/activate.d/
113+ echo ' export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/' >> $CONDA_PREFIX /etc/conda/activate.d/env_vars.sh
114+ echo ' export XLA_FLAGS=--xla_gpu_cuda_data_dir=$CONDA_PREFIX/' >> $CONDA_PREFIX /etc/conda/activate.d/env_vars.sh
115+ source $CONDA_PREFIX /etc/conda/activate.d/env_vars.sh
116+
117+ # Install dependencies.
118+ python -m pip install --upgrade pip
119+ python -m pip install -r requirements.txt
120+ python -m pip install -e " ."
121+ ```
122+
123+ ### MacOS
124+
125+ ⚠️⚠️⚠️ MacOS binaries are for the M1 architecture are not currently available from
126+ official sources. You can try experimental development workflow leveraging the
127+ [ tensorflow metal plugin] ( https://developer.apple.com/metal/tensorflow-plugin/ )
128+ and a [ community maintained build] ( https://github.com/sun1638650145/Libraries-and-Extensions-for-TensorFlow-for-Apple-Silicon )
129+ of ` tensorflow-text ` . These binaries are not provided by Google, so proceed at
130+ your own risk.
131+
132+ #### Experimental instructions for Arm (M1)
133+
134+ ``` shell
135+ # Create and activate conda environment.
136+ conda create -n keras-nlp python=3.9
137+ conda activate keras-nlp
138+
139+ # Install dependencies.
140+ conda install -c apple tensorflow-deps=2.9
141+ python -m pip install --upgrade pip
142+ python -m pip install -r requirements-macos-m1.txt
143+ python -m pip install -e " ."
144+ ```
102145
103- Following these commands you should be able to run the tests using
104- ` pytest keras_nlp ` . Please report any issues running tests following these
105- steps.
146+ #### Instructions for x86 (Intel)
147+
148+ ``` shell
149+ # Create and activate conda environment.
150+ conda create -n keras-nlp python=3.9
151+ conda activate keras-nlp
152+
153+ # Install dependencies.
154+ python -m pip install --upgrade pip
155+ python -m pip install -r requirements.txt
156+ python -m pip install -e " ."
157+ ```
158+
159+ ### Windows
160+
161+ For the best experience developing on windows, please install
162+ [ WSL] ( https://learn.microsoft.com/en-us/windows/wsl/install ) , and proceed with
163+ the linux installation instruction above.
164+
165+ To run the format and lint scripts, make sure you clone the repo with Linux
166+ style line endings and change any line separator settings in your editor.
167+ This is automatically done if you clone using git inside WSL.
168+
169+ Note that will not support Windows Shell/PowerShell for any scripts in this
170+ repository.
106171
107172## Testing changes
108173
@@ -143,18 +208,3 @@ the following commands manually every time you want to format your code:
143208If after running these the CI flow is still failing, try updating ` flake8 ` ,
144209` isort ` and ` black ` . This can be done by running ` pip install --upgrade black ` ,
145210` pip install --upgrade flake8 ` , and ` pip install --upgrade isort ` .
146-
147- ## Developing on Windows
148-
149- For Windows development, we recommend using WSL (Windows Subsystem for Linux),
150- so you can run the shell scripts in this repository. We will not support
151- Windows Shell/PowerShell. You can refer
152- [ to these instructions] ( https://docs.microsoft.com/en-us/windows/wsl/install )
153- for WSL installation.
154-
155- Note that if you are using Windows Subsystem for Linux (WSL), make sure you
156- clone the repo with Linux style LF line endings and change the default setting
157- for line separator in your Text Editor before running the format
158- or lint scripts. This is automatically done if you clone using git inside WSL.
159- If there is conflict due to the line endings you might see an error
160- like - ` : invalid option ` .
0 commit comments