boris commited on
Commit
7067c27
1 Parent(s): dbf86c9
Files changed (1) hide show
  1. dev/README.md +122 -0
dev/README.md ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Development Instructions for TPU
2
+
3
+ ## Setup
4
+
5
+ - Apply to the [TRC program](https://sites.research.google/trc/) for free TPU credits if you're elligible.
6
+ - Follow the [Cloud TPU VM User's Guide](https://cloud.google.com/tpu/docs/users-guide-tpu-vm) to set up gcloud.
7
+ - Verify `gcloud config list`, in particular account, project & zone.
8
+ - Create a TPU VM per the guide and connect to it.
9
+
10
+ When needing a larger disk:
11
+
12
+ - Create a balanced persistent disk (SSD, so pricier than default HDD but much faster): `gcloud compute disks create DISK_NAME --size SIZE_IN_GB --type pd-balanced`
13
+ - Attach the disk to your instance by adding `--data-disk source=REF` per ["Adding a persistent disk to a TPU VM" guide](https://cloud.google.com/tpu/docs/setup-persistent-disk), eg `gcloud alpha compute tpus tpu-vm create INSTANCE_NAME --accelerator-type=v3-8 --version=v2-alpha --data-disk source=projects/tpu-toys/zones/europe-west4-a/disks/DISK_NAME`
14
+ - Format the partition as described in the guide.
15
+ - Make sure to set up automatic remount of disk at restart.
16
+
17
+ ## Connect VS Code
18
+
19
+ - Find external IP in the UI or with `gcloud alpha compute tpus tpu-vm describe INSTANCE_NAME`
20
+ - Verify you can connect in terminal with `ssh EXTERNAL_IP -i ~/.ssh/google_compute_engine`
21
+ - Add the same command as ssh host in VS Code.
22
+ - Check config file
23
+
24
+ ```
25
+ Host INSTANCE_NAME
26
+ HostName EXTERNAL_IP
27
+ IdentityFile ~/.ssh/google_compute_engine
28
+ ```
29
+
30
+ ## Environment configuration
31
+
32
+ ### Use virtual environments (optional)
33
+
34
+ We recommend using virtual environments (such as conda, venv or pyenv-virtualenv).
35
+
36
+ If you want to use `pyenv` and `pyenv-virtualenv`:
37
+
38
+ - Installation
39
+
40
+ - [Set up build environment](https://github.com/pyenv/pyenv/wiki#suggested-build-environment)
41
+ - Use [pyenv-installer](https://github.com/pyenv/pyenv-installer): `curl https://pyenv.run | bash`
42
+ - bash set-up:
43
+
44
+ ```bash
45
+ echo '\n'\
46
+ '# pyenv setup \n'\
47
+ 'export PYENV_ROOT="$HOME/.pyenv" \n'\
48
+ 'export PATH="$PYENV_ROOT/bin:$PATH" \n'\
49
+ 'eval "$(pyenv init --path)" \n'\
50
+ 'eval "$(pyenv init -)" \n'\
51
+ 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
52
+ ```
53
+
54
+ - Usage
55
+
56
+ - Install a python version: `pyenv install X.X.X`
57
+ - Create a virtual environment: `pyenv virtualenv 3.9.6 dalle_env`
58
+ - Activate: `pyenv activate dalle_env`
59
+
60
+ Note: you can auto-activate your environment at a location with `echo dalle_env >> .python-version`
61
+
62
+ ### Tools
63
+
64
+ - Git
65
+
66
+ - `git config --global user.email "[email protected]"
67
+ - `git config --global user.name "First Last"
68
+
69
+ - Github CLI
70
+
71
+ - See [installation instructions](https://github.com/cli/cli/blob/trunk/docs/install_linux.md)
72
+ - `gh auth login`
73
+
74
+ - Direnv
75
+
76
+ - Install direnv: `sudo apt-get update && sudo apt-get install direnv`
77
+ - bash set-up:
78
+
79
+ ```bash
80
+ echo -e '\n'\
81
+ '# direnv setup \n'\
82
+ 'eval "$(direnv hook bash)" \n' >> ~/.bashrc
83
+ ```
84
+
85
+ ### Set up repo
86
+
87
+ - Clone repo: `gh repo clone borisdayma/dalle-mini`
88
+ - If using `pyenv-virtualenv`, auto-activate env: `echo dalle_env >> .python-version`
89
+
90
+ ## Environment
91
+
92
+ - Install the following (use it later to update our dev requirements.txt)
93
+
94
+ ```
95
+ requests
96
+ pillow
97
+ jupyterlab
98
+ ipywidgets
99
+
100
+ -e ../datasets[streaming]
101
+ -e ../transformers
102
+ -e ../webdataset
103
+
104
+ # JAX
105
+ --find-links https://storage.googleapis.com/jax-releases/libtpu_releases.html
106
+ jax[tpu]>=0.2.16
107
+ flax
108
+ ```
109
+
110
+ - `transformers-cli login`
111
+
112
+ ---
113
+
114
+ - set `HF_HOME="/mnt/disks/persist/cache/huggingface"` in `/etc/environment` and ensure you have required permissions, then restart.
115
+
116
+ ## Working with datasets or models
117
+
118
+ - Install [Git LFS](https://github.com/git-lfs/git-lfs/wiki/Installation)
119
+ - Clone a dataset without large files: `GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/datasets/.../...`
120
+ - Use a local [credential store](https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage) for caching credentials
121
+ - Track specific extentions: `git lfs track "*.ext"`
122
+ - See files tracked with LFS with `git lfs ls-files`