Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

prepare_runpod_deepspeed.sh 3.7 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  1. #!/bin/bash
  2. #
  3. # Container source: https://github.com/huggingface/transformers/blob/main/docker/transformers-pytorch-deepspeed-latest-gpu/
  4. #
  5. # This script:
  6. # - cleaned up `prepare_runpod.sh`
  7. # - adapted https://github.com/winglian/axolotl/blob/main/scripts/setup-runpod.sh
  8. # - adapted https://github.com/runpod/containers/tree/main/oobabooga
  9. #
  10. # To run this in RunPod with `huggingface/transformers-pytorch-deepspeed-latest-gpu`, set
  11. # Expose HTTP Ports (Max 10): 7860,8888
  12. # docker command: `bash -c "curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/utensil/llm-playground/main/scripts/prepare_runpod_deepspeed.sh -sSf | bash"`
  13. # WEBUI chatbot
  14. # JUPYTER_PASSWORD change to your secret
  15. # HUGGINGFACE_TOKEN change to your token from https://huggingface.co/settings/tokens
  16. # SUDO nosudo
  17. # WORKSPACE /workspace/
  18. #
  19. # To test this in Codespaces, run `cd /workspaces/ && WORKSPACE=/workspaces/ llm-playground/scripts/prepare_runpod_pytorch.sh`
  20. #
  21. set -euxo pipefail
  22. set -x
  23. CODESPACES=${CODESPACES:-""}
  24. WORKSPACE=${WORKSPACE:-"/workspace"}
  25. cd $WORKSPACE
  26. if [ -z "$CODESPACES" ]; then
  27. nvidia-smi
  28. num_gpus=$(nvidia-smi --query-gpu=name --format=csv,noheader | wc -l)
  29. gpu_indices=$(seq 0 $((num_gpus - 1)) | paste -sd "," -)
  30. export CUDA_VISIBLE_DEVICES=$gpu_indices
  31. echo "CUDA_VISIBLE_DEVICES=$CUDA_VISIBLE_DEVICES"
  32. fi
  33. cd $WORKSPACE
  34. if [ ! -d "llm-playground" ]; then
  35. git clone https://github.com/utensil/llm-playground
  36. fi
  37. cd llm-playground
  38. export DEBIAN_FRONTEND=noninteractive
  39. ./helper/prepare.sh
  40. # Skip CUDA in Codespaces
  41. if [ -z "$CODESPACES" ]; then
  42. pip3 install --force-reinstall https://download.pytorch.org/whl/nightly/cu117/torch-2.0.0.dev20230301%2Bcu117-cp38-cp38-linux_x86_64.whl --index-url https://download.pytorch.org/whl/nightly/cu117
  43. if [ -z "${TORCH_CUDA_ARCH_LIST}" ]; then # only set this if not set yet
  44. # this covers most common GPUs that the installed version of pytorch supports
  45. # python -c "import torch; print(torch.cuda.get_arch_list())"
  46. export TORCH_CUDA_ARCH_LIST="7.0 7.5 8.0 8.6+PTX"
  47. fi
  48. fi
  49. cd $WORKSPACE/llm-playground
  50. LOAD_MODEL=${LOAD_MODEL:-""}
  51. LOAD_DATASET=${LOAD_DATASET:-""}
  52. if [ ! -z "$LOAD_MODEL" ]; then
  53. python ./helper/download-model.py $LOAD_MODEL
  54. fi
  55. if [ ! -z "$LOAD_DATASET" ]; then
  56. python ./helper/download-dataset.py $LOAD_DATASET
  57. fi
  58. mkdir -p $WORKSPACE/llm-playground/models
  59. mkdir -p $WORKSPACE/llm-playground/loras
  60. mkdir -p $WORKSPACE/llm-playground/datasets
  61. python ./helper/upload.py
  62. cd $WORKSPACE
  63. if [ ! -d "text-generation-webui" ]; then
  64. git clone https://github.com/oobabooga/text-generation-webui
  65. fi
  66. cd $WORKSPACE/text-generation-webui/
  67. git pull
  68. pip3 install -r requirements.txt
  69. TMP=$WORKSPACE/tmp/
  70. rm -rf $TMP
  71. mkdir -p $TMP
  72. mv models $TMP
  73. mv loras $TMP
  74. mv training/datasets $TMP
  75. ln -s $WORKSPACE/llm-playground/models ./models
  76. ln -s $WORKSPACE/llm-playground/loras ./loras
  77. ln -s $WORKSPACE/llm-playground/datasets ./training/datasets
  78. cp $WORKSPACE/llm-playground/storage/3b.txt ./training/datasets/3b.txt
  79. # The following is not working on RunPod, the Jupyter notebook can start but websocket connection lost and all executions hang
  80. #
  81. # Will use it only for ssh access for now
  82. #
  83. # cd notebooks
  84. # pip3 install -r requirements.txt
  85. #
  86. # JUPYTER_PASSWORD=${JUPYTER_PASSWORD:-"deepspeed"}
  87. # if [[ $JUPYTER_PASSWORD ]]
  88. # then
  89. # echo "Launching Jupyter Lab"
  90. # cd $WORKSPACE
  91. # jupyter nbextension enable --py widgetsnbextension
  92. # jupyter lab --generate-config
  93. # nohup jupyter lab --config=/root/.jupyter/jupyter_notebook_config.py --allow-root --no-browser --port=8888 --ip=* --ServerApp.token=$JUPYTER_PASSWORD --ServerApp.allow_origin=* --ServerApp.preferred_dir=$WORKSPACE &
  94. # fi
  95. sleep infinity
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...